This is no longer required since the RawCmd params now consist of a slice
of raw JSON messages which the registered parser can directly unmarshal.
ok @jcvernaleo
This commit modifies the RawCmd type to use a slice of json.RawMessages so
that unmarshalling each individual parameter can be deferred to the
handler for the command.
This is superior to the old method of using a []interface{} because it
means that each parameter is now unmarshalled into the expected concrete
type directly instead of whatever it happens to be in the JSON. Due to
this, the old behavior where every number was unmarshlled as a float64 and
converted to the appropriate final type, which could lead to odd behavior
when going through marshal/unmarshal cycles, has been eliminated. This
change also means each individual parameter can now be full blown structs
(JSON objects) that marshal and unmarshal themselves which greatly
simplifies complex parameters and removes the need for additional and
error prone code.
This commit contains a lot of changes because every command needed its
MarshalJSON and UnmarshalJSON methods updated to support the new
mechanism. As a part of changing these functions, a new common creation
function for the the RawCmd struct was added to avoid the previous
duplication of the common fields. Also, rather than repeating the method
string in each MarshJSON functon, it makes use of cmd.Method().
Finally, some of the error messages were incorrect and have been corrected
as well as made consistent.
ok @jcvernaleo, @jrick, @owainga
Fix move need to convert amount to btc from satoshi
Fix settxfee need to convert amount to btc from satoshi
Fix for optional arg off by one in move.
Fix for gettxout in optional args along with typo in error message.
And lots of new tests.
Test stop, signrawtransaction, setaccount, sendtoaddress, and a few
others.
Fix off by one error in the optional arguments for sendtoaddress.
Rename occurances of Minconf to MinConf for constitancy.
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.
Following the example of bitcoind and the bitcoin wiki, provide a
function to convert floats (which are returned by the json-rpc server)
to int64 (which is the normal representation for most values involving
bitcoins).
Since we already have the specific username and password we want to strip
from errors, use a specific search string rather than a generic regular
expression. This is quite a bit more efficient than using regular
expressions and also has the benefit of being more accurate.
Also, rather than using the added overhead of fmt to convert the error to
a string, just call Error() directly on it to get the string.
Finally, instead of just stripping it, replace it with the literal
string "<username>:<password>" to avoid any possible confusion in the
error messages where it might otherwise appear the url was being
constructed incorrectly.
ok jcv@