Commit graph

1144 commits

Author SHA1 Message Date
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
Olaoluwa Osuntokun
9ad115360b
Merge pull request #584 from cfromknecht/btcd-neutrino-module-bump
build: bump to latest btcd+neutrino+btcutil
2019-01-14 18:45:21 -08:00
Wilmer Paulino
ec210ad79c
chain/bitcoind_client: extend filterTx with script spend support
In this commit, we extend the BitcoindClient to properly detect the
spend of an arbitrary script on-chain. This is possible by looking at a
transaction's input and re-deriving the PkScript, from its signature
script/witness, of the output it's attempting to spend. Upon detecting
the spend, a chain.RelevantTx will be dispatched.
2019-01-14 18:38:45 -08:00
Conner Fromknecht
cf8553756b
build: bump to latest btcd+neutrino+btcutil 2019-01-14 18:38:30 -08:00
Wilmer Paulino
177e31c0b3 waddrmgr+cmd/dropwtxmgr: start rescan from birthday block
In this commit, we modify the dropwtxmgr tool to force a rescan upon
restart from the wallet's birthday block, rather than the chain's
genesis block. We can safely do this as we expect that no on-chain
events relevant to the wallet should happen before this block.  For
older wallets which do not have their birthday block set, the rescan
should start from the genesis block.
2019-01-08 20:12:16 -08:00
Olaoluwa Osuntokun
e59e51f8e1
Merge pull request #581 from cfromknecht/fix-go-modules-2
build: update to latest btcd and neutrino versions
2018-11-30 14:16:47 -08:00
Olaoluwa Osuntokun
eb7f35e8d1
build: update to latest btcd and neutrino versions 2018-11-30 14:10:43 -08:00
Olaoluwa Osuntokun
a6439bb0d2
Merge pull request #580 from cfromknecht/latest-btcd
build: use latest btcd and neutrino
2018-11-30 13:50:35 -08:00
Olaoluwa Osuntokun
1650767ccc
build: force go socks as dep 2018-11-30 13:45:39 -08:00
Olaoluwa Osuntokun
519b80b838
build: use latest btcd and neutrino 2018-11-29 23:30:39 -08:00
Olaoluwa Osuntokun
284e2e0e69
Merge pull request #578 from cfromknecht/go-modules
build: Update to go modules
2018-11-29 19:07:54 -08:00
Olaoluwa Osuntokun
d1aea1782f
build: for go modules for entire goclean.sh 2018-11-29 19:03:23 -08:00
Olaoluwa Osuntokun
b0f5763403
build: force go modules support in goclean.sh test execution 2018-11-29 18:54:58 -08:00
Olaoluwa Osuntokun
50095184c1
build: update travis build to use go modules, switch to go 1.11 2018-11-29 18:47:19 -08:00
Olaoluwa Osuntokun
25f864e62f
build: update goclean.sh to use go modules, not dep 2018-11-29 18:46:36 -08:00
Olaoluwa Osuntokun
20db88d8ff
walletdb/bdb: switch from bolt to bbolt
Fixes #545.
2018-11-29 18:43:37 -08:00
Olaoluwa Osuntokun
b523fd5274
buid: remove old glide build files 2018-11-29 18:42:53 -08:00
Olaoluwa Osuntokun
47cd06ad14
build: add new go.mod and go.sum files for gomodules 2018-11-29 18:42:34 -08:00
Olaoluwa Osuntokun
7ad4f1e81d
Merge pull request #576 from wpaulino/birthday-block-candidate
wallet/chainntnfs: set height for new birthday block candidate
2018-11-20 15:37:25 -08:00