Commit graph

1384 commits

Author SHA1 Message Date
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
Conner Fromknecht
13796b496a
votingpool: nuke package
This commit removes the votingpool package, which is currently
unused as far as I'm aware.
2018-11-29 15:07:08 -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
Wilmer Paulino
80450c9033
wallet/chainntfns: make birthdaySanityCheck return ErrBirthdayBlockNotSet 2018-11-20 13:00:45 -08:00
Wilmer Paulino
cc77e41198
wallet/chainntfns: set height for new birthday block candidate
In this commit, we address an issue that would cause users to be stuck
in an infinite loop by fetching the same candidate birthday block due to
its height not being updated if the sanity check was attempting to fix
an estimate in the future. We fix this by setting the new candidate
height so that new candidate blocks can be fetched and tested.
2018-11-19 20:48:14 -08:00
Wilmer Paulino
f92cc4db42
wallet/chainntfns_test: add birthdaySanityCheck tests 2018-11-19 20:48:14 -08:00
Wilmer Paulino
03a818efaa
wallet/chainntfns: remove wallet dependency from birthdaySanityCheck
In this commit, we remove the wallet dependency from the
birthdaySanityCheck function. Every interaction with the wallet is now
backed by two interfaces, birthdayStore and chainConn. These interfaces
will allow us to increase the test coverage of the birthdaySanityCheck
as now we'll only need to mock out only the necessary functionality.
2018-11-19 20:48:14 -08:00
Olaoluwa Osuntokun
55c7c63993
Merge pull request #575 from wpaulino/syncedto-rescan
wallet/wallet: prevent always rescanning from birthday block
2018-11-15 19:00:35 -08:00
Wilmer Paulino
bd95bfa6fb
wallet/wallet: prompt sanity check upon setting new birthday block within ImportPrivateKey
In this commit, we set the verified bit to false upon setting the new
birthday block to ensure its correctness as it was provided by the caller.
2018-11-15 18:17:56 -08:00
Wilmer Paulino
16ea72e95b
wallet/wallet: update to latest SetBirthdayBlock changes 2018-11-15 18:17:56 -08:00
Wilmer Paulino
f9df4908b3
wallet/chainntfns: prevent sanity check if correctness of birthday block has been verified
In this commit, we prevent any further sanity check attempts by the
wallet if its correctness has previously been verified. We do this to
ensure we don't unnecessarily attempt to find a new candidate.
2018-11-15 18:17:56 -08:00
Wilmer Paulino
7c377b2906
waddrmgr/sync: expose verification status in Manager's birthday block methods 2018-11-15 18:02:21 -08:00
Wilmer Paulino
6568c433fe
waddrmgr/db: store birthday block verification status
In this commit, we add a new key/value pair to the waddrmgr's sync
bucket to store the verification status of the birthday block. This
verification status determines whether the wallet has verified the
correctness of its birthday block through its sanity check on startup.
2018-11-15 18:01:19 -08:00