Commit graph

684 commits

Author SHA1 Message Date
John C. Vernaleo
aec660c749 Return WWW-Authenticate header
On invalide credentials return WWW-Authenticate the same way btcd does.

Pointed out by @davec in decred/dcrwallet#14
2016-02-01 09:10:22 -05:00
Josh Rickmar
515cbc69ce Always lock waddrmgr for every timeout or explicit request.
Use waddrmgr.IsError to avoid logging errors when trying to lock an
already locked wallet.

Fixes #349.
2016-01-31 22:38:59 -05:00
Olaoluwa Osuntokun
4c839ae3d3 Generate a seed when creating a new wallet if none was provided.
Previously, if a nil seed was passed into loader.CreateNewWallet, a
random seed was never generated. This would cause an error within the
waddrmgr due to the seed being of invalid (0) length.
2016-01-31 13:37:57 -08:00
Josh Rickmar
bb1102b414 Fix fee calculation for gettransaction. 2016-01-29 12:58:05 -05:00
Josh Rickmar
497ffc11f0 Modernize the RPC server.
This is a rather monolithic commit that moves the old RPC server to
its own package (rpc/legacyrpc), introduces a new RPC server using
gRPC (rpc/rpcserver), and provides the ability to defer wallet loading
until request at a later time by an RPC (--noinitialload).

The legacy RPC server remains the default for now while the new gRPC
server is not enabled by default.  Enabling the new server requires
setting a listen address (--experimenalrpclisten).  This experimental
flag is used to effectively feature gate the server until it is ready
to use as a default.  Both RPC servers can be run at the same time,
but require binding to different listen addresses.

In theory, with the legacy RPC server now living in its own package it
should become much easier to unit test the handlers.  This will be
useful for any future changes to the package, as compatibility with
Core's wallet is still desired.

Type safety has also been improved in the legacy RPC server.  Multiple
handler types are now used for methods that do and do not require the
RPC client as a dependency.  This can statically help prevent nil
pointer dereferences, and was very useful for catching bugs during
refactoring.

To synchronize the wallet loading process between the main package
(the default) and through the gRPC WalletLoader service (with the
--noinitialload option), as well as increasing the loose coupling of
packages, a new wallet.Loader type has been added.  All creating and
loading of existing wallets is done through a single Loader instance,
and callbacks can be attached to the instance to run after the wallet
has been opened.  This is how the legacy RPC server is associated with
a loaded wallet, even after the wallet is loaded by a gRPC method in a
completely unrelated package.

Documentation for the new RPC server has been added to the
rpc/documentation directory.  The documentation includes a
specification for the new RPC API, addresses how to make changes to
the server implementation, and provides short example clients in
several different languages.

Some of the new RPC methods are not implementated exactly as described
by the specification.  These are considered bugs with the
implementation, not the spec.  Known bugs are commented as such.
2016-01-29 11:18:26 -05:00
Josh Rickmar
6af96bfdb7 Correctly handle RPC listen addresses with IPv6 zones.
Fixes #341.
2016-01-14 13:33:08 -05:00
Mawuli Adzoe
c4abe025d0 Fix minor typos. 2015-12-30 15:24:31 -07:00
Josh Rickmar
b701fadd7b Update travis config for recent Go versions. 2015-12-08 11:40:20 -05:00
Josh Rickmar
647e7fdd22 Update README.
Removed links to outdated btcsuite MSIs, replacing these with links to
Github releases.

Combined installation and updating instructions since they are
identical.

Added Windows to the list of operating systems that the "Build from
source" instructions work with.

Added PowerShell examples for copying the sample btcd and btcwallet
configs for both MSI and source installs.
2015-11-25 12:27:34 -05:00
Josh Rickmar
b0566e09c8 Separate out default ports and utility funcs.
This change moves the chain and network parameter definitions, along
with the default client and server ports, to a package for reuse by
other utilities (most notably, tools in the cmd dir).  Along with it,
functions commonly used for config parsing and validation are moved to
an internal package since they will also be useful for distributed
tools.
2015-11-25 01:02:50 -05:00
Josh Rickmar
5482feecf4 Prepare for release 0.7.0. 2015-11-23 10:44:37 -05:00
Josh Rickmar
8999c13f4d Add 0.7.0 deps to deps.txt. 2015-11-23 10:44:36 -05:00
Rune T. Aune
52b8e1903f Add the chain subsystem logger to btcrpcclient.
Logging from btcrpcclient is currently not possible to set, and defaults
to nothing. Letting it inherit chain's logger can greatly simplify
debugging of connectivity issues.

