// SignRawTransaction2Async returns an instance of a type that can be used to // get the result of the RPC at some future time by invoking the Receive // function on the returned instance. // // See SignRawTransaction2 for the blocking version and more details. func (c *Client) SignRawTransaction2Async(tx *btcwire.MsgTx, inputs []btcjson.RawTxInput) FutureSignRawTransactionResult { txHex := "" if tx != nil { // Serialize the transaction and convert to hex string. buf := bytes.NewBuffer(make([]byte, 0, tx.SerializeSize())) if err := tx.Serialize(buf); err != nil { return newFutureError(err) } txHex = hex.EncodeToString(buf.Bytes()) } id := c.NextID() cmd, err := btcjson.NewSignRawTransactionCmd(id, txHex, inputs) if err != nil { return newFutureError(err) } return c.sendCmd(cmd) }
// makeSignRawTransaction generates the cmd structure for signrawtransaction commands. func makeSignRawTransaction(args []interface{}) (btcjson.Cmd, error) { optArgs := make([]interface{}, 0, 3) if len(args) > 1 { var inputs []btcjson.RawTxInput err := json.Unmarshal([]byte(args[1].(string)), &inputs) if err != nil { return nil, err } optArgs = append(optArgs, inputs) } if len(args) > 2 { var inputs []string err := json.Unmarshal([]byte(args[2].(string)), &inputs) if err != nil { return nil, err } optArgs = append(optArgs, inputs) } if len(args) > 3 { optArgs = append(optArgs, args[3]) } return btcjson.NewSignRawTransactionCmd("btcctl", args[0].(string), optArgs...) }