Commit graph

2167 commits

Author SHA1 Message Date
Dave Collins
2a7d725a09 Move websocket endpoint to /ws.
This commit moves the connection endpoint for websockets to /ws instead of
/wallet. First, the former is more standard, and second the latter
presumes how the websocket is to be used.

Closes #80.
2014-02-03 10:46:03 -06:00
Dave Collins
5ec951f6a7 Rework and improve headers-first mode.
This commit improves how the headers-first mode works in several ways.

The previous headers-first code was an initial implementation that did not
have all of the bells and whistles and a few less than ideal
characteristics.  This commit improves the heaers-first code to resolve
the issues discussed next.

- The previous code only used headers-first mode when starting out from
  block height 0 rather than allowing it to work starting at any height
  before the final checkpoint.  This means if you stopped the chain
  download at any point before the final checkpoint and restarted, it
  would not resume and you therefore would not have the benefit of the
  faster processing offered by headers-first mode.
- Previously all headers (even those after the final checkpoint) were
  downloaded and only the final checkpoint was verified.  This resulted in
  the following issues:
  - As the block chain grew, increasingly larger numbers of headers were
    downloaded and kept in memory
  - If the node the node serving up the headers was serving an invalid
    chain, it wouldn't be detected until downloading a large number of
    headers
  - When an invalid checkpoint was detected, no action was taken to
    recover which meant the chain download would essentially be stalled
- The headers were kept in memory even though they didn't need to be as
  merely keeping track of the hashes and heights is enough to provde they
  properly link together and checkpoints match
- There was no logging when headers were being downloaded so it could
  appear like nothing was happening
- Duplicate requests for the same headers weren't being filtered which
  meant is was possible to inadvertently download the same headers twice
  only to throw them away.

This commit resolves these issues with the following changes:

- The current height is now examined at startup and prior each sync peer
  selection to allow it to resume headers-first mode starting from the
  known height to the next checkpoint
- All checkpoints are now verified and the headers are only downloaded
  from the current known block height up to the next checkpoint.  This has
  several desirable properties:
  - The amount of memory required is bounded by the maximum distance
    between to checkpoints rather than the entire length of the chain
  - A node serving up an invalid chain is detected very quickly and with
    little work
  - When an invalid checkpoint is detected, the headers are simply
    discarded and the peer is disconnected for serving an invalid chain
  - When the sync peer disconnets, all current headers are thrown away
    and, due to the new aforementioned resume code, when a new sync peer
    is selected, headers-first mode will continue from the last known good
    block
- In addition to reduced memory usage from only keeping information about
  headers between two checkpoints, the only information now kept in memory
  about the headers is the hash and height rather than the entire header