Also remove a now redundant log message upon connecting to btcd.
2015-11-19 17:15:20 -06:00
Dave Collins
6ba74e6730 Update for hdkeychain NewMaster API change. 2015-11-10 12:05:16 -06:00
Josh Rickmar
4f6edce6dc Fix signmessage RPC to match Core.
AFAICT this function has never worked correctly due to the hash being
signed not matching the hash created by Core.  Core wallet writes
serialized strings to a double-sha256 hashing stream, while we were
using string concatination.  This produced different messages since
the message before hashing did not include compact integers (called
varints in btcsuite code) preceding each string with the string
length.

Tested by creating signed messages from btcwallet and verifying them
with Bitcoin-Qt, as well as creating signatures from Bitcoin-Qt and
verifying them with btcwallet.

Fixes #323.
2015-10-16 14:13:59 -04:00
John C. Vernaleo
cef002139f Fix wallet compile after SigCache addition to NewEngine. 2015-10-12 13:09:40 -04:00
Josh Rickmar
31d152608b Temporarly increase session RPC timeout. 2015-09-23 12:24:24 -04:00
Josh Rickmar
33d053c6a7 Detect silent network drops.
This change introduces additional network activity with the btcd
process to ensure that the network connection is not silently dropped.
Previously, if the connection was lost (e.g. wallet runs on a laptop
and connects to remote btcd, and the laptop is suspended/resumed) the
lost connection would not be detectable since all normal RPC activity
(excluding requests from btcwallet to btcd made by the user) is in the
direction of btcd to wallet in the form of websocket notifications.
2015-09-22 14:54:40 -04:00
cjepson
6ee1f9b7ee Fix retrieval of public key addresses from address manager
The behaviour of function Address() in waddrmgr has been updated such that
it now displays the correct behaviour as described in the comments. That is,
when a public key address is given as a btcutil.Address, the key is converted
to a public key hash address so that serializing with ScriptAddress() yields
the corresponding public key hash. This allows the address manager to find
the corresponding private key, and fixes the signing of multisignature
transactions.
2015-07-22 15:48:24 -04:00
Josh Rickmar
c31dc63760 Remove unnecessary address manager locks.
In particular, this allows the use of AccountName in the passed
function when iterating over all account numbers.
2015-07-21 13:59:46 -04:00
Josh Rickmar
eb25d889a0 Add spendable field to listunspent result.
Fixes #262.
2015-07-21 13:46:24 -04:00
Josh Rickmar
a2a132129e Add AppVeyor continuous integration. 2015-06-30 22:54:36 -04:00
Josh Rickmar
f7ed140a9b Reorder wtxmgr.CreditRecord fields.
This reverses the order of index and amount fields to match
DebitRecord and also saves 8 bytes per instance on amd64.
2015-06-19 01:43:15 -04:00
Josh Rickmar
e5e239e124 API updates for times in block notifications. 2015-06-18 12:29:13 -04:00
Alex Yocom-Piatt
a735e3c3e2 Add mutex for delete(m.addrs, ..) in MarkUsed 2015-06-15 12:01:18 -05:00
Josh Rickmar
411eacbeea Remove data races from switching lock impls.
sync.Locker cannot be safely used to switch a sync.Mutex to a noop
locker since other goroutines that attempt to lock the mutex will race
on the changing interface.  Instead, just statically dispatch
sync.Mutex methods.
2015-06-12 11:40:04 -04:00
Josh Rickmar
9d5abaf14e Simplify error handling with waddrmgr.IsError. 2015-05-27 18:21:17 -04:00
Josh Rickmar
39cab6087a Add waddrmgr.IsError function. 2015-05-27 17:32:33 -04:00
Josh Rickmar
9ee887823d Take advantage of Go 1.5 optimized zeroing.
Closes #286.
2015-05-27 15:32:32 -04:00
Josh Rickmar
8caef99ee4 Fix whitespace. 2015-05-27 13:45:45 -04:00
Josh Rickmar
164368d02e Prepare for release 0.6.0. 2015-05-27 11:45:21 -04:00
Josh Rickmar
5843c0bc66 Move legacy under internal directory.
After Go 1.5, this will prevent consumers from importing these
packages since they are currently unmaintained.

