Commit graph

3479 commits

Author SHA1 Message Date
Owain G. Ainsworth
fedafbdd49 go fmt 2013-10-25 18:23:53 +01:00
Owain G. Ainsworth
b3b8b37855 test and fix bugs in getaddednodeinfo 2013-10-25 18:23:28 +01:00
Owain G. Ainsworth
77316a003a fix method for getaccountaddress.
and test dumpprivkey, dumpwallet, encryptwallet, getaccount and
getaccountaddress
2013-10-25 17:47:11 +01:00
Owain G. Ainsworth
bac5600145 basic functionality test for decoderawtransactioncmd 2013-10-25 17:22:07 +01:00
Owain G. Ainsworth
6227c446d3 Add a framewowrk for parsing and creating json commands.
Initial prototype for one command mostly from jrick, with discussion
with me and jcv.  Other commands mocked up in a couple of long boring days by
yours truly.

Code isn't fully tested yet so may well still be buggy in the type conversions.
Test will be added over the next few days to get this up to snuff.
2013-10-25 17:10:39 +01:00
Dave Collins
89d86d07ac ValidateTransactionScripts now accepts script flags.
This commit modifies the ValidateTransactionScripts API to accept the
recently added ScriptFlags from btcscript.  This provides flexibility to
the caller to choose validation behavior based on those new flags.
2013-10-25 10:49:06 -05:00
Dave Collins
bd297491b9 Make var length string overflow tests consistent.
This commit modifies the variable length string overflow tests slight to
make them consistent with the other overflow tests.
2013-10-25 09:55:27 -05:00
Dave Collins
a4c5c620c6 Finish a TODO in the message headers tests. 2013-10-25 09:00:05 -05:00
Dave Collins
d1edbf1f0b Add tests to exercise intential malicious overflow.
This commit adds several tests which intentionally attempt to feed
malicious data to the various deserialize functions.
2013-10-25 08:57:39 -05:00
Dave Collins
5cc32bbfc7 Add bounds checking to all variable length allocs.
Several of the bitcoin data structures contain variable length entries,
many of which have well-defined maximum limits.  However, there are still
a few cases, such as variable length strings and number of transactions
which don't have clearly defined maximum limits.  Instead they are only
limited by the maximum size of a message.

In order to efficiently decode messages, space is pre-allocated for the
slices which hold these variable length pieces as to avoid needing to
dynamically grow the backing arrays.  Due to this however, it was
previously possible to claim extremely high slice lengths which exceed
available memory (or maximum allowed slice lengths).

This commit imposes limits to all of these cases based on calculating
the maximum possible number of elements that could fit into a message
and using those as sane upper limits.

The variable length string case was found (and tests added to hit it) by
drahn@ which prompted an audit to find all cases.
2013-10-25 08:55:39 -05:00
Dale Rahn
70aa92bf0d Test some boundary conditions that exercise 'flaws' in the current
btcwire protocol.
2013-10-24 14:39:40 -04:00
Josh Rickmar
618b885e9e Notify wallets of mined transactions.
This change allows btcwallet to keep a pool of transactions that have
not yet been mined into a block, notifying wallet when transactions
are mined, as well as introducing a new way to send the
btcd:blockconnected notification with wallet-specific information as
part of the same notification.  When a transaction is sent using the
RPC call 'sendrawtransaction', a notification request will be
automatically registered with the connected wallet (if using
websockets) to notify the wallet when the transaction first appears in
a block.

To perform this notification, and to avoid requiring wallets from
waiting for seperate mined tx notifications (and resend after a
timeout) or from sending an additional tx mined request for every tx
in the pool after each new block, the blockconnected notification is
now created seperately for each wallet.  If the notified wallet has
sent a transaction, an additional JSON field "minedtxs" will include
an array of transaction IDs that the wallet has created and which are
included in the new block.

