Commit graph

1313 commits

Author SHA1 Message Date
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
Olaoluwa Osuntokun
192de4ec84
Merge pull request #617 from wpaulino/bitcoind-client-misc-fixes
chain: misc BitcoindClient fixes
2019-05-23 17:34:18 -07:00
Wilmer Paulino
8ae8071c54
waddrmgr: use RLock when retrieving sync info 2019-05-23 14:04:02 -07:00
Wilmer Paulino
bf9cc20045
wallet: check RPC error code for rejected confirmed transactions
This unifies the logic of receiving an error when broadcasting a
confirmed transaction through btcd's/bitcoind's RPC interface. The btcd
dependency update is required in order for it to match bitcoind's
behavior. For older nodes that have yet to update, the confirmed
transaction will still be caught by the "transaction already exists"
case. This is not needed for bitcoind however, because its been sending
the same RPC error code for several major releases now.
2019-05-22 17:06:37 -07:00
Wilmer Paulino
0efe836773
chain: avoid using defer for BitcoindClient onRescanFinished notification
Since defer will copy the function with the parameters evaluated at its
invocation, the RescanFinished notification would be dispatched with the
incorrect block. To fix this, we'll just send the notification at the
end ourselves manually.
2019-05-11 13:06:25 -07:00
Wilmer Paulino
28161bee42
chain: improve error logging within BitcoindClient.reorg 2019-05-11 13:05:27 -07:00
Wilmer Paulino
ecfebcea03
chain: remove unnecessary returned error from BitcoindClient.filterBlock 2019-05-11 13:05:23 -07:00
Wilmer Paulino
8d6dd92706
chain: fix Fatalf format verb error 2019-05-11 13:05:17 -07:00
Olaoluwa Osuntokun
9d95f76e99
Merge pull request #614 from wpaulino/on-block-connected-panic
chain: prevent panic if onBlockConnected is called before onFilteredBlockConnected
2019-04-24 15:40:17 -07:00
Wilmer Paulino
e0f82255c7
chain: prevent panic if onBlockConnected is called before onFilteredBlockConnected 2019-04-19 12:27:33 -07:00
Olaoluwa Osuntokun
b386e6385e
Merge pull request #505 from cfromknecht/nuke-votingpool
votingpool: nuke package
2019-04-18 21:36:24 -07:00
Olaoluwa Osuntokun
9e694e2bfc
Merge pull request #613 from wpaulino/neutrino-rescan-finished
chain: dispatch RescanFinished notification after BlockConnected
2019-04-18 20:15:46 -07:00
Wilmer Paulino
b3643ed7a9
chain: dispatch RescanFinished notification after BlockConnected
In this commit, we address a bug within the wallet when running with
Neutrino where it wouldn't be able to mark it as synced with the chain
due to not receiving a RescanFinished notification if it was a block
behind the chain. This happened because of the order in which the
notifications are delivered within the underlying Neutrino ChainService,
FilteredBlockConnected gets dispatched before BlockConnected. This
doesn't always work however because there is an implicit dependency
between them in which BlockConnected must occur first.

To address it, rather than switching the order in which the
notifications are dispatched, we just check if we can dispatch the final
RescanFinished notification after dispatching BlockConnected.

