Commit graph

2293 commits

Author SHA1 Message Date
Dale Rahn
ae25e28d7e Update test to new API. 2014-04-15 10:47:29 -04:00
Dale Rahn
dd41d71a31 If data for tx is not present, return error. 2014-04-15 10:47:25 -04:00
Dale Rahn
4d63076526 All external entry points into the database must be locked. 2014-04-15 10:17:37 -04:00
Dave Collins
f389d39c43 Update tests for notifynewtxs -> notifyreceived. 2014-04-14 22:45:56 -05:00
Dave Collins
0b4401ddb6 Rename NotifyNewTXsCmd to NotifyReceivedCmd.
This commit renamed the notifynewtxs RPC to notifyreceived since it more
accurately reflects its intention which is to register addresses to be
notified about when they receive funds.

This is work towards conformal/btcd#98.

ok @jrick.
2014-04-14 22:18:54 -05:00
Dave Collins
05a7979292 Update for notifynewtxs to notifyreceived rename.
The websocket extension command to register for notifications when an
address receives funds has been renamed.  This commit catches up to the
change.
2014-04-14 19:11:08 -05:00
Dave Collins
de51409185 Add debug print for chain verify.
Since a chain verification can take a long time depending on the
parameters, this commit adds a debug print to the RPC server at the info
level for how many blocks are being verified and at what level.

The logic was also slightly modified so the number of blocks being checked
can easily be calculated and shown.
2014-04-14 10:29:51 -05:00
Josh Rickmar
79beb22aef Export CoinbaseMaturity as a const.
The unexported variable is still kept so that tests may modify it.

ok @davecgh
2014-04-14 08:45:43 -05:00
David Hill
3937c1a67c This RPCS debug statement should be a trace. 2014-04-13 15:50:28 -04:00
David Hill
997d98bddf add a few missing and fix misspelled commands. 2014-04-12 10:47:07 -04:00
David Hill
ea7947f74e Add support for decodescript concrete result. 2014-04-12 10:41:32 -04:00
Dave Collins
0ca3d386ed Add support for listaccounts concrete result. 2014-04-12 02:40:06 -05:00
David Hill
372e8c1926 Add support for ListSinceBlockResult
ok @davecgh
2014-04-11 20:17:21 -04:00
David Hill
e6dca4de6f Add UnlockedUntil to InfoResult. 2014-04-11 18:59:10 -04:00
Dave Collins
0a14b19276 Redo ListTransactionsResult fix.
This was also lost in the move to jsonresults.go.
2014-04-11 14:56:55 -05:00
Dave Collins
31a354e585 Add support for registering custom reply parsers.
This commit extends the RegisterCustomCmd function to also accept a reply
parser which will be invoked for replies to the custom command via
ReadResultCmd.  This allows replies to custom commands to be returned a
concrete structs instead of map[string]interface{}.

ok @jcvernaleo, @jrick
2014-04-11 14:27:59 -05:00
Dave Collins
db5bc2c77c Add reply parser for ListAddressTransactionCmd.
ok @jrick
2014-04-11 14:13:55 -05:00
Dave Collins
3208b7ae75 Update for btcjson RegisterCustomCmd API change. 2014-04-11 14:13:51 -05:00
David Hill
1240483592 gofmt 2014-04-11 14:54:44 -04:00
David Hill
c2dd398b1e Add support for GetTransactionResult.
ok @jcvernaleo
2014-04-11 14:06:44 -04:00
Josh Rickmar
c6149949a2 Redo the ListTransactionsResult amount->txid fix.
This likely got lost in a merge or the move to the jsonresults.go
file.
2014-04-11 12:39:18 -05:00
Dave Collins
fbe04b73ab Rename jsonresult_test.go -> jsonresults_test.go.
This matches the name of the file that contains the code it is testing.
2014-04-11 11:11:42 -05: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
fdc49d6a30 Convert NewTxNtfn to use new concrete type.
The NewTxNtfn notification was previously using a map[string]interface.
This commit modifies it to use the new concrete type
btcjson.ListTransactionsResult instead which allows nicer marshalling and
unmarshalling.

ok @jrick
2014-04-11 10:02:16 -05:00
Dave Collins
1ff465ae88 Remove RegisterCustomCmdGenerator.
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
2014-04-11 09:38:15 -05:00
Dave Collins
fc07555ad3 Update for latest btcjson API changes.
This commit modifies the AllVerboseTxNtfn command to use a parser along
with the standard btcjson.RegisterCustomCmd instead of the now removed
RegisterCustomCmdGenerator function.  This is possible due to the recent
changes that defers the unmarshalling of the parameters of a RawCmd to the
parser.
2014-04-11 09:20:25 -05:00
Dave Collins
6f08ca8a8a Correct unmarshal for GetAddressBalanceCmd.
The unmarshaller for the GetAddressBalanceCmd was calling the wrong parse
function.  It wasn't caught by the tests because the error on
UnmarshalJSON was being ignored, so this commit also updates the tests to check the
error.
2014-04-11 09:04:53 -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
Josh Rickmar
42061ebf87 Update for btcws API change. 2014-04-10 21:12:40 -05:00
Dave Collins
a0bfde8db0 Update btcctl for latest btcjson changes. 2014-04-10 21:12:40 -05:00
Dave Collins
bfcd7f6790 Update for latest btcjson.RawCmd changes.
This commit modifies all of the commands and notifications to work
properly with the latest btcjson.RawCmd Params field changes.

This new approach 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.

Since it is now preferred to use full blown structs for individual
parameters, the RescanCmd type has been changed to use a new OutPoint
that can be used directly for marshalling and unmarshalling instead of a
*btcwire.OutPoint.

Also, all of the MarshalJSON functions now make use of the new
btcjson.NewRawCmd function rather than repeating the same common field
over and over and all of the MarshalJSON, UnmarshalJSON, and parseX
functions have been made more consistent.

ok @jrick
2014-04-10 21:10:16 -05:00
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
Josh Rickmar
1fd5cd2742 Use btcws.GetBestBlockResult. 2014-04-10 20:03:54 -05:00
Josh Rickmar
b77de52d3d Move GetBestBlockResult struct from btcwallet. 2014-04-10 16:42:28 -05:00
David Hill
8a503c6148 Add addrlocal to GetPeerInfoResult.
ok @davecgh
2014-04-09 22:39:25 -04:00
Owain G. Ainsworth
03dd134305 adapt for btcec changes. 2014-04-09 19:30:59 +01:00
Owain G. Ainsworth
e841a2e999 Make ParsePubkey reutrn a *btcec.PublicKey
Provide a fucntion on public key to get the ecdsa type without knowing
internals.
2014-04-09 19:27:56 +01: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
David Hill
805ce37d31 Use the stack for most known sizes.
By using the stack for known sizes, there is less pressure on the
garbage collector.
2014-04-08 15:55:21 -04: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
384a535f49 addmultisigaddress support for btcctl 2014-04-07 14:45:42 -04:00
David Hill
b0242a8793 Add missing fields to ValidateAddressResult structure
ok @jrick
2014-04-07 14:07:38 -04:00
Dave Collins
f0581b565c Correct two more comments in block bytes breakdown. 2014-04-06 14:14:48 -05:00
Dave Collins
0e1f8fda6d Correct some comments in block bytes breakdown. 2014-04-05 21:00:28 -05:00
Dave Collins
4fce6d1476 Sync latest script tests to bitcoind test suite. 2014-04-03 23:18:52 -05:00