Commit graph

3531 commits

Author SHA1 Message Date
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
Dave Collins
5859deea7e Improve RPC authentication failure responses.
This commit improves how the legacy RPC server responds to authentication
failures so things like web browsers can react better.  The following
changes have been made:

First, authentication failures were only printing the 401 error response
in the body instead of setting the http status code.  This means the
response had a 200 OK header with a body of 401 Unauthorized.  Therefore
the client would think everything was ok, but see the response as
malformed JSON.

Second, the spec for 401 Unauthorized responses state they must include a
WWW-Authenticate header to instruct the client how to authenticate.
Without this, browsers won't prompt the user for credentials.
2014-01-23 11:27:48 -06:00
Josh Rickmar
413e028702 Add RecoverAddressesCmd. 2014-01-23 10:56:20 -05:00
Josh Rickmar
8f43dc758e Fix build. 2014-01-22 21:21:05 -05:00
Dave Collins
0d40bf901d Implement alternative auth for websockets.
The previous websocket code required HTTP auth headers to be sent in order
to use the websocket.  While this makes sense for most applications, some
use cases such as javascript-based websockets from browsers do no have the
ability to send headers.

This commit modifies the authentication logic to allow an alternative
authentication mechanism when HTTP auth headers can't be sent.  In
particular, it introduces a new JSON-RPC command named authenticate which
accepts the username and passphrase for the RPC server.  The command is
only required if the connetion has not already been authenticated via HTTP
auth headers and it must be the first command to be received.  Sending any
other command will immediately disconnect the websocket.

ok from @owainga and @jrick.

This closes #77.
2014-01-22 17:40:14 -06:00
Dave Collins
14dc8cee83 Add new authenticate command. 2014-01-22 14:12:08 -06:00
David Hill
ad65bee735 fix typo 2014-01-22 13:17:41 -05:00
Owain G. Ainsworth
9cb5190ac2 add support for the ping rpc command.
And the pingtime and pingwait fields of getpeerinfo.
2014-01-22 16:21:08 +00:00
Owain G. Ainsworth
1487a352da add basic support for the help rpc command. 2014-01-22 16:20:38 +00: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
Owain G. Ainsworth
7e1c44369c Adapt to btcjson api changes.
Add placeholder help text for all the json types that btcws adds. Jrick will
fill them in when he adds documentation.
2014-01-22 16:19:39 +00:00
Josh Rickmar
e745fffb83 Fix slice index for parameter. 2014-01-22 10:13:34 -05:00
Josh Rickmar
e321b6bdc7 Rename exportwatchingwallet zip option to download. 2014-01-22 10:08:09 -05:00
Josh Rickmar
8fb5c9f0e6 Return the actual id value, not func. 2014-01-21 15:10:12 -05:00
Josh Rickmar
f471d2b336 Add ExportWatchingWalletCmd. 2014-01-21 14:23:36 -05:00
Josh Rickmar
d3e4bcdcf5 Fix sendrawtransaction for websockets.
This fixes two issues: first, the sendrawtransaction handler had an
extra character in the key in the websocket handler map, preventing
the handler from never running.  Second, a nil pointer dereference was
removed from the handler.

This change fixes the minedtx notifications for btcwallet, since the
websocket-handler now runs instead of falling back to the legacy RPC
handler.
2014-01-20 18:27:27 -05:00
Dave Collins
d0d74b4e3e Add checkpoint at block height 279000. 2014-01-20 11:03:11 -06:00
Dave Collins
0a86df4a16 Correct test print found by go vet. 2014-01-19 21:41:52 -06:00
Dave Collins
f12ca20372 Enable memdb support.
This commit adds the btcdb memdb backend as a supported database type.
Note that users will NOT want to run in this mode because, being memory
only, it obviously does not persist the database when shutdown.

It is being added for testing purposes to help prevent constant abuse to
developer's hard drive when churning the block database multiple times a
day.
2014-01-19 20:44:06 -06:00
Dave Collins
e2dba2a074 Update for recent btcdb API changes. 2014-01-19 20:13:53 -06:00
Dave Collins
2aca924514 Allow the Open/CreateDB funcs to take any params.
The specific parameters required by a backend is better left up to the
backend itself.  For example memdb has no need for a database path, while
ldb does.  This commit modifies the OpenDB and CreateDB functions to take
a arbitrary arguments which are passed along to the driver.  The driver is
expected to verify the correct type and number of arguments and error
accordingly.