This new unique blockconnected notification can also be used for
additional notifications that may happen each new block in the future,
and to cut down on existing notification handlers in btcwallet, such
as for transactions to a watched address.
2013-10-23 18:13:03 -04:00
Dave Collins
2bb8c5d5cc Bring back default redirect for profiling.
Now that the RPC server uses its own mux, bring back the code which does
the automatic 303 redirect for the root of the profile server.
2013-10-23 10:48:17 -05:00
Dave Collins
5a4772bdc6 Change the RPC server to use it's own Muxer.
Rather than relying on the http package's DefaultServeMux for the RPC
server, create a unique mux specifically for the RPC server.  This ensures
things, such as the http profiling handlers, do not commingle.
2013-10-23 10:45:43 -05:00
Dave Collins
8970d4bf99 Revert "Add default redirect for profiling when enabled."
This reverts commit cc6cfdad9e.
2013-10-23 10:25:09 -05:00
Dave Collins
cc6cfdad9e Add default redirect for profiling when enabled.
This commit adds a simple 303 redirect for the root of profile server so
launching it without a path automatically goes to the debug profiling
page.
2013-10-23 09:39:02 -05:00
Dave Collins
7846b2f4e2 Update README.md TODO to remove 32-bit MSI.
32-bit MSIs will now be available for all future releases.
2013-10-22 17:05:43 -05:00
Dave Collins
1e93cdad6e Add 0.3.2 deps to deps.txt. 2013-10-22 16:45:19 -05:00
Dave Collins
3b025b2352 Prepare for release 0.3.2. 2013-10-22 16:40:51 -05:00
Dave Collins
998682ec83 Remove sqlitedb from the common tests.
The sqlite db backend is now deprecated.
2013-10-22 15:28:32 -05:00
Dave Collins
5eee027f92 Correct leveldb package documenation.
The leveldb package documentation still referred to sqlite from
original copy/paste.
2013-10-22 15:26:44 -05:00
Dave Collins
8f75a09479 Remove sqlite as an available db type. 2013-10-22 15:01:51 -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
1420eccf73 Use rpc errors defined in btcjson. 2013-10-22 12:28:00 -04:00
John C. Vernaleo
9ddb768c47 Define errors.
Define errors (previously done in btcwallet and btcd's rpcserver) in
one place so they can just be called by name rather than generated in
code using btcjson.

Closes #5
2013-10-22 12:25:54 -04:00
Dave Collins
9ded3fa2cf Generate usage from handler data in btcctl.
Rather than having to keep the usage in sync with the supported commands,
simply include the usage as a field in the command handlers map and
dynamically generate the usage from there.
2013-10-22 10:56:56 -05:00
Dave Collins
d4f980c71f Show usage on no params to btcctl. 2013-10-22 10:15:46 -05:00
Dave Collins
c55152ef7e Always return non-zero code from btcctl on error. 2013-10-22 10:01:13 -05:00
John C. Vernaleo
850870f14b Fix some doc typos (from oga@) 2013-10-22 09:18:55 -04:00
Dave Collins
629168b7ae Perform display handler check before issues RPC.
This commit modifies the command handler in btcctl to check the existence
of a display handler before issues an RPC command.  This prevents a round
trip to the server if there is no display handler.

Also, fix a couple of comments while here.
2013-10-22 00:40:17 -05:00
Dave Collins
4e5cd1a326 Allow nil conversion handlers in btcctl. 2013-10-21 23:03:11 -05:00
Dave Collins
2ea4239f5e Improve btcctl.
This commit significantly reworks btcctl to use a map based approach to
command handling.  This reduces the number of lines of code needed,
simplifies adding new commands, improves the error handling, and removes
several cases where unexpected data was not handled properly (it could
panic).

This commit also adds the ability to specify the optional parameter on
getrawtransaction.

Discussed with dhill@.
2013-10-21 22:58:47 -05:00
Dave Collins
102fc5f513 Rework the mempool locking code.
It was previously possible for the unprotected iteration of the mempool
orphans to lead to undefined results.  This commit remedies that by
reworking the locking code a bit.  It also embeds the mutex directly into
the mempool struct rather than having a separate field for it so the
syntax is a slightly cleaner.
2013-10-21 18:22:59 -05:00
David Hill
27abb0eb3e add "addnode" to btcctl 2013-10-21 14:09:05 -04:00
David Hill
e1a02d71b3 add getpeerinfo to btcctl 2013-10-21 13:26:40 -04:00
John C. Vernaleo
440f336d34 Correct addnode's required argument type. 2013-10-21 13:22:52 -04:00
David Hill
a975b60a0a add getconnectioncount skeleton to rpc 2013-10-21 13:00:13 -04:00
David Hill
3130659cdf add getconnectioncount to btcctl 2013-10-21 12:59:07 -04:00
Josh Rickmar
5bfc9c7eed Remove possible nil pointer dereferences.
Results from FetchTxByShaList must each be checked for a nil Err and a
non-nil Tx.  Fix this issue in two places where these conditions were
not being checked.
2013-10-20 13:02:34 -04:00
Dave Collins
d44d253dff Make quit channel with RPC server.
The latest websockets code added a quit channel to the RPC server, but did
not initialize it.  This commit corrects that so shutdown works properly
again.
2013-10-20 11:06:36 -05:00
David Hill
0abfdcc88b fix reversed variables in a warning message. 2013-10-17 16:58:57 -04:00
Dave Collins
e5620d6387 Correct reply for getrawmempool RPC command.
The RPC command needs to return a slice of hash strings, not the
underlying *btcwire.ShaHash bytes.
2013-10-17 12:11:04 -05:00
David Hill
ff20c420a2 add decoderawtransaction, getbestblockhash, getdifficulty, and
getrawmempool to btcctl.
2013-10-17 12:35:27 -04:00
David Hill
4c50ff541f fix getbestblockhash 2013-10-17 12:33:46 -04:00
David Hill
ffed6599ce add getrawmempool to rpcserver 2013-10-17 12:23:53 -04:00
Owain G. Ainsworth
40c75b27ac Add CalcScriptInfo entrypoint to return info about scriptpairs.
Specficially the class of the pkScript, the  expected numbers of
arguments and the number of sigops.
2013-10-17 17:07:39 +01:00
Owain G. Ainsworth
5a9cc91e62 Add an idle timer for peers.
If we don't hear from a peer for 5 minutes, we disconnect them. To keep
traffic flowing we send a ping every 2 minutes if we have not send any
other message that should get a reply.
2013-10-17 17:06:47 +01:00
Owain G. Ainsworth
bc89dedf9a Remove prevGetBlocksMutex.
This is only ever accessed from one place (blockmanager) which is single
threaded.
2013-10-17 17:06:47 +01:00
Owain G. Ainsworth
a41c874837 Remove stale comment. 2013-10-17 17:06:47 +01:00
Owain G. Ainsworth
2231456c23 Make it possible to get a notification when a message has been sent.
If a channel is passed in then true will be sent on the provided channel
after the message has successfully sent.
2013-10-17 17:06:41 +01:00