Co-Authored-By: Roei Erez <roeierez@gmail.com>
2019-04-18 19:32:37 -07:00
Wilmer Paulino
767a7a95cf
chain: extract RescanFinished notification dispatch into method
Co-Authored-By: Roei Erez <roeierez@gmail.com>
2019-04-18 19:30:40 -07:00
Wilmer Paulino
8f25b8b4ef
chain: keep track of lastFilteredBlockHeader within NeutrinoClient
Co-Authored-By: Roei Erez <roeierez@gmail.com>
2019-04-18 19:23:05 -07:00
Olaoluwa Osuntokun
8b90263a61
Merge pull request #609 from wpaulino/utxos-after-remove
wtxmgr: only remove entry for specified spending transaction
2019-03-26 20:45:48 -07:00
Wilmer Paulino
0ae78b1f56
wtxmgr: only remove entry for specified spending transaction
In this commit, we address an issue with the wallet store where it'd be
possible for us to keep lingering unconfirmed transaction entries for an
output that has been spent by a different, confirmed transaction. This
was caused due to us removing all spending transaction entries for a
given output when removing conflicts. Since all of the entries would be
removed, we weren't able to retrieve the hashes of the remaining
spending transactions to remove their records as well. Instead, we
propose to only remove the entry for the specified spending transaction.
2019-03-22 16:59:04 -07:00
Olaoluwa Osuntokun
89ab2044f9
Merge pull request #608 from wpaulino/manager-oncommit-lock
waddrmgr: use methods that do not hold the manager's lock
2019-03-18 18:05:15 -07:00
Wilmer Paulino
3cf41c92b5
waddrmgr: use methods that do not hold the manager's lock 2019-03-18 15:47:48 -07:00
Olaoluwa Osuntokun
68fc7c82e1
Merge pull request #607 from Roasbeef/new-neutrino-rescan
build+chain: update to latest version of neutrino
2019-03-12 21:11:34 -07:00
Olaoluwa Osuntokun
d9a9f4176b
build+chain: update to latest version of neutrino
The latest version also includes a change to the way we need to
initialize the rescan object.
2019-03-12 21:05:42 -07:00
Olaoluwa Osuntokun
acf3b04b02
Merge pull request #604 from wpaulino/scan-chain-bug-fix
wallet: ensure bestHeight is updated before isCurrent check
2019-03-12 20:26:08 -07:00
Olaoluwa Osuntokun
ecfdd888dd
Merge pull request #602 from wpaulino/wallet-sync-dev-env
wallet/wallet: accept 0 bestHeight in developer environments
2019-03-12 20:17:22 -07:00
Wilmer Paulino
06bf42c746
wallet: use last synced block as birthday in development environments
In this commit, we address an issue with chains that are not current,
like in the often case of regtest and simnet chains. Syncing the wallet
would fail due to the chain not being current and not finding a suitable
birthday block. We fix this by just using the last synced block as the
birthday block to ensure we can properly sync to the chain.
2019-03-12 18:33:45 -07:00
Wilmer Paulino
ea7c6c3ed9
wallet: accept 0 bestHeight in developer environments
In this commit, we fix a regression in the wallet when attempting to
sync new developer test chains such as regtest and simnet. The wallet
would block syncing until a block was mined, but in order to mine a
block, an address must be generated by the wallet first. This address
generation would block as the syncing logic was already holding the
database's mutex.
2019-03-12 18:33:31 -07:00
Olaoluwa Osuntokun
25804bf90f
Merge pull request #597 from wpaulino/tx-broadcast-err-handling
wallet/wallet: remove invalid transactions when broadcast fails
2019-03-08 21:10:47 -08:00
Wilmer Paulino
5f1ab915be
wallet: ensure bestHeight is updated before isCurrent check
In this commit, we fix an issue with the wallet's initial sync logic
where we'd miss processing all of the blocks in the chain. This can
happen if the backend is considered current while we're still catching
up. To address this, we make sure we update our best height to process
those missed blocks.

Co-authored-by: Roei Erez <roeierez@gmail.com>
2019-03-08 18:31:23 -08:00
Olaoluwa Osuntokun
8c64a08971
Merge pull request #601 from Roasbeef/recovery-bug-fix-node
wallet: only log block batch if non-empty
2019-03-01 13:43:46 -03:00
Olaoluwa Osuntokun
99b7d2e1ed
Merge pull request #510 from halseth/createsimpletx-dryrun
wallet: add dryrun arg to tx create, rolling back db if set
2019-03-01 13:17:48 -03:00
Olaoluwa Osuntokun
b9da1fbd8d
wallet: only log block batch if non-empty
This fixes an issue reputed by a user that would cause btcwallet to
panic if the full node was stopped while btcwallet was still restoring
the wallet.
2019-02-27 18:38:17 -03:00
Johan T. Halseth
650f859fdb
wallet: add dryrun arg to tx create, rolling back db if set 2019-02-27 13:08:18 -03:00
Wilmer Paulino
c7ab11f310
wallet/wallet: reuse publishTransaction within resendUnminedTxs
By doing this, we defer all error string-matching to happen within
publishTransaction, which allows us to simplify some of the existing
logic and maintain consistency.
2019-02-20 14:50:27 -08:00
Wilmer Paulino
7a2b5cef76
wallet/wallet: remove invalid transactions when broadcast fails
In this commit, we rework how publishTransaction works in order to
correctly handle removing invalid transactions from the wallet's
unconfirmed transaction store. This is crucial as otherwise, invalid
transactions can remain within the wallet and be used for further
transactions, causing a chain of inaccurate transactions.

publishTransaction will now only return an error if the transaction
fails to be broadcast and it has not been previously seen in the
mempool/chain. This is intended in order to provide an easier API to
callers. Any other errors when broadcasting the transaction will cause
it to be removed from the wallet's unconfirmed transaction store to
ensure it maintains an accurate view of the chain.
2019-02-20 14:50:27 -08:00
Wilmer Paulino
7e00d1843e
wallet/wallet: refactor sending transaction to backend into own method
We do this in order to be able to reuse the new publishTransaction
method within other parts of the wallet in order to consolidate all
error string-matching within one place.
2019-02-20 13:13:44 -08:00
Johan T. Halseth
918d9c2f88
waddrmgr/scoped_manager: add nextAddresses cache update to db tx's OnCommit()
This commit makes nextAddresses add a function to the transactions
OnCommit handler used to update the cache on successful database
transaction commit. Before this we would risk the cache and database of
get out of sync if the database transaction failed or was aborted after
the cache was updated.
2019-02-14 09:19:25 +01:00
Johan T. Halseth
3378be750b
walletdb/interface: add OnCommit and Tx methods
This commit adds the method OnCommit to the ReadWriteTx interface,
making it possible to add closures to be executed once the transaction
is commitited. The method Tx is added to the ReadWriteBucket interface,
for getting the bucket's underlying tx.

