Commit Graph

73 Commits

Author SHA1 Message Date
Dave Collins
b585d4e3a0 Make params which reference txout indices uint32.
This reasons for this change follow:

- All instances of the same key should be consistent amongst the commands
  and returns
- Output indices can't be negative, so rather than adding more code to
  check for a negative after unmarshal, just allow the unmarshal to weed
  out negatives

ok @jcvernaleo
2014-06-16 14:44:04 -05:00
David Hill
39b09f7be1 Add support for estimatefee and estimatepriority. 2014-06-11 11:05:13 -04:00
David Hill
529036ec2b Implement getnetworkinfo 2014-05-14 11:45:13 -04:00
David Hill
4f0eb662c8 Support getblockchaininfo 2014-05-12 12:53:34 -04:00
Dave Collins
48bcbc5a22 Move result structs and funcs to jsonresults.go.
This commit moves all of the structs which deal with command results and
related functions to a new file named jsonresults.go.

This is in preparation of allowing custom results to be registered.

ok @jcvernaleo
2014-04-11 11:09:40 -05:00
Dave Collins
95f8e5d6d8 Deprecate CreateMessage(WithId) and update docs.
This commit marks the CreateMessage and CreateMessageWithId functions as
deprecated as they are no longer maintained due to the new concrete
command approach.

It also updates the package documentation to show the new preferred method
as well as add details about btcd.

ok @jcvernaleo
2014-04-11 11:01:02 -05:00
Dave Collins
3513654933 Add new (Tls)RpcSend funcs to send a Cmd.
The existing RpcCommand and TlsRpcCommand were build with
CreateMessage(WithID) in mind since they return an already marshalled
command.  The approach was changed to use concrete commands created via
the New<command>Cmd family of functions.  However, this means the caller
had to manually marshal the command before calling (Tls)RpcCommand which
was not very user friendly.

This commit adds two new functions named RpcSend and TlsRpcSend which
directly accepts a btcjson.Cmd and handles the marshalling itself.

ok @jcvernaleo
2014-04-11 10:49:49 -05:00
Dave Collins
0512ddd8f8 Correct ListTransactionsResult.
This commit tweaks the ListTransactions result a bit so it is compatible
with the reference implementation.
2014-04-11 08:45:01 -05:00
David Hill
75a237bc0d Add support for GetTransactionResult.
ok @jcvernaleo
2014-04-11 09:39:08 -04:00
Dave Collins
d211c4c6c8 Correct TxID JSON key of ListTransactionsResult. 2014-04-10 22:26:44 -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
Francis Lam
8f69a0bf69 Added new RelayFee field and missing TimeOffset field to InfoResult 2014-03-15 15:34:55 -04: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
7623d13c37 Make getnetworkhashps result an int64. 2014-02-07 12:10:10 -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
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
Dave Collins
bf90ed2142 Add 2014 to copyright dates. 2014-01-08 23:49:06 -06: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
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
Dave Collins
d3b76da919 Make ScriptSig anonymous struct an exported type.
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.
2013-12-27 12:22:37 -06:00
Dave Collins
509bf830b1 Correct Vin ScriptSig to properly omit when empty.
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).
2013-12-27 11:27:52 -06:00
Dave Collins
1855c19562 Allow getrawtransaction result to be string.
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.
2013-12-26 21:28:57 -06:00
Dave Collins
e0e4c8bdb6 Allow getblock result to be string or BlockResult.
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.
2013-12-26 10:39:10 -06:00
Owain G. Ainsworth
4cb318ac02 Handle optional verbose parameter to getrawmempool.
This does remove the `nicer' type handle for getrawmempool for now since
it is no longer so simple.

ok jcv.
2013-12-16 18:01:45 +00:00
John C. Vernaleo
4d0cbb776b Make id omitemtpy to match spec better. 2013-12-11 13:42:29 -05:00
Francis Lam
91a19dda85 Fixed TxRawResult/Vin structure and added GetBlockCmd verbose flags
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
2013-12-08 14:51:18 -05:00
John C. Vernaleo
7397dd6896 Rename reqSig to reqSigs
Match bitcoin json name better.

Closes #9
2013-11-22 08:48:02 -05:00
Owain G. Ainsworth
e43c79c74d add TlsRpcCommand and TlsRawRpcCommand.
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.
2013-11-19 14:46:17 +00:00
John C. Vernaleo
606262514b Improve error messages.
Attempt to determine if error when sending a command is due to auth
issue and give more useful error in that case.
2013-11-18 13:23:05 -05:00
John C. Vernaleo
cbd3d730a9 Add initial support for submitblock command.
Closes #7
2013-10-22 15:11:01 -04:00
John C. Vernaleo
850870f14b Fix some doc typos (from oga@) 2013-10-22 09:18:55 -04:00
John C. Vernaleo
440f336d34 Correct addnode's required argument type. 2013-10-21 13:22:52 -04:00
Josh Rickmar
31489c15b3 Remove the embedded error and satisify the builtin error interface
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.
2013-10-14 13:16:37 -04:00
John C. Vernaleo
7ad6d73416 Add support for recent commands:
getrawchangeaddress and getbestblockhash.
2013-10-11 15:12:27 -04:00
John C. Vernaleo
5444d262b8 Fix for signrawtransaction.
Add sendrawtransaction to list of commands we know the return type
for.
2013-10-04 13:18:49 -04:00
John C. Vernaleo
dc9618c9ab Add a Error() to the Error struct.
Resolves #6
2013-10-01 12:50:50 -04:00
John C. Vernaleo
5d40d51672 Correct bug in walletpassphrase arguements.
Thanks to pureveg and hngchiming for pointing it out.
2013-08-14 10:15:16 -04:00