Beispiel #1
0
func (bc *BtcCred) SignOcReq(req *msg.OcReq, conf *util.BitcoindConf) error {
	h, err := getReqSigDataHash(req)
	if err != nil {
		return err
	}
	hb64 := base64.StdEncoding.EncodeToString(h)

	msg, err := btcjson.NewSignMessageCmd(nil, bc.Addr, hb64)
	if err != nil {
		return fmt.Errorf("error while making cmd: %v", err.Error())
	}
	json, err := msg.MarshalJSON()
	if err != nil {
		return fmt.Errorf("error while marshaling: %v", err.Error())
	}
	resp, err := btcjson.RpcCommand(conf.User, conf.Password, conf.Server, json)
	if err != nil {
		return fmt.Errorf("error while making bitcoind JSON-RPC: %v", err.Error())
	}
	sig, ok := resp.Result.(string)
	if !ok {
		return errors.New("error during bitcoind JSON-RPC")
	}

	req.Coins = append(req.Coins, fmt.Sprintf(bc.Addr))
	req.CoinSigs = append(req.CoinSigs, fmt.Sprintf(sig))

	return nil
}
Beispiel #2
0
// makeSignMessage generates the cmd structure for signmessage commands.
func makeSignMessage(args []interface{}) (btcjson.Cmd, error) {
	return btcjson.NewSignMessageCmd("btcctl", args[0].(string),
		args[1].(string))
}