Commit graph

167 commits

Author SHA1 Message Date
Alex
e273e178dd Repoint repo to btcsuite on btcwalletln, and a few rebase fixes. 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
77b756c651 multi: point all imports towards roasbeef's forks 2018-05-23 19:38:56 -07:00
Josh Rickmar
f3df6c8bc9 Handle flags explicitly set to defaults.
This prevents treating a flag that was explicitly set to the default
as unchanged, since the explicit set is recorded in the new
*cfgutil.ExplicitString flag type.
2016-05-25 09:37:23 -04:00
Josh Rickmar
5140086f6e Use LICENSE file and short license headers. 2016-02-28 22:22:34 -05:00
Josh Rickmar
620a3c649e Add VersionService to gRPC server to query server versions.
Fixes #375.
2016-02-24 00:22:37 -05:00
Josh Rickmar
567752ea9b Add option for one time TLS keys.
This option prevents the RPC server TLS key from ever being written to
disk.  This is performed by generating a new certificate pair each
startup and writing (possibly overwriting) the certificate but not the
key.

Closes #359.
2016-02-11 00:15:30 -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
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
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
e5e239e124 API updates for times in block notifications. 2015-06-18 12:29:13 -04: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
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
Manan Patel
a883c96aa5 add SendPairs helper function to wallet package 2015-05-14 11:51:52 -07: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
Dave Collins
c820c8a015 Relicense to the btcsuite developers. 2015-05-01 12:20:05 -05:00
Dave Collins
0a13274d5b Update btcjson path import paths to new location. 2015-05-01 00:59:14 -05:00
Josh Rickmar
ec6034e2d9 Modify default account naming policy.
Rather than disallowing the default account to be renamed as was
proposed in #245 (and implemented in #246), the default account name
is no longer considered a reserved name by the address manager.
Instead, it is simply the initial name used for the first initial
account.

A database upgrade removes any additional aliases for the default
account in the database.  This prevents a lookup for some name which
is not an account name from mapping to the default account
unexpectedly (potentially preventing incorrect account usage from the
RPC server due to bad iteraction with default parameters).

All unset account names in a JSON-RPC request are expected to be set
nil by btcjson.  This behavior depends on btcsuite/btcd#399.

Additionally, the manager no longer considers the wildcard * to be a
reserved account name.  Due to poor API decisions, the RPC server
overloads the meaning of account fields to optionally allow referring
to all accounts at a time, or a single account.  This is not a address
manager responsibility, though, as a future cleaner API should not use
multiple differet meanings for the same field across multiple
requests.  Therefore, don't burden down future APIs with this quirk
and prevent incorrect wildcard usage from the RPC server.

Closes #245.
2015-05-01 01:30:20 -04:00
Josh Rickmar
43aef7db3c Convert RPC server to btcjson v2.
Closes #227.
2015-05-01 00:55:12 -04:00
Josh Rickmar
56039deb94 Integrate wtxmgr package. 2015-04-28 17:30:17 -04:00
Javed Khan
48a3b413b4 Move txstore package to legacy directory 2015-04-20 18:20:19 -04:00
Josh Rickmar
b74a6f78a6 Update for txscript.Script -> txscript.Engine. 2015-04-20 17:21:19 -04:00
Josh Rickmar
0d7b8af543 Updates for txscript.NewScript API change. 2015-04-20 16:52:26 -04:00
Javed Khan
84675ec9b8 Creating account requires unlocked manager - err 2015-04-13 21:12:07 +05:30
Manan Patel
dfe617e05d create wallet package
This a refactor of the btcwallet main package to create a new wallet
package.
The main feature of this package is the integration of all the other
wallet components (waddrmgr, txstore, and chain) and the Wallet type is
'runnable', so it will be continuously updating itself against changes
notified by the remote btcd instance.