The existing backends have been updated accordingly.
2014-01-19 20:13:21 -06:00
Dave Collins
2eea55ae1d Prune the btcddb.Db interface.
This commit prunes several unused functions from the Db interface and the
underlying implementations.  For the most part these are holdovers from
the original sqlite implementation.  It also removes the types associated
with those functions since they are no longer needed.  The following
functions and types have been removed:

- InvalidateCache
- InvalidateBlockCache
- InvalidateTxCache
- SetDBInsertMode
  - InsertMode type and associated constants
- NewIterateBlocks
  - BlockIterator interface

The reasons for removing these are broken out below.

- Neither of two current implementations implement these functions nor
  does any of the fully functional code using the interface invoke them.
- After contemplating and testing caching of blocks and transactions at
  this layer, it doesn't seem to provide any real benefit unless very
  specific assumptions about the use case are made.  Making those
  assumptions can make other use cases worse.  For example, assuming a
  large cache is harmful to memory-constrained use cases.  Leaving it up
  to the caller to choose when to cache block and transactions allows much
  greater flexibility.
- The DB insert mode was an artifact of the original sqlite implementation
  and probably should have only been exposed specifically on the
  implementation as opposed through generic interface.  If a specific
  implementation wishes to provide functionality such as special modes,
  that should be done through type assertions.
2014-01-19 18:01:05 -06:00
Dave Collins
583406ee51 Use block headers to generate node index.
This commit changes the node index creation to use block headers instead
of full blocks.  This speeds up the initial node index generation since it
doesn't require loading a bunch of full blocks at startup.
2014-01-19 13:04:07 -06:00
Dave Collins
1626994433 Avoid copying block headers in convenience locals.
This commit modifies local variables that are used for more convenient
access to a block's header to use pointers.  This avoids copying the
header multiple times.
2014-01-19 12:42:45 -06:00
Dave Collins
be277b7230 Update for recent btcwire API changes. 2014-01-19 12:32:30 -06:00
Dave Collins
f309e899f3 Make use of the new btcdb functions.
This commit switches the handleGetHeadersMsg function to make use of the
new FetchBlockHeightBySha and FetchBlockHeaderBySha functions in btcdb.

Also, while here, nuke the header copy which is no longer required due to
the recent btcwire changes.
2014-01-19 03:05:02 -06:00
Dave Collins
8c34084e24 Add interface tests for new Fetch functions. 2014-01-19 02:55:07 -06:00
Dave Collins
d6c2492c7f Add FetchBlockHeightBySha/FetchBlockHeaderBySha.
This commit introduces two new functions to the btcdb.Db interface named
FetchBlockHeightBySha and FetchBlockHeaderBySha.

The FetchBlockHeightBySha function is useful since previously it was only
possible to get the height of block by fetching the entire block with
FetchBlockBySha and pulling the height out of the returned btcutil.Block.

The FetchBlockHeaderBySha function will ultimately make it much more
efficient to fetch block headers.  Currently, due to the database design
in the ldb backend, the entire block has to be loaded anyways, so the only
current benefit is to avoid the deserialize on all of the transactions.
However, ultimately btcdb will gain a more efficient backend which can
also avoid reading all of the extra transaction data altogether.
2014-01-19 02:54:47 -06:00
Dave Collins
845aedf103 Remove deprecated sqlite3.
The sqlite3 backend has been deprecated for quite some time.  As a result,
it has not been updated with many of the more recent changes which means
the behavior no longer conforms to the interface contract.
2014-01-19 02:36:54 -06:00
Dave Collins
27bc18ba2e Switch test coverage tool to new 'go tool cover'.
Also, make the coverage report test ldb and memdb instead of just sqlite3.
2014-01-19 02:35:41 -06:00
Dave Collins
6672f71d68 Add tests for new Serialize/Deserialize functions. 2014-01-18 21:43:11 -06:00
Dave Collins
06d1236d49 Add Serialize/Deserialize for BlockHeader.
This commit introduces two new functions for Blockheader named Serialize
and Deserialize.  The functions provide a stable mechanism for serializing
and deserializing block headers to and from disk.  The main benefit here
is deserialization of the header since typically only full blocks are
serialized to disk.  Then when a header is needed, only the header portion
of the block is read and deserialized.
2014-01-18 21:42:43 -06:00
Dave Collins
33bb455365 Update for recent btcwire API changes. 2014-01-18 21:15:09 -06:00
Dave Collins
0696c757fa Update ldb/dbtest to latest goleveldb API. 2014-01-18 21:06:10 -06:00