Commit graph

73 commits

Author SHA1 Message Date
Roy Lee
7b5b2ff774 [lbry] remove nested go mudules 2022-05-24 03:09:34 -07:00
Oliver Gugger
60a04006d6
wtxmgr: remove unused functions 2021-07-23 12:49:36 +02:00
Olaoluwa Osuntokun
5649a66307
Merge pull request #751 from LN-Zap/fix-2398
Prevent duplicate notifications for (un)confirmed transactions
2021-07-13 16:05:48 -07:00
Joost Jager
5b1e64abde
wtxmgr: filter out expired leases
Expired leases are kept in the database until the next cleaning round.
This commit makes sure that expired leases look like they do not exist
to outside callers.
2021-07-05 08:57:33 +02:00
Bjarne Magnussen
0066eee3ea
wtxmgr: add InsertTxCheckIfExsists to check if a tx already recorded
Adds new error `ErrDuplicateTx` and method `InserTxCheckIfExists` to check if a transaction to be inserted was already recorded.
2021-05-28 14:29:48 +02:00
Olaoluwa Osuntokun
47e0edadcd
build: update pinned modules to latest versions 2021-05-13 16:36:34 -07:00
Olaoluwa Osuntokun
5c08d49e19
Merge pull request #732 from wpaulino/import-account-or-pubkey
wallet: support derived public key import
2021-03-23 18:39:13 -07:00
Wilmer Paulino
6ff982ccdc
wtxmgr: prevent race condition by using local vars 2021-03-15 19:08:06 -07:00
Joost Jager
8932811695 wallet: parameterize lock duration
Allow arbitrary lock durations instead of a hard-coded ten minute
period.
2021-03-12 12:51:15 +01:00
Joost Jager
ff2577a0e7 wtxmgr: add ListLeases 2021-03-12 12:51:15 +01:00
Wilmer Paulino
690a12fa8b
wtxmgr: ignore ErrBucketNotFound error upon locked outputs bucket deletion
This error would be seen when an old wallet that has yet to update is
performing the latest wtxmgr migration. It's possible for the locked
outputs bucket to not exist if outputs haven't been locked before, so we
should its deletion correctly.
2021-02-15 14:40:34 -08:00
Olaoluwa Osuntokun
526c9a6103
wtxmgr: update to walletdb v1.3.4 2020-12-01 19:12:58 -08:00
yyforyongyu
368301866e
wtxmgr: update tests to use db timeout param 2020-11-06 23:58:09 +08:00
Olaoluwa Osuntokun
186417b824
wtxmgr: update to walletdb v1.3.2 2020-06-15 12:08:53 -07:00
Wilmer Paulino
c42130075c
wtxmgr: introduce persistent output leases
This commit allows for the ability to lease an output to a particular ID
for a limited amount of time, ensuring that no other processes can use
said output for their coin selection needs. An output can either be
unlocked manually, or lazily whenever required.
2020-05-28 17:53:49 -07:00
carla
ab19740c94
wtxmgr: extract label deserialization into separate function
Requrired so that we can use the same logic in dropwtxmgr.
2020-05-28 09:07:31 +02:00
carla
4ec3fb4928
wtxmgr: separate PutTxLabel into store-independent function
Separate out the logic we use to write labels so that it can be used
in dropwtxmgr to re-add labels if we want to keep them when we drop the
rest of the db.
2020-05-27 14:54:25 +02:00
carla
f852d2f991
wtxmgr: add transaction label to TxDetails 2020-05-11 15:18:15 +02:00
carla
9aed49070d
wtxmgr: update rangeBlockTransactions to use minedTxDetails
Code is duplicated across these two functions, so update
rangeBlockTransactions to use minedTxDetails. When iterating through
a block, we do have the block metadata already (which is looked up by
minedTxDetails). This change can be further optimized to split
minedTxDetails into minedTxDetails and minedTxDetailsWithoutBlock to
reduce this redundancy.
2020-05-11 15:18:06 +02:00
carla
50869085eb
wtxmgr: add put and fetch functions for optional transaction label
Add and test functions which can be used to write optional transaction
labels to disk in their own bucket. These labels are keyed by txid and
write the labels to disk using-length value encoding scheme. Although
the length field is not required at present, it is added to allow future
extensibility without a migration.

This approach is chosen over adding this information to txRecords,
Because a migration would be required to add a field after the variable
Length serialized tx.