It also includes several methods which provide access to information
necessary to run a wallet RPC server.
2015-04-02 11:17:45 -07:00
Javed Khan
68a9168d9e Updated waddrmgr to manage account names 2015-03-19 06:28:23 +05:30
Josh Rickmar
0a7b10d051 Rescan after btcd reconnect.
Otherwise, if the websocket connection to btcd is lost and
reestablished, there is no sync to the current best block, and btcd
will not notify wallet of new relevant transactions.
2015-03-02 16:04:26 -05:00
Josh Rickmar
5ad37374fb Use the correct synced block when calculating confs.
This was previously using the most recently notified (by the chain
package) block, but transaction processing from this block may not be
finished yet.  Using this block's height to calculate the number of
confirmations is therefore incorrect, and can result in every RPC
handler missing transactions or returning transactions from the wrong
block.
2015-03-02 13:30:42 -05:00
Josh Rickmar
c9d9b4b610 Implement several btcd RPCs in wallet as well.
Wallet should handle these so that wallet clients don't end up
creating requests to btcd about the latest processed block, which is
not the same as wallet's most recently processed block.

By providing wallet clients with this info, we avoid a race where the
client thinks wallet has processed N blocks, but in fact is still
synced to N-1 (and perhaps currently processing transactions from
block N).  This can cause unexpected results for many of the
bitcoind-compatible RPC APIs due to their reliance on number of
confirmations, rather than using absolute block heights.
2015-03-02 13:22:46 -05:00
Dave Collins
8f9f53a618 Switch to new waddrmgr package
This commit converts the wallet to use the new secure hierarchical
deterministic wallet address manager package as well as the walletdb
package.

The following is an overview of modified functionality:

- The wallet must now be created before starting the executable
- A new flag --create has been added to create the new wallet using wizard
  style question and answer prompts
- Starting the process without an existing wallet will instruct now
  display a message to run it with --create
- Providing the --create flag with an existing wallet will simply show an
  error and return

In addition the snacl package has been modified to return the memory after
performing scrypt operations to the OS.

Previously a runtime.GC was being invoked which forced it to release the
memory as far as the garbage collector is concerned, but the memory was
not released back to the OS immediatley.  This modification allows the
memory to be released immedately since it won't be needed again until the
next wallet unlock.
2015-03-02 11:55:42 -06:00
Dave Collins
130e44c761 Move keystore to legacy directory. 2015-03-02 12:21:44 -05:00
David Hill
f704c58114 Use txscript.StandardVerifyFlags
By using txscript.StandardVerifyFlags when creating and validating
transactions, we can ensure the transactions successfully created
won't be rejected due to script policy.
2015-02-26 18:41:59 -05:00
Josh Rickmar
d9e2443002 Fix build.
This fixes the build after btcsuite/btcd#302, which renamed the
txscript constant ScriptCanonicalSignatures constant to
ScriptVerifyDERSignatures.
2015-02-23 22:44:04 -05:00
Dave Collins
8b6c161cbc Update btcws path import paths to new location. 2015-02-19 13:09:16 -06:00
Dave Collins
58f7cedc0e Update btcjson path import paths to new location. 2015-02-19 12:01:41 -06:00
Dave Collins
b2ebd20d75 Update btcec path import paths to new location. 2015-02-06 11:06:45 -06:00
Dave Collins
23c9dc423e Update btcwire path import paths to new location. 2015-02-05 15:41:38 -06:00
Dave Collins
6d4889ffb0 Update btcscript import paths to new location. 2015-01-30 12:31:29 -06:00
Dave Collins
31149b88b9 Add prints when client and server TLS is disabled. 2015-01-23 16:11:13 -06:00
Dave Collins
f05ab25696 Update btcwallet import paths to new location. 2015-01-17 00:25:53 -06:00
Dave Collins
06ed33b65a Update btcjson import paths to new location. 2015-01-16 23:58:53 -06:00
Dave Collins
3fc3ecc908 Update btcws import paths to new location. 2015-01-16 23:40:19 -06:00
Dave Collins
7276c1ca7d Update btcscript import paths to new location. 2015-01-16 19:38:15 -06:00
Dave Collins
7db8ff3f9a Update btcec import paths to new location. 2015-01-16 18:08:45 -06:00
Dave Collins
283aa28be5 Update btcwire import paths to new location. 2015-01-16 16:03:04 -06:00