Refactor GetBlockVerboseTx to reflect correct getblock RPC call parameters. #1528
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, rpcclient.GetBlockVerboseTx(...) does not return raw transaction data. This is due to how GetBlockCmd is implemented in btcjson; in upstream/master,
getblock
sends two boolean parameters (verbose
andverbosetx
), which throws an error.According to the bitcoin JSON RPC documentation,
getblock
accepts two parameters:blockhash
(as a string) andverbosity
(as an integer).verbosity
can be any of0
,1
, or2
, with0
being the default.This pull request aims to correctly implement
verbosity
as a parameter togetblock
by refactoringGetBlockCmd
(inbtcjson/chainsvrcmds.go
) to have two fields:Hash
andVerbosity
, withVerbosity
being an optional int pointer.In order to implement correct behavior, three primary changes are necessary: the above refactor, an additional type specific to
getblock verbosity=2
, and a newFuture
type to enable proper (and error-free) unmarshalling ofverbosity=2
data.The new type (
GetBlockVerboseTxResult
) is almost entirely the same asGetBlockVerboseResult
, but with the minor modification of changing theTx
field from a[]string
to a[]TxRawResult
so as to enable proper unmarshalling.The new
Future
type (FutureGetBlockVerboseTxResult
) returns aGetBlockVerboseTxResult
rather than aGetBlockVerboseResult
so that data can be properly returned to the user without error.