From 6e5c0a79044d3d80a22d94049eeb509ea040efac Mon Sep 17 00:00:00 2001 From: David Hill Date: Thu, 15 Sep 2016 16:01:54 -0400 Subject: [PATCH] Fix GetBlockVerbose API. This changes the GetBlockVersion API to not send a third parameter. The third parameter is a boolean that expands the transaction data structures as well. However, Bitcore Core does not recognize this feature. GetBlockVerbose now only takes a hash value. Users of the GetBlockVerbose(hash, true) must now use GetBlockVerboseTx(hash). --- chain.go | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/chain.go b/chain.go index 369632df..30543b0d 100644 --- a/chain.go +++ b/chain.go @@ -134,22 +134,47 @@ func (r FutureGetBlockVerboseResult) Receive() (*btcjson.GetBlockVerboseResult, // the returned instance. // // See GetBlockVerbose for the blocking version and more details. -func (c *Client) GetBlockVerboseAsync(blockHash *chainhash.Hash, verboseTx bool) FutureGetBlockVerboseResult { +func (c *Client) GetBlockVerboseAsync(blockHash *chainhash.Hash) FutureGetBlockVerboseResult { hash := "" if blockHash != nil { hash = blockHash.String() } - cmd := btcjson.NewGetBlockCmd(hash, btcjson.Bool(true), &verboseTx) + cmd := btcjson.NewGetBlockCmd(hash, btcjson.Bool(true), nil) return c.sendCmd(cmd) } // GetBlockVerbose returns a data structure from the server with information // about a block given its hash. // +// See GetBlockVerboseTx to retrieve transaction data structures as well. // See GetBlock to retrieve a raw block instead. -func (c *Client) GetBlockVerbose(blockHash *chainhash.Hash, verboseTx bool) (*btcjson.GetBlockVerboseResult, error) { - return c.GetBlockVerboseAsync(blockHash, verboseTx).Receive() +func (c *Client) GetBlockVerbose(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseResult, error) { + return c.GetBlockVerboseAsync(blockHash).Receive() +} + +// GetBlockVerboseTxAsync 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 GetBlockVerboseTx or the blocking version and more details. +func (c *Client) GetBlockVerboseTxAsync(blockHash *chainhash.Hash) FutureGetBlockVerboseResult { + hash := "" + if blockHash != nil { + hash = blockHash.String() + } + + cmd := btcjson.NewGetBlockCmd(hash, btcjson.Bool(true), btcjson.Bool(true)) + return c.sendCmd(cmd) +} + +// GetBlockVerboseTx returns a data structure from the server with information +// about a block and its transactions given its hash. +// +// See GetBlockVerbose if only transaction hashes are preferred. +// See GetBlock to retrieve a raw block instead. +func (c *Client) GetBlockVerboseTx(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseResult, error) { + return c.GetBlockVerboseTxAsync(blockHash).Receive() } // FutureGetBlockCountResult is a future promise to deliver the result of a