Commit graph

1325 commits

Author SHA1 Message Date
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
Wilmer Paulino
4f5baed780
wallet/wallet: prevent always rescanning from birthday block
In this commit, we address an issue with the wallet where it would
always request a rescan from the birthday block. This is very crucial
for older wallets, as it'll potentially go through thousands of blocks.
To address this, we'll now only request a rescan from our birthday if
we're recovering our wallet from our seed, the birthday block was rolled
back, or if we're performing our initial sync. Otherwise, we'll request
a rescan from tip.
2018-11-15 16:34:42 -08:00
Olaoluwa Osuntokun
4c01c0878c
Merge pull request #573 from wpaulino/notify-received
wallet: notify wallet upon relevant transaction confirmation
2018-11-14 18:39:41 -08:00
Wilmer Paulino
31011de227
wtxmgr+wallet: add wtxmgr sublogger 2018-11-14 18:09:10 -08:00
Wilmer Paulino
9d329e111e
wtxmgr/migrations: add drop transaction history migration
In this commit, we follow up our previous migration to reset our synced
block to our birthday block with another migration to drop our
transaction history. We'll need to do this to ensure that the
transaction store matches the exact state of our outputs on-chain to
prevent inadvertently crafting any invalid transactions.
2018-11-14 18:09:10 -08:00
Wilmer Paulino
a0a5e46177
wtxmgr/db: add new createBuckets and deleteBuckets methods 2018-11-14 18:09:10 -08:00
Wilmer Paulino
de4662e5df
wtxmgr: convert unit tests to be package-level
This allows us to reuse some of the existing code to test migrations of
the transaction store.
2018-11-14 18:09:10 -08:00
Wilmer Paulino
0424fd22ec
waddrmgr/migrations: add migration to force rescan from birthday block
In this commit, we add a migration to force a rescan of users' wallets
starting from their birthday block to ensure that their balance is
reflected correctly as it is on-chain. This was inspired by the recent
bug discovered where the wallet would not watch for the confirmation of
a relevant transaction.
2018-11-14 18:09:10 -08:00
Wilmer Paulino
ae31984630
wallet: request notification of tx confirmation that pays to relevant addr
In this commit, we address a slight regression within the wallet
that was introduced in a previous commit. When attempting to send coins
on-chain, we would never ask the chain backend to notify us of the
transaction upon confirmation. This, along with the rebroadcast of
unconfirmed transactions logic, would result in the wallet becoming out
of sync with the chain.

Below is an example of how this could have happened:

  1. Send funds on-chain.
  2. Wallet doesn't ask to be notified of the confirmation.
  3. Since the wallet is not notified of the confirmation, the
  transaction remains in the unconfirmed bucket, even though it might
  have already confirmed on-chain.
  4. Restart and trigger the rebroadcast of unconfirmed transactions.
  5. The unconfirmed transaction is removed from the unconfirmed bucket
  due to it already existing on-chain, without it being moved to the
  confirmed bucket. Moving to the confirmed bucket would require the
  block at which it confirmed, which we don't have at this point.
2018-11-14 18:06:26 -08:00
Wilmer Paulino
4976c84f8f
wallet/wallet: prevent logging resend tx error if already accepted into
mempool
2018-11-14 18:06:25 -08:00