Beispiel #1
0
// makeSubmitBlock generates the cmd structure for submitblock commands.
func makeSubmitBlock(args []interface{}) (btcjson.Cmd, error) {
	opts := &btcjson.SubmitBlockOptions{}
	if len(args) == 2 {
		opts.WorkID = args[1].(string)
	}

	return btcjson.NewSubmitBlockCmd("btcctl", args[0].(string), opts)
}
Beispiel #2
0
// SubmitBlockAsync 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 SubmitBlock for the blocking version and more details.
func (c *Client) SubmitBlockAsync(block *btcutil.Block, options *btcjson.SubmitBlockOptions) FutureSubmitBlockResult {
	blockHex := ""
	if block != nil {
		blockBytes, err := block.Bytes()
		if err != nil {
			return newFutureError(err)
		}

		blockHex = hex.EncodeToString(blockBytes)
	}

	id := c.NextID()
	cmd, err := btcjson.NewSubmitBlockCmd(id, blockHex, options)
	if err != nil {
		return newFutureError(err)
	}

	return c.sendCmd(cmd)
}