Commit graph

1512 commits

Author SHA1 Message Date
Wilmer Paulino
333ecbf262 chain: notify block when not filtered for BitcoindClient 2019-09-09 17:10:38 +03:00
Olaoluwa Osuntokun
ae43a2a200
Merge pull request #643 from wpaulino/go1.13
build: pin against latest neutrino version and update travis to go 1.13
2019-09-05 18:38:08 -07:00
Olaoluwa Osuntokun
277ce501a4
build: run travis against go 1.13 2019-09-05 18:31:15 -07:00
Olaoluwa Osuntokun
cfb9bb1e32
build: pin against latest neutrino version 2019-09-05 18:31:03 -07:00
Olaoluwa Osuntokun
5480f628bc
Merge pull request #642 from wpaulino/submodule-wtxmgr-txauthor
build: create new modules for wtxmgr and internal packages
2019-09-05 17:46:43 -07:00
Olaoluwa Osuntokun
3fc43caa86
build: update top-level module to pin to new sub-modules 2019-09-05 17:34:09 -07:00
Olaoluwa Osuntokun
8dddf4319f
wallet/txauthor: create new wallet/txauthor module 2019-09-05 17:30:56 -07:00
Olaoluwa Osuntokun
a608ee4e4f
wallet/txrules: create new wallet/txrules module 2019-09-05 17:24:09 -07:00
Olaoluwa Osuntokun
d510e4772d
wallet/txsizes: create new txsizes package+module, remove internal version
In this commit, we move the existing `internal/txsizes` package into its
own package and make it a module along the way. This allows projects
like `neutrino` to depend on a slimmer set of `btcwallet` related
dependencies.
2019-09-05 17:18:14 -07:00
Olaoluwa Osuntokun
35a7a1a0f6
wtxmgr: create new wtxmgr submodule 2019-09-05 16:57:26 -07:00
Olaoluwa Osuntokun
4a8fb7b716
Merge pull request #641 from wpaulino/walletdb-module
build+walletdb: create new module for walletdb
2019-09-05 16:32:33 -07:00
Olaoluwa Osuntokun
0594b75a43
build+walletdb: create new module for walletdb
In this commit, we create a new module for `walletdb` in order to allow
external projects to use the project without also having to depend on
the entirety of `btcwallet`. With this commit, projects that depend on
`walletdb` will benefit from a slimmer set of additional dependencies.
2019-09-05 16:23:31 -07:00
Olaoluwa Osuntokun
300b649394
Merge pull request #634 from Crypt-iQ/bbolt_options_btcwallet_0801
bdb: specify freelist options by default
2019-09-04 14:59:10 -07:00
Olaoluwa Osuntokun
a5162f9db4
Merge pull request #639 from wpaulino/remove-golangcrypto-dep
build: replace use of btcsuite/golangcrypto with golang.org/x/crypto
2019-09-04 12:58:14 -07:00
Wilmer Paulino
26a58718a3
build: replace use of btcsuite/golangcrypto with golang.org/x/crypto
btcsuite/golangcrypto was created to cope with the lack of package
management for Go back in the day. This is no longer needed as we now
use modules.
2019-09-04 12:51:58 -07:00
Olaoluwa Osuntokun
505acf5150
Merge pull request #636 from wpaulino/empty-filter-block
chain: prevent filtering blocks when BitcoindClient has an empty filter
2019-08-13 19:34:31 -07:00
Wilmer Paulino
5124978a9b
chain: prevent filtering blocks when BitcoindClient has an empty filter 2019-08-09 18:16:40 -07:00
nsa
e809748b1e bdb: specify freelist options by default
This commit specifies two bbolt options when opening the bbolt db.
This reduces heap pressure in case there are a lot of pages on
the freelist.
2019-08-01 22:15:53 -04:00
nsa
604661be3d build: update bbolt to v1.3.3
This commit updates the bbolt dependency to v1.3.3 so that we
can use the NoFreelistSync option without triggering a panic
in case a rollback occurs.
2019-08-01 19:30:07 -04:00
Olaoluwa Osuntokun
7a3a3e82cb
Merge pull request #633 from wpaulino/insert-unconfirmed-after-confimed
wtxmgr: prevent adding existing confirmed transactions as unconfirmed
2019-07-11 20:49:38 -07:00
Olaoluwa Osuntokun
79761f5121
Merge pull request #632 from wpaulino/bitcoind-block-zmq-read
chain: explicitly close connections in BitcoindConn's Stop method
2019-07-11 15:45:49 -07:00
Wilmer Paulino
02b0a7c18d
wallet: fix nil txid in publishTransaction
A nil txid could've been returned from publishTransaction even if it was
successful. This was due to the underlying SendRawTransaction call
"failing", e.g., when the transaction being broadcast has already
confirmed, but publishTranasction interpreting such failure as a
success.
2019-07-10 16:25:01 -07:00
Wilmer Paulino
44d818d813
wtxmgr: prevent adding existing confirmed transactions as unconfirmed
We do this as a sanity check for users of the wallet to ensure the
wallet maintains a correct representation of the chain.
2019-07-10 16:25:00 -07:00
Wilmer Paulino
6c4dab5f7c
chain: remove extraneous rpcclient.Disconnect calls from BitcoindConn
These are not needed since they have no effect when the RPC client is
making HTTP POST requests.
2019-07-10 16:15:51 -07:00
Wilmer Paulino
f02166e5de
chain: explicitly close connections in BitcoindConn's Stop method
Since it's now possible for gozmq.Conn to block when calling Receive,
BitcoindConn hangs upon being stopped because its goroutines are waiting
for a message to be delivered. To address this, we modify it to close
its ZMQ connections driving the goroutines once it's been stopped. This
allows the goroutines to unblock by detecting the EOF error and exiting.
2019-07-10 16:15:50 -07:00
Olaoluwa Osuntokun
cd66e82bc8
Merge pull request #631 from wpaulino/dropwtxmgr-max-reorg-depth
cmd/dropwtxmgr+waddrmgr: handle constraint when resetting synced state
2019-07-10 15:45:58 -07:00
Wilmer Paulino
f710cd4a92
cmd/dropwtxmgr+waddrmgr: handle constraint when resetting synced state
We update the dropwtxmgr utility tool to take into account that the
wallet only stores MaxReorgDepth blocks, which introduced an additional
constraint when updating the wallet's synced state. The constraint
ensures that the previous block exists when updating the wallet's synced
state, but this does not hold for the birthday block since it's the
first block we'll store.
2019-07-08 13:26:43 -07:00
Olaoluwa Osuntokun
4a9774585e
Merge pull request #628 from cfromknecht/faster-btcd-init
wallet: speed up bare wallet init when using the btcd backend
2019-06-28 15:53:30 -07:00
Olaoluwa Osuntokun
2698f8434e
wallet: speed up bare wallet init when using the btcd backend
In this commit, we speed up creating a fresh wallet when using the btcd
backend. Before this commit, we would need to rescan 10k or so blocks
when creating a new wallet with the btcd backend. btcd will actually
fully scan all the blocks even though we have zero addresses or UTXOs to
look for. As a result, this can take quite some time.