The put label function will overwrite existing labels if called more
than once for the same txid. User side validation of whether we want
to override this label should be performed by calling code. Labels must
be > 0 characters and <= 500 characters (an arbitrarily chosen limit).
2020-05-11 15:16:11 +02:00
Conner Fromknecht
282ee8f09f
wtxmgr: update go.mod to walletdb 1.2.0 2020-01-15 12:40:34 -08:00
Olaoluwa Osuntokun
95064ae858
wtxmgr+build: update all packges to point towards walletdb v1.2.0 2020-01-15 04:51:25 -08:00
Olaoluwa Osuntokun
c49e7ef3ec
Merge pull request #658 from wpaulino/lingering-unconfirmed-input
wtxmgr: remove unconfirmed input reference for confirmed transcation …
2019-11-08 19:18:58 -08:00
Olaoluwa Osuntokun
ef3abfafbc
Merge pull request #655 from breez/fix-re-broadcast-flow
Fix broadcast existing transaction
2019-11-08 19:14:04 -08:00
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
35a7a1a0f6
wtxmgr: create new wtxmgr submodule 2019-09-05 16:57:26 -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
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
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
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
2fb234c68f
wtxmgr: remove old migration logic
In this commit, we remove the old upgrade/migration logic of the
transaction manager as it's been superseded by the new approach using
the migration.Manager interface.
2018-11-05 17:58:16 -08:00
Wilmer Paulino
c523ccd192
wtxmgr/db: remove LatestVersion const in favor of getLatestVersion
In this commit, we can remove the LatestVersion constant as it's no
longer needed. Instead, we'll now define the latest version as the last
entry in the slice of versions previously defined.
2018-11-05 17:58:16 -08:00
Wilmer Paulino
ec1213aeab
wtxmgr/migrations: add migration.Manager implementation
In this commit, we add an implementation of the recently introduced
migration.Manager interface for the transaction manager. With this,
we'll now be able to only expose the things required for the migration
to happen, but have the actual migration logic live at a much higher
level.

There are no existing migrations for the transaction manager, but since
the latest version was already defined as 1, we'll start from there to
be backwards-compatible.
2018-11-05 17:58:16 -08:00
Wilmer Paulino
3bdfb6cc23
wtxmgr/db: define new helpers to set/get store version 2018-11-05 17:58:16 -08:00
Wilmer Paulino
427e497498
wtxmgr/tx_test: extend TestRemoveUnminedTx to check balances
In this commit, we extend TestRemoveUnminedTx to also account for
checking the store's total balance (confirmed and unconfirmed). It
currently ensures that the UTXO state is correct, but as a sanity check,
we'll also ensure that balances are properly updated.
2018-09-20 19:12:34 -07:00
Wilmer Paulino
989a81eb24
wtxmgr/query_test: remove duplicate hash test case
In this commit, we remove the duplicate test case from TestStoreQueries
as we'll no longer allow storing a transaction as unconfirmed if it's
already confirmed.
2018-08-29 17:10:41 -07:00
Wilmer Paulino
4a7f2c1078
wtxmgr/query_test: remove t.Fatal calls within db transactions in TestStoreQueries 2018-08-29 17:10:40 -07:00
Wilmer Paulino
fbe82c3531
wtxmgr: check existing unspent outputs before adding the credit
In this commit, we resolve a lingering bug within the wallet where it's
possible that an output is added as unconfirmed credit after the fact
that it has already confirmed. This would lead to duplicate entries for
the same output within the wallet causing double spend transactions to
be crafted.
2018-08-29 17:10:40 -07:00
Wilmer Paulino
98f65ac943
wtxmgr/tx_test: add test case for duplicate outputs within the store
In this commit, we add a new test case to the wtxmgr store to ensure
that duplicate outputs don't exists within the store. It's possible for
this to happen if an output is marked as unconfirmed credit, then marked
as confirmed once it confirms, and once again marked as unconfirmed. It
can be marked as unconfirmed again due to the backend notifying the
client about this transaction. Ideally this should not happen, but the
root cause is much more involved. As a stop gap, we'll ensure that
outputs can be marked as unconfirmed credits more than once whatsoever.
As is, the test case fails, which proves that this is an issue. A later
commit will resolve this and the test case should pass.
2018-08-29 17:10:39 -07:00
Wilmer Paulino
a71881aed8
wtxmgr/tx_test: move store teardown after error check 2018-08-29 17:10:38 -07:00
Wilmer Paulino
aa826c64cf
wtxmgr: store multiple spending tx hashes for outpoints
In this commit, we modify the way we store spending transaction hashes
for unconfirmed spends. Now, rather than only keeping track of one
possible unconfirmed spend, we track multiple in order to ensure we
properly handle transaction replacements, like in the case of RBF,
double spends, etc. With this in, the double spent tests recently added
should now pass.
2018-07-16 13:39:53 -07:00
Wilmer Paulino
ff646086b7
wtxmgr: split moveMinedTx into deleteUnminedTx and updateMinedBalance
In this commit, we slightly refactor the existing moveMinedTx method
and split it into two: deleteUnminedTx and updateMinedBalance. We do
this as moveMinedTx is no longer moving the transaction from the unmined
bucket to the mined, instead it just removes it from the unmined bucket.
2018-07-16 13:39:52 -07:00