- There is now logging information about what is happening with headers
- Duplicate header requests are now filtered
2014-02-01 16:33:00 -06:00
Dave Collins
be2e4c5860 Add new function to get the checkpoints.
Previously there was only a function to get the latest checkpoint.  This
commit exposes a new function named Checkpoints which returns a slice of
checkpoints ordered by height for the active network or nil when
checkpoints are disabled.
2014-01-31 19:52:20 -06:00
Dave Collins
c6d865f3b5 Cleanup and slightly optimize the progress logging.
Previously the logging function which reports on progress was called for
every block, regardless of whether it was an orphan or not.  This could be
confusing since it could show a different number of blocks processed as
compared to the old versus new heights reported (orphans do not add to the
block height since they aren't extending the main chain).  Further, the
database had to be consulted for the latest block since the block we just
processed might not be the latest one if it was an orphan.  This is quite
a bit more time conusming than it should've been for progress reporting.

This commit modifies that to only include non-orphan blocks.  As a result,
the latest height shown will match the number of blocks processed (even
when there are orphans) and the additional block lookup from the database
is avoided.
2014-01-30 12:40:37 -06:00
David Hill
79ff9b76ee add verifymessage to btcctl 2014-01-30 13:26:15 -05:00
David Hill
bd0c799e2f add validateaddress to btcctl 2014-01-30 13:14:28 -05:00
David Hill
9c2abd1fa1 add listreceivedbyaccount and listreceivedbyaddress to btcctl 2014-01-30 13:10:43 -05:00
David Hill
1a64f33fca add listunspent to btcctl 2014-01-30 12:59:26 -05:00
David Hill
ed4ffc44a1 add listlockunspent to btcctl 2014-01-30 12:31:56 -05:00
David Hill
0951ffa1c7 add listaddressgroupings to btcctl 2014-01-30 12:29:21 -05:00
David Hill
ea689489d3 add gettxoutsetinfo to btcctl 2014-01-30 12:23:38 -05:00
David Hill
46709bda08 add getrawchangeaddress to btcctl 2014-01-30 12:19:04 -05:00
David Hill
8749cde081 add getreceivedbyaccount and getreceivedbyaddress to btcctl 2014-01-30 12:08:50 -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
2b9f5b8932 in getrawmempool verbose mode, initialize depends to an empty array.
this matches bitcoind.

from jrick
ok davec
2014-01-29 22:22:07 -05:00
David Hill
b532860477 sync with btcjson changes to getrawtransaction.
ok oga@
2014-01-29 21:21:58 -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
Owain G. Ainsworth
82fca37eae implement the getinfo rpc command.
This contains some wallet inforamtion, but bitcoind if wallet is
disabled returns just the non wallet information. we do the same.
2014-01-29 18:31:33 +00:00
Owain G. Ainsworth
042d9206a1 change some more code over to using newer btcdb apis. 2014-01-29 18:31:33 +00:00
Owain G. Ainsworth
8d930ceed1 convert getdifficulty to getBlockHeaderBySha to save some cycles. 2014-01-29 18:31:33 +00:00
Dave Collins
970c0cdb30 Misc cleanup.
This commit contains various code cleanup such as comment fixes and
function ordering consistency.
2014-01-28 18:57:07 -06:00
Dave Collins
6a9997583a Prune the block node index in fast add mode too.
The recent addition of the fast add path to support headers first was not
running the block node index pruning code which removes unneeded block
nodes from memory.  This resulted in higher memory usage than needed in
fast add mode.
2014-01-28 13:46:55 -06:00
Dave Collins
7390a62a8d Correct internal node children on reorg.
Previously the code was only adding a new block node as a child in the
inernal node index for the cases it extended the main chain or a side
chain and not for a node which caused a reorg.  This resulted in the block
node pruning code not clearing the parent link of reorged nodes which
ultimately led to a sanity check error accordingly.

This commit resolves the issue by ensuring new block nodes are added as
children of their respective parents in all cases.

Closes #4.
2014-01-28 13:44:39 -06:00
David Hill
112525bd7a cleanup sendfrom and sendmany 2014-01-27 21:31:33 -05:00
David Hill
6c9a206709 add keypoolrefill to btcctl 2014-01-27 21:11:59 -05:00
David Hill
34849a181c add listaccounts to btcctl 2014-01-27 21:05:27 -05:00
Owain G. Ainsworth
5cef5bc05c add support for listsinceblock to btcctl 2014-01-27 23:22:09 +00:00
David Hill
2697a0a9ea add settxfee to btcctl 2014-01-27 16:31:48 -05:00
David Hill
c0d6180685 add sendmany to btcctl 2014-01-27 15:57:44 -05:00
David Hill
b354015426 add sendfrom to btcctl 2014-01-27 15:19:39 -05:00
Dave Collins
72afc787e6 Move getinfo RPC method to askwallet list.
The getinfo RPC method requires access to information only available in
the wallet.  Therefore, it has been moved to the list of methods which
return an error information the caller to send the request to the wallet
instead.
2014-01-27 13:52:59 -06:00
David Hill
a5e5903caf add walletlock to btcctl 2014-01-27 13:44:31 -05:00
Josh Rickmar
36e5aa8e92 Add walletpassphrasechange support to btcctl. 2014-01-27 13:39:01 -05:00
David Hill
ffe767c679 add getaddressesbyaccount to btcctl 2014-01-27 13:32:36 -05:00
David Hill
82552e4465 add walletpassphrase to btcctl 2014-01-27 12:49:54 -05:00
David Hill
221352586b add getnewaddress to btcctl 2014-01-27 12:35:20 -05:00
Dave Collins
b9a641ab79 Move getnewaddress RPC method to askwallet list.
The getnewaddress RPC method deals with wallet-related functionality and
therefore has been moved to the list of methods which return an error
information the caller to send the request to the wallet instead.
2014-01-27 10:58:24 -06:00
Dave Collins
0bf4e0e097 Move getblocktemplate/getwork to askwallet list.
Both of these RPC methods require access to information ony available in
the wallet.  Therefore they have been moved to the list of methods which
return an error information the caller to send the request to the wallet
instead.
2014-01-25 22:58:38 -06:00
Dave Collins
d58af1c3cf Make peer state iterator funcs receivers.
Rather than having the iterator functions a separate entities that access
the state to iterate, just expose the iterators as receivers on the state
itself.  This is more consistent with the style used throughout the code
and the other receivers on the state such as Count, OutboundCount, etc.
2014-01-25 22:51:28 -06:00
Dave Collins
fea4109eb2 Add getaddednodeinfo support to btcctl. 2014-01-25 22:50:34 -06:00
Dave Collins
dcef4128b8 Add support for getaddednodeinfo RPC command.
This commit adds full support for the getaddednodeinfo RPC command
including DNS lookups which abide by proxy/onion/tor rules when the DNS
flag is specified.  Note that it returns an array of strings when the DNS
flag is not set which is different than the current version of bitcoind
which is bugged and scheduled to be fixed per issue 3581 on the bitcoind
issue tracker.
2014-01-25 22:50:32 -06: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
Josh Rickmar
50a1c37317 Remove parameters for createencryptedwallet.
The createencryptedwallet extension RPC request should not be used to
create wallets for additional accounts.  Instead, all btcwallet
accounts should use the same passphrase as the default account's
wallet.  This change removes the account name and description
parameters from createencryptedwallet, as it will only be used to
create the default account.
2014-01-24 11:16:59 -05:00
Josh Rickmar
0f7f080f19 Move help texts into their own const group. 2014-01-24 10:55:36 -05:00
David Hill
4a93564b04 Add getwork result infrastructure. Make the work request optional. 2014-01-23 17:30:44 -05:00
David Hill
5736dc05ae add getwork support to btcctl 2014-01-23 15:57:15 -05:00
David Hill
908945ed53 fix getwork API
closes #12
2014-01-23 15:55:52 -05:00
David Hill
109ca258af sort commands and fix typos 2014-01-23 14:21:41 -05:00
David Hill
136aa95446 add getblocktemplate support to btcctl. 2014-01-23 13:44:28 -05:00