Commit graph

1425 commits

Author SHA1 Message Date
Wilmer Paulino 66e09f252d
wtxmgr: remove unconfirmed input reference for confirmed transcation
Previously, inserting a transaction as unconfirmed into the store and
later confirming it would leave a lingering unconfirmed input record.
This was discovered as part of
https://github.com/btcsuite/btcwallet/pull/655. This issue would only
affect the wallet if it tracked spent transaction outputs, which it
doesn't. We aim to resolve it in any case for the sake of internal
consistency.
2019-10-30 16:44:55 -07:00
Wilmer Paulino ac731b8e52
wtxmgr: add TestInsertMempoolTxAndConfirm
This test ensures that there aren't any lingering unconfirmed records
for a transaction that existed within the store as unconfirmed before
becoming confirmed. At the moment, this is currently failing due to a
gap when moving a transaction from unconfirmed to confirmed within the
store. This will be resolved in a subsequent commit.
2019-10-30 16:44:54 -07:00
Roei Erez 1c43ed9294 wtxmgr: fix broadcast existing transaction
This commit ensures the wallet won't enter an inconsitent state
by checking tx confirmation before adding credit.
Without this fix, In the case the existing transaction is already
confirmed on-chain the flow updates the bucketUnminedCredits but
without adding en entry also to the bucketUnmined resulting in
inconsistent state.
2019-10-31 00:28:21 +02:00
Wilmer Paulino 1e2f445cdd
wtxmgr: improve error message for failed tx record retrieval 2019-10-24 09:24:32 -04:00
Olaoluwa Osuntokun 7abdd4f8ad
Merge pull request #649 from halseth/neutrino-dep-update-cfilter-fix
mod: update neutrino dep
2019-10-14 18:12:23 +02:00
Johan T. Halseth ed825b0fd9
mod: update neutrino+btcd dep 2019-10-14 17:53:31 +02:00
Olaoluwa Osuntokun 5f205d607b
Merge pull request #648 from wpaulino/bolt-no-freelist-sync-option
multi: extend walletdb bolt driver with NoFreelistSync option
2019-10-03 21:45:42 -07:00
Wilmer Paulino 81797fe29d
multi: extend walletdb bolt driver with NoFreelistSync option
This allows external callers to set the option instead. All tests
remained with the option enabled.
2019-10-03 13:28:04 -04:00
Olaoluwa Osuntokun 95d7aa0b49
Merge pull request #647 from halseth/rbf-reject-matching
Cleanup publication error matching, add ErrDoubleSpend/ErrReplacment
2019-09-24 17:50:52 -07:00
Johan T. Halseth 0149963628
wallet: define ErrReplacement
This error will be returned if the backend rejects a transaction since
it doesn't satisfy the requirements for replacement.
2019-09-24 09:00:22 +02:00
Johan T. Halseth 7533180fd3
wallet: define ErrDoubleSpend
This error is returned in cases where there are conflicting transactions
either in the mempool or chain.
2019-09-24 09:00:10 +02:00
Johan T. Halseth 33770f11b2
wallet: clean up error string matching
Also note where the errors are found.
2019-09-20 09:31:02 +02:00
Olaoluwa Osuntokun d5cdeb4b91
Merge pull request #644 from wpaulino/notify-on-not-filtered
chain: notify block when not filtered for BitcoindClient
2019-09-11 09:57:39 +03:00
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