Closes #232.
2015-05-27 10:12:24 -04:00
Josh Rickmar
b7cef610c0 Fix JSON-RPC error code for walletpassphrase failures. 2015-05-26 11:39:22 -04:00
Javed Khan
fbf744bc5e Update wallet to use ForEach- style functions 2015-05-21 23:35:13 +05:30
Guilherme Salgado
fe0f60991a Stop mocking global func() variables
Doing that may cause erratic test failures when we run them in parallel, so
move the functions the tests need to mock as struct fields that are not
shared across tests.
2015-05-14 21:49:09 +02:00
Guilherme Salgado
97e84fe212 Turn isTxTooBig into a method on withdrawalTx
Also get rid of the replaceIsTxTooBig test helper by making tests use
replaceCalculateTxSize instead
2015-05-14 21:48:01 +02:00
Manan Patel
a883c96aa5 add SendPairs helper function to wallet package 2015-05-14 11:51:52 -07:00
Josh Rickmar
d714bf3310 Refactor wallet opening.
Rather than the main package being responsible for opening the address
and transaction managers, the namespaces of these components are
passed as parameters to the wallet.Open function.

Additionally, the address manager Options struct has been split into
two: ScryptOptions which holds the scrypt parameters needed during
passphrase key derivation, and OpenCallbacks which is only passed to
the Open function to allow the caller to provide additional details
during upgrades.

These changes are being done in preparation for a notification server
in the wallet package, with callbacks passed to the Open and Create
functions in waddrmgr and wtxmgr.  Before this could happen, the
wallet package had to be responsible for actually opening the managers
from their namespaces.
2015-05-14 14:33:33 -04:00
Josh Rickmar
edde89cd4c Rollback transactions past the last saved recent block.
If a long reorganize occurs farther back than the last saved recent
block hash (currently max 20 are saved) a full rescan is triggered
since there is no guarantee the previous blocks weren't also removed
in the reorg.  In this case, the address manager was set unsynced, but
transaction history was not rolled back as well.  This commit corrects
this by unconfirming all transactions but those in the genesis block.
2015-05-14 14:32:15 -04:00
Guilherme Salgado
47ca1ca6e5 StartWithdrawal returns a previously saved WithdrawalStatus if parameters match
StartWithdrawal now persists the WithdrawalStatus before returning, and also
returns a previously saved one in subsequent calls with the same parameters.
2015-05-14 13:14:01 -05:00
Josh Rickmar
472d6b0c1e Prevent duplicate waddrmgr lock error.
Fixes #270.
2015-05-14 10:42:01 -04:00
Guilherme Salgado
49210dcf97 Change the stack semantics in withdrawal.eligibleInputs 2015-05-14 09:27:19 -05:00
Josh Rickmar
4637d62baf Use 0 instead of -1 for zero-conf listtransactions results.
Fixes #278.
2015-05-13 20:06:44 -04:00
Josh Rickmar
736a46ff81 Use negative fees with listtransaction result types.
This matches Bitcoin Core Wallet.

Fixes #272.
2015-05-13 13:18:06 -04:00
Josh Rickmar
41b7d4c5ee Remove target conf limit on listsinceblock txs.
All transactions since the specified block (or the genesis block if
left unspecified) should be included in the result array

Along with this fix, update the help descriptions to mention that the
target confirmations parameter is not considered when including
transactions in the result object.  That is, transactions with a
height greater than the height of the lastblock in the result object
are still included.

Fixes #263.
2015-05-13 11:46:31 -04:00
David Hill
9d7fb99b8b Add script verification errors to signrawtransaction result.
This mimics Bitcoin Core commit 8ac2a4e1788426329b842eea7121b8eac7875c76
2015-05-08 10:09:35 -04:00
Josh Rickmar
49f33eec0f Updates for btcjson type changes.
To increase compatibility with Bitcoin Core Wallet, additional fields
were added to and other fields made optional for the listtransactions
and gettransaction results structs.  For both, fee was changed to be
optional (including the zero value is allowed).
2015-05-06 13:18:13 -04:00
Josh Rickmar
8ce25ce518 Do not remove txs from extra block on reorgs. 2015-05-04 09:28:19 -04:00
Dave Collins
c820c8a015 Relicense to the btcsuite developers. 2015-05-01 12:20:05 -05:00
Josh Rickmar
0ae57f2564 Fix waddrmgr version 4 upgrade path.
If the account number to name index mapped the default account name to
an alias, the upgrade would not succeed and the upgrade would be
aborted (and rolled back).

This became a problem for upgrading old (pre-v3) wallets since the v3
upgrade did not rename the previous "" account to "default", but
instead just created an alias.

Fix tested by @dajohi, who ran into this issue with a wallet upgrade
from an older keystore version.
2015-05-01 12:24:22 -04:00