Commit graph

26 commits

Author SHA1 Message Date
Oliver Gugger 3a5d9f84b0
multi: fix linter issues 2021-03-24 14:44:32 +01:00
Olaoluwa Osuntokun b0b64d3bbd multi: update due to latest API changes 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun a0abd3632c multi: update to new upstream btcsuite/btcd API's 2018-05-23 19:38:56 -07:00
Alex e8b5091725 log: update to new logging API 2018-05-23 19:38:56 -07:00
Alex 3d81f856fd Move spvchain into neutrino and start integration w/btcwallet 2018-05-23 19:38:56 -07:00
Alex 32adc3c43f Make rescan a struct, add spending tx to GetUtxo, start integration. 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 8e723ea454 Update deps to pull in latest gRPC release.
While here, pull in latest btcsuite and logrotate changes.  Update for
logrotate API changes.
2017-07-19 11:39:25 -04:00
Josh Rickmar 4222c0464a Update project dependencies.
One change of note is that this pulls in the new btclog-based logger
and removes the seelog dependency.
2017-06-20 09:34:45 -04:00
Josh Rickmar 5140086f6e Use LICENSE file and short license headers. 2016-02-28 22:22:34 -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
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 c820c8a015 Relicense to the btcsuite developers. 2015-05-01 12:20:05 -05: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
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
Dave Collins f05ab25696 Update btcwallet import paths to new location. 2015-01-17 00:25:53 -06:00
Dave Collins 2f79c3176e Update btclog import paths to new location. 2015-01-16 11:43:34 -06:00
Dave Collins 4f097d8e79 Update seelog import paths to new location. 2015-01-15 22:29:07 -06:00
Josh Rickmar b9fd527d33 Remove account support, fix races on btcd connect.
This commit is the result of several big changes being made to the
wallet.  In particular, the "handshake" (initial sync to the chain
server) was quite racy and required proper synchronization.  To make
fixing this race easier, several other changes were made to the
internal wallet data structures and much of the RPC server ended up
being rewritten.

First, all account support has been removed.  The previous Account
struct has been replaced with a Wallet structure, which includes a
keystore for saving keys, and a txstore for storing relevant
transactions.  This decision has been made since it is the opinion of
myself and other developers that bitcoind accounts are fundamentally
broken (as accounts implemented by bitcoind support both arbitrary
address groupings as well as moving balances between accounts -- these
are fundamentally incompatible features), and since a BIP0032 keystore
is soon planned to be implemented (at which point, "accounts" can
return as HD extended keys).  With the keystore handling the grouping
of related keys, there is no reason have many different Account
structs, and the AccountManager has been removed as well.  All RPC
handlers that take an account option will only work with "" (the
default account) or "*" if the RPC allows specifying all accounts.

Second, much of the RPC server has been cleaned up.  The global
variables for the RPC server and chain server client have been moved
to part of the rpcServer struct, and the handlers for each RPC method
that are looked up change depending on which components have been set.
Passthrough requests are also no longer handled specially, but when
the chain server is set, a handler to perform the passthrough will be
returned if the method is not otherwise a wallet RPC.  The
notification system for websocket clients has also been rewritten so
wallet components can send notifications through channels, rather than
requiring direct access to the RPC server itself, or worse still,
sending directly to a websocket client's send channel.  In the future,
this will enable proper registration of notifications, rather than
unsolicited broadcasts to every connected websocket client (see
issue #84).

Finally, and the main reason why much of this cleanup was necessary,
the races during intial sync with the chain server have been fixed.
Previously, when the 'Handshake' was run, a rescan would occur which
would perform modifications to Account data structures as
notifications were received.  Synchronization was provided with a
single binary semaphore which serialized all access to wallet and
account data.  However, the Handshake itself was not able to run with
this lock (or else notifications would block), and many data races
would occur as both notifications were being handled.  If GOMAXPROCS
was ever increased beyond 1, btcwallet would always immediately crash
due to invalid addresses caused by the data races on startup.  To fix
this, the single lock for all wallet access has been replaced with
mutexes for both the keystore and txstore.  Handling of btcd
notifications and client requests may now occur simultaneously.
GOMAXPROCS has also been set to the number of logical CPUs at the
beginning of main, since with the data races fixed, there's no reason
to prevent the extra parallelism gained by increasing it.

Closes #78.

Closes #101.

Closes #110.
2014-07-25 13:26:14 -05:00
Tomás Senart def3543ba6 goimports -w . 2014-07-03 13:45:40 +02:00
Josh Rickmar ad72d3a400 Add basic transaction store logging.
The info log level (default) will produce output about confirmed and
unconfirmed transactions being inserted into the store, as well as
unconfirmed transactions which have been mined into blocks.  By
enabling the debug log level (-d TXST=debug), additional information
about transaction inputs and outputs is logged.  This includes the
total amount of previously-unspent outputs which have been marked
spent by the inserted transaction, and the output indexes and amounts
for each spendable output.  Additionally, the debug log level will log
whenever transactions are removed due to being a double spend of
another inserted transaction.
2014-06-19 18:16:13 -05:00
Josh Rickmar 59845d9c21 Implement a batching rescan manager.
Recent btcd versions only allow one rescan to run at any given time
per websocket client.  To better handle this, a new set of goroutines
are started by the account manager which batch and serialize rescan
jobs.

If no rescans are currently running, a new rescan starts.  If a rescan
is already being processed, the request is queued and runs after the
current rescan finishes.  For any additional incoming requests before
the current rescan finishes, the requests are merged with the
currently-waiting request so both can be handled with a single rescan.

This change also prepares for rescan progress notifications from btcd,
but are still unhandled until the necessary details for
partially-synced addresses are added to the wallet file format.
2014-03-26 17:27:30 -05:00
Josh Rickmar a6e0f3bc2a Update copyright years on remaining files. 2014-01-09 14:13:26 -05:00
Josh Rickmar 9094bcde02 Remove unused const. 2013-10-29 11:02:30 -04:00
Josh Rickmar 91b4a5711c Fix logger formatting.
This change copies the behavior of btcd for using seelog for logging,
including making timestamps human readable, and setting the default
logging level to info.

Fixes #8.
2013-10-29 10:38:51 -04:00