The getwork command alters the output depending on whether or not the
optional data parameter was specified. It is a JSON object when no data
was provided, and a boolean indicating whether a solution was found
when data was provided.
The getaddednode command dns flag alters the output. It is a JSON object
when true and a slice of strings containing the addresses when false.
Note there is a bug in bitcoind as of version 0.8.6 which returns the
addresses as a JSON object with duplicate keys. This has been reported as
issue 3581 on the bitcoind issue tracker.
This commit allows the result for getaddednodeinfo to be either the JSON
object or the string slice.
Added MarshalJSON method to Vin which properly omits the Vout field
from coinbase Vin's by using anonymous structs with the proper
subsets of fields outputted by bitcoind
Changed Vout.ScriptPubKey to add omitempty for ReqSigs and Addresses:
both fields are not shown when there is an error identifying to
scriptType or parsing addresses in bitcoind
The previous commit modified the Vin ScriptSig field to be a pointer to an
anonymous struct so it could be properly omitted. However, the callers
need to be able to create a new object to assign to the field, so this
commit makes the previous anonymous struct an exported type named
ScriptSig.
In order for a field which is a struct to be omitted from JSON
marshal/unmarshal, it must be a pointer so the json package can tell when
it's empty (when it's nil).
The getrawtransaction command has recently added a verbose flag which
alters the output. The previous code made use of the "Hex" field of the
TxRawResult to return the information, but this is not consistent with the
original getrawtransaction RPC call which returns a string when verbose is
false and the TxRawResult JSON object when it is true.
This commit corrects that by allowing the result for getrawtransaction to
be either form.
The getblock command has recently added a verbose flag which alters the
output. The previous code added a new field "Hex" to the BlockResult, but
this is not consistent with the origin getblock RPC call which returns a
string when verbose is false and the BlockResult JSON object when it is
true.
This commit corrects that by first removing the Hex field from the
BlockResult and second allowing the result for getblock to be either form.
Changed TxRawResult to omitempty block info for mempool tx as well as
moved Txid to Vin.TxId from Vin.ScriptSig.Txid (both match bitcoind
output)
Added support for new bitcoind [verbose=true] and added non-standard
optional verboseTx to return TxRawResults intead Txids
These act the same as the !tls versions of this code but they take a PEM
encoded certificate chain to be used to verify certificates (ca verified
certs could use /etc/ssl/certs.pem) and a parameter to skip cert
verification and will use https internally.
This also adds tests to verify that the created error string follows
the expected format of "code: message" and tests to verify that Error
can be used as an error. Additionally, the idiom
var _, _ error = Error{}, &Error{}
was added so the build will fail if the builtin error interface is
never satisified in the future.
Add new RpcRawCommand to get []byte represtation of reply instead of
btcjson.Result.
Export ReadResultCommand to allow caller of RpcRawCommand to deal with
the reply in the same way RpcCommand does.
Adjust test code to for the above changes.
Add return types for serveral additional commands.
Fix required vs. optional arguments for createrawtransaction.
Update tests and test coverage for all changes.