Commit graph

29 commits

Author SHA1 Message Date
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
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
Josh Rickmar
e5e239e124 API updates for times in block notifications. 2015-06-18 12:29: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
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
fbe92830c1 Use btcjson v2 types with the updated btcrpcclient.
btcrpcclient commit 9ca93b30ad11ec34348d2d788c58019571bf9524 switched
the client to btcjson v2 and broke the wallet build.  This change is
the minimum amount of work to make wallet work again.

The rpc server still uses btcjson v1, so there will be 2 versions of
btcjson linked in the resulting binary.  This is not optimal but not
compiling is worse.
2015-04-06 13:14:01 -04:00
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
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
Dave Collins
8b6c161cbc Update btcws path import paths to new location. 2015-02-19 13:09:16 -06:00
Josh Rickmar
ad80e9f384 Address several issues pointed out by lint and vet.
This brings the entire tree closer to but not 100% goclean.sh clean.
2015-02-06 01:04:01 -05:00
Dave Collins
4a1067b6f1 Update btcnet path import paths to new location. 2015-02-05 23:58:46 -06:00
Dave Collins
23c9dc423e Update btcwire path import paths to new location. 2015-02-05 15:41:38 -06:00
Dave Collins
f05ab25696 Update btcwallet import paths to new location. 2015-01-17 00:25:53 -06:00
Dave Collins
3fc3ecc908 Update btcws import paths to new location. 2015-01-16 23:40:19 -06:00
Dave Collins
a26a65e2e0 Update btcnet import paths to new location. 2015-01-16 17:32:30 -06:00
Dave Collins
283aa28be5 Update btcwire import paths to new location. 2015-01-16 16:03:04 -06:00
Dave Collins
2f79c3176e Update btclog import paths to new location. 2015-01-16 11:43:34 -06:00
Dave Collins
d71bc3193f Update btcrpcclient import paths to new location. 2015-01-15 21:28:09 -06:00
Dave Collins
afeb509c45 Update btcutil import paths to new location. 2015-01-15 10:48:58 -06:00
Javed Khan
edaddb0d95 Allow disabling RPC client TLS for localhost only.
This commit introduces a new flag, --noclienttls, which can be used to disable
TLS for the RPC client.  However, the flag can only be used when the RPC
client is connecting to localhost interfaces.  This is intended to prevent
accidentally leaking sensitive data when switching between local and
remote servers.
2015-01-09 21:36:48 +05:30
Josh Rickmar
757244a8da Fix logging for improper redeemingtx notifications. 2014-08-14 15:27:14 -05:00
Guilherme Salgado
868625d8c3 Remove a unused channel from chain.NewClient 2014-07-31 14:33:46 -05:00
Josh Rickmar
248ea9c08f Send btcdconnected notifications without a wallet.
The notified chain server connection state was being passed through
the wallet and then notified to the RPC server, which prevented this
notification from ever firing if a wallet didn't exist yet.  Instead,
make the RPC server register for these notifications directly from the
chain server RPC client.

I'm not happy with this notification and how it's handled in the code,
but to not break existing clients this change is being made.  Fixing
the notifiation mess and modifying existing clients to use a new
notification API will need to be done sometime later.
2014-07-30 09:47:50 -05:00
Josh Rickmar
8771664af7 Send btcdconnected ntfns to connected clients.
If a websocket client was already connected and the wallet and/or
chain server is loaded into the rpc server (enabling the handlers
specific to those components), the btcdconnected notifications were
not being sent, and this could break clients that expected the
notification.  I'm not happy with this change, but since this is how
notifications are currently done (unsolicited), and to not break
compatibility yet, I'm adding these back in for now.

Eventually, this notification will require explicit registration
before it is received by a client.  See issue #84.

Closes #115.
2014-07-28 09:33:00 -05: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