The bdb implementation is updated to satisfy the interface change.
2019-02-14 09:19:18 +01:00
Johan T. Halseth
b688a6d891
walletdb/bdb: update interface implementation godoc
Recently the Bucket and Tx interfaces were split into Read and ReadWrite
versions. This commit updates the godoc for the bdb interface
implementation to be consistent with this change.
2019-02-14 09:19:18 +01:00
Olaoluwa Osuntokun
b51c1adeee
Merge pull request #591 from halseth/not-is-current-at-0
wallet/wallet: assume not current if best height is 0
2019-02-12 19:46:19 -08:00
Olaoluwa Osuntokun
d1a7a29ea8
Merge pull request #593 from cfromknecht/filter-fix-neutrino
build: update to latest btcd, btcutil, and neutrino
2019-02-12 19:31:19 -08:00
Olaoluwa Osuntokun
66ad6be7f4
build: update to latest btcd, btcutil, and neutrino 2019-02-12 19:12:34 -08:00
Olaoluwa Osuntokun
b8074786d7
Merge pull request #590 from wpaulino/dependency-sort
wtxmgr: export dependencySort and add unit tests
2019-02-08 16:22:37 -08:00
Johan T. Halseth
eef81a4124
wallet/wallet: assume not current if best height is 0
This is done to avoid the birthday rescan to fail if the chain backend
reports a bestheight of 0.

Earlier it could happen that we attempted to sync to the birthday, but
since only the genesis block was available, which would be rejected as
birthday block because of the timestamp, it would fail to find a block
and the sync would fail.
2019-02-06 11:26:24 +01:00
Wilmer Paulino
a832811f8b
wtxmgr/khansort_test: add DependencySort unit tests 2019-01-31 16:43:22 -08:00
Wilmer Paulino
9b37298bad
wtxmgr: export dependencySort 2019-01-31 16:42:53 -08:00
Wilmer Paulino
fe56fdb828
wtxmgr: refactor dependencySort to use wire.MsgTx 2019-01-31 16:41:19 -08:00
Olaoluwa Osuntokun
ba03278a64
Merge pull request #577 from wpaulino/initial-sync-birthday-block
wallet/wallet: redefine initial sync to birthday block not being set
2019-01-22 19:32:36 -08:00
Wilmer Paulino
c853ceaa60
wallet/wallet: consolidate rollback logic
In this commit, we consolidate the existing rollback logic to carry out
its duties under one database transaction.

Co-authored-by: Roei Erez <roeierez@gmail.com>
2019-01-14 22:42:45 -08:00
Wilmer Paulino
db837f1ba3
wallet/wallet: use new syncToBirthday and recovery methods
In this commit, we refactor the wallet's syncing logic with
syncWithChain to use the newer, simpler methods: syncToBirthday and
recovery. Along the way, we also fix a bug within the wallet where it
was possible to sync past the birthday, but not sync to tip completely
and restart, which would lead to us starting a rescan from the latest
synced height, rather than from the birthday stamp.

This commit slightly changes the wallet's syncing behavior to the
following:

  1. Ensure the wallet is synced to its birthday.
  2. Perform a recovery if requested.
  3. Check for chain reorgs.
  4. Dispatch a rescan from the current synced height.

Co-authored-by: Roei Erez <roeierez@gmail.com>
2019-01-14 22:42:45 -08:00
Wilmer Paulino
29e1f0c4fb
wallet/wallet: add new recovery method
In this commit, we add a new recovery method to the wallet. This method
attempts to recover any unspent outputs which pay to any of the wallet's
addresses. Most of the logic found within it is heavily borrowed from
the existing syncWithChain method. This method is currently unused, but
it will end up replacing some of the existing sync logic in a later
commit.
2019-01-14 22:42:45 -08:00
Wilmer Paulino
089cc747db
wallet/wallet: add new syncToBirthday method
In this commit, we add a new syncToBirthday method to the wallet. This
method intends to sync the wallet's point of the view of the chain until
finding its birthday. Most of the logic found within it is heavily
borrowed from the existing syncWithChain method. This method is
currently unused, but it will end up replacing some of the existing sync
logic in a later commit.

Co-authored-by: Roei Erez <roeierez@gmail.com>
2019-01-14 22:42:45 -08:00