In this commit we modify the starting height of the initial rescan to
start at the birthday height, and only modify it if it's unset, or the
best height of the chain is before this birthday height. As a result, we
won't always have the full 10k block re org safety horizon on disk, but
will tend to this level after we begin to sync forward.
2019-06-28 15:01:09 -07:00
Olaoluwa Osuntokun
46c0cf2a3f
Merge pull request #627 from wpaulino/wallet-recovery-start-height
wallet: start recovery from the wallet's best height
2019-06-20 16:32:57 -07:00
Wilmer Paulino
2ff8e92e37
wallet: remove wallet best height check when checkpointing intial sync
This check is not required since the wallet's best height is the genesis
block.
2019-06-19 20:00:00 -07:00
Wilmer Paulino
426f523475
wallet: start recovery from the wallet's best height
Previously, the wallet would attempt to store the same block it
checkpointed during its initial sync when performing a recovery. This
would cause the previous block existence validation check to be in
place, which would ultimately fail because the previous block was not
stored intentionally.

To address this, we always start/resume our recovery from the wallet's
best height. This also ensures that we do not rescan the same block
again when resuming a recovery after a shutdown.
2019-06-19 19:59:51 -07:00
Olaoluwa Osuntokun
de02d6fdfb
Merge pull request #626 from Roasbeef/dust-fix-sendoutputs
wallet: use relay fee to check for dust not fee rate
2019-06-18 17:55:38 -07:00
Olaoluwa Osuntokun
1dccdec1c1
wallet: use relay fee to check for dust not fee rate
In this commit we fix a lingering bug in our output sanity checks that
would only show up during time periods of persistently higher fees.
Before this commit we would incorrectly use the fee rate instead of the
min relay fee when checking an output for dust. This would cause us to
mistakenly reject a transaction for having a dust output.

We fix this by falling back to using the current min-relayfee.
2019-06-18 17:11:01 -07:00
Olaoluwa Osuntokun
a335c56614
Merge pull request #618 from wpaulino/instant-wallet-startup
wallet+waddrmgr: sync and store up to MaxReorgDepth blocks
2019-06-14 06:35:44 +02:00
Wilmer Paulino
4a913d02ea
chain: only allow bitcoind block notifications at tip after NotifyBlocks
One could argue that the behavior before this commit was incorrect, as
the ChainClient interface expects a call to NotifyBlocks before
notifying blocks at tip, so we decide to fix this.

Since we now wait for the chain backend to be considered "current"
before proceeding to sync the wallet with it, any blocks that were
processed while waiting would result in being notified and scanned
twice, once by processing it at tip, and another while rescanning the
wallet, which is not desirable.
2019-06-13 18:09:06 -07:00
Wilmer Paulino
a9847c28b6
wallet: improve error logging for unsuccessful notification handling
If a block arrives while the wallet is rescanning, users would be shown
a log message that is confusing and not very helpful.
2019-06-13 18:09:05 -07:00
Wilmer Paulino
fd8aa5d541
wallet: use locateBirthdayBlock within birthdaySanityCheck
We use the recently introduced locateBirthdayBlock function within
birthdaySanityCheck as it serves as a more optimized alternative that
achieves the same purpose.
2019-06-13 18:09:04 -07:00
Wilmer Paulino
26bc5ab104
wallet: remove unused function scanChain 2019-06-13 18:09:03 -07:00
Wilmer Paulino
fa65c1b5f7
wallet: store reorg safe height upon initial sync
Currently, wallet rescans start from its known tip of the chain. Since
we no longer store blocks all the way from genesis to the tip of the
chain, performing a rescan would cause us to scan blocks all the way
from genesis, which we want to avoid. To prevent this, we set the
wallet's tip to be the current reorg safe height. This ensures that
we're unable to scan any blocks before it, and that we maintain
MaxReorgDepth blocks stored.
2019-06-13 18:09:02 -07:00
Wilmer Paulino
e754478496
wallet: modify recovery logic to not start from genesis
This commit serves as another building point to allow the wallet to not
store blocks all the way from genesis to the tip of chain. We modify the
wallet's recovery logic to now start from either its birthday block, or
the current reorg safe height if it's before the birthday, to ensure the
wallet properly only stores MaxReorgDepth blocks.

We also refactor things a bit in hopes of making the logic a bit more
readable.
2019-06-13 18:09:02 -07:00
Wilmer Paulino
2a6f24c61b
wallet: locate birthday block without scanning chain from genesis
We do this as the wallet will no longer store blocks all the way from
genesis to the tip of the chain. Instead, in order to find a reasonable
birthday block, we resort to performing a binary search for a block
timestamp that's within +/-2 hours of the birthday timestamp.
2019-06-13 18:09:01 -07:00
Wilmer Paulino
17efcdba2f
wallet: wait until chain backend is current to begin wallet sync
This serves as groundwork for only storing up to MaxReorgDepth blocks
upon initial sync. To do so, we want to make sure the chain backend
considers itself current so that we can only fetch the latest
MaxReorgDepth blocks from it.
2019-06-13 18:09:00 -07:00
Wilmer Paulino
39f81c630b
chain: add IsCurrent method to chain.Interface
IsCurrent allows us to determine if the chain backend considers itself
"current" with the chain.
2019-06-13 18:08:59 -07:00
Wilmer Paulino
1ee2a239de
wallet: make wallet initial sync synchronous
This ensures the wallet can properly do an initial sync, a recovery, or
detect if it's on a stale branch before attempting to process new blocks
at tip.

Since the rescan will be triggered synchronously as well, we'll need to
catch the wallet's quit chan when handling rescan batches in order to
allow for clean shutdowns.
2019-06-13 18:08:58 -07:00
Wilmer Paulino
f2f46b674d
waddrmgr: add migration to maintain MaxReorgDepth block hashes stored
In this commit, we add a migration that will be used by existing wallets
to ensure they can adhere to the new requirement of storing up to
MaxReorgDepth entries within the block hash index.
2019-06-11 12:02:42 -07:00
Wilmer Paulino
e548e76684
waddrmgr: maintain a maximum of MaxReorgDepth block hashes stored
In this commit, we modify the wallet's block hash index to only store up
to MaxReorgDepth blocks. This allows us to reduce consumed storage, as
we'd be mostly storing duplicate data. We choose to store up to
MaxReorgDepth to ensure we can recover from a potential long reorg.
2019-06-11 12:02:41 -07:00
Olaoluwa Osuntokun
66a95921c0
Merge pull request #624 from wpaulino/neutrino-rescan-finished-deadlock
chain: prevent deadlock while notifying RescanFinished for NeutrinoClient
2019-06-11 04:59:59 +02:00
Wilmer Paulino
eedd5ce1b6
chain: prevent deadlock while notifying RescanFinished for NeutrinoClient 2019-06-07 13:00:09 -07:00
Olaoluwa Osuntokun
2c05240dff
Merge pull request #620 from wpaulino/waddrmgr-rlock-sync
waddrmgr: use RLock when retrieving sync info
2019-05-23 17:35:33 -07:00