Commit graph

187 commits

Author SHA1 Message Date
Dave Collins
016e69cd51 Convert RawCmd to use raw messages for params.
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
2014-04-10 20:59:46 -05:00
David Hill
8a503c6148 Add addrlocal to GetPeerInfoResult.
ok @davecgh
2014-04-09 22:39:25 -04:00
David Hill
50473f6ed3 Add support for CreateMultiSigResult.
ok @jcvernaleo
2014-04-09 13:45:55 -04:00
Dave Collins
dd926bfdf9 Add support for ListTransactionsResult.
ok @jcvernaleo.
2014-04-09 09:07:53 -05:00
Dave Collins
7c39a02ed1 Correct ReadResultCmd for getaddednodeinfo.
The returned result was previously a []interface{} instead of a
[]GetAddedNodeInfoResult.  This commit resolves that issue.

ok @jcvernaleo
2014-04-08 07:57:31 -05:00
David Hill
b0242a8793 Add missing fields to ValidateAddressResult structure
ok @jrick
2014-04-07 14:07:38 -04:00
John C. Vernaleo
71e31f03a2 Update coverage report. 2014-03-16 14:18:43 -04:00
Francis Lam
8f69a0bf69 Added new RelayFee field and missing TimeOffset field to InfoResult 2014-03-15 15:34:55 -04:00
jolan
1bc63bfd5d recieve->receive 2014-03-14 15:08:51 -05:00
Dave Collins
f65ea832de Export a couple of peer-to-peer client errors.
ok @jcvernaleo
2014-03-12 10:11:18 -05:00
John C. Vernaleo
21b974e271 Fix missing ) in comment. 2014-02-20 10:52:06 -05:00
Dave Collins
81843d269f Add support for GetRawMempoolResult. 2014-02-16 14:02:24 -06:00
Dave Collins
6a2b93e622 Add support for GetPeerInfoResult. 2014-02-16 13:45:04 -06:00
Dave Collins
5135fd3203 Allow getwork result to be a bool or JSON object.
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.
2014-02-11 17:44:48 -06:00
Dave Collins
a733633685 Correct GetWorkCmd.
The getwork RPC now only accepts a single optional parameter which, if
present, is a string containing the hex-encoded block data to solve.

Also update the tests for the new correct parameters.

ok @jcvernaleo
2014-02-11 16:45:48 -06:00
Dave Collins
cace9187d7 Correct typo in CmdGenerator comment. 2014-02-09 22:30:22 -06:00
Francis Lam
bfe374e735 Added comments for CmdGenerator and RegisterCustomCmdGenerator 2014-02-08 17:55:11 -05:00
Francis Lam
773efd633d Added RegisterCustomCmdGenerator to btcjson package
Allows for addition of custom Cmd classes that implement UnmarshalJSON
directly as opposed to via RawCmd object and RawCmdParser
2014-02-08 16:41:36 -05:00
Dave Collins
7623d13c37 Make getnetworkhashps result an int64. 2014-02-07 12:10:10 -06:00
Dave Collins
397c4caefe Correct getnettotals help message. 2014-02-05 10:51:59 -06:00
Dave Collins
4661be8758 Add support for GetNetTotalsResult.
ok @jcvernaleo
2014-02-05 09:43:25 -06:00
John C. Vernaleo
0d1539118b Add some missing comments on exported items. 2014-02-04 17:10:37 -05:00
David Hill
ae21689a57 gofmt 2014-02-04 16:13:24 -05:00
David Hill
25bb31ebd5 use bytes.Equal instead. 2014-02-04 15:40:16 -05:00
David Hill
ced679c4e5 Fix getreceivedby[account|address] api. The first parameter is not
optional.
2014-01-30 11:48:27 -05:00
David Hill
cbe4b140b9 Change the optional parameter for getrawtransaction from bool to int.
This matches bitcoind.

ok oga@
2014-01-29 21:19:07 -05:00
Dave Collins
6e2fa5aad7 Allow getaddednodeinfo result to be string slice.
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.
2014-01-24 22:41:52 -06:00
Dave Collins
421f4c54a0 Add support for GetAddedNodeInfoResult.
ok @jcvernaleo.
2014-01-24 14:50:34 -06:00
David Hill
4a93564b04 Add getwork result infrastructure. Make the work request optional. 2014-01-23 17:30:44 -05:00
David Hill
908945ed53 fix getwork API
closes #12
2014-01-23 15:55:52 -05:00
Owain G. Ainsworth
3c1bcb86ee add newsize parameter to keypoolrefill 2014-01-22 16:20:08 +00:00
Owain G. Ainsworth
99fdcf5d09 Add allowhighfees to SendRawTransactionCmd 2014-01-22 16:20:08 +00:00
Owain G. Ainsworth
5619604c21 Add addresses member to ListUnspentCmd 2014-01-22 16:20:08 +00:00
Owain G. Ainsworth
b677a421d0 Add an interface to provide help text for supported commands.
This changes the api to register new commands to also pass in the help
text.
2014-01-22 16:20:08 +00:00
Dave Collins
bf90ed2142 Add 2014 to copyright dates. 2014-01-08 23:49:06 -06:00
John C. Vernaleo
6747e36f51 Slight increase in test coverage. 2014-01-08 10:31:54 -05:00
John C. Vernaleo
d1efe0c109 Add SetId() to Cmd along with tests. 2014-01-08 09:36:43 -05:00
John C. Vernaleo
ee378dc0c0 Add additional tests for listreceivedbyaccount.
Fix bug caught by tests.
2014-01-07 13:49:45 -05:00
John C. Vernaleo
cea1120a0a Add tests for listreceivebyaddress.
Fix bug with minconf type caught by test (thanks oga).
2014-01-07 13:44:12 -05:00
John C. Vernaleo
5ced990c22 Add test for listsinceblock.
Fix bug in listsinceblock found by test.
2014-01-06 11:02:32 -05:00
John C. Vernaleo
0ef1452247 Improve test coverage a bit.
Fix bug in a json command caught by new test.
2014-01-06 10:40:23 -05:00
Dave Collins
e1053b4a95 Add P2sh field to DecodeScriptResult. 2014-01-04 11:54:39 -06:00
Dave Collins
f78d054700 Add struct for DecodeScriptResult. 2014-01-03 18:20:06 -06:00
John C. Vernaleo
258e9ef4c6 Add test for the Cmd.Id() functions. 2014-01-03 17:50:17 -05:00
John C. Vernaleo
2944ccb86b Update coverage report. 2014-01-03 12:02:41 -05:00
Dave Collins
84cb4c7130 Export new function ConvertCreateRawTxParams.
The inputs to the createrawtransaction command are JSON strings, however
the NewCreateRawTransactionCmd function takes concrete types.  Thus,
callers which deal with the raw JSON need a method to perform the
validation and conversion.  This logic is the same as what needs to happen
when unmashalling a full JSON-RPC command, so this commit factors that
logic out into a separate function and exports it.
2014-01-03 10:25:06 -06:00
Dave Collins
8d7354f45b Gofmt. 2014-01-03 10:22:07 -06:00
Francis Lam
5d91e16e7c Added MarshalJSON to Vin and changed Vout.ScriptPubKey
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
2013-12-30 20:36:46 -06:00
Dave Collins
c0236b5a2f Change LockTime in TxRawDecodeResult to uint32. 2013-12-30 18:42:46 -06:00
Dave Collins
11d39125de The sequence num of a tx input is a uint32. 2013-12-27 12:38:11 -06:00