Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wtxmgr: only remove entry for specified spending transaction #609

Merged
merged 1 commit into from Mar 27, 2019

Conversation

Projects
None yet
2 participants
@wpaulino
Copy link
Contributor

wpaulino commented Mar 23, 2019

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.

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.
@@ -69,13 +69,19 @@ func (s *Store) removeDoubleSpends(ns walletdb.ReadWriteBucket, rec *TxRecord) e

doubleSpendHashes := fetchUnminedInputSpendTxHashes(ns, prevOutKey)
for _, doubleSpendHash := range doubleSpendHashes {
doubleSpendVal := existsRawUnmined(ns, doubleSpendHash[:])
// We'll make sure not to remove ourselves.

This comment has been minimized.

Copy link
@Roasbeef

Roasbeef Mar 27, 2019

Member

This likely could have been included as a distinct commit. As is now, it's easy to miss this amongst everything else going on in this diff.

commitDBTx(t, store, db, func(ns walletdb.ReadWriteBucket) {
t.Helper()

outputs, err := store.UnspentOutputs(ns)

This comment has been minimized.

Copy link
@Roasbeef

Roasbeef Mar 27, 2019

Member

It feels as though we shouldn't even keep around this series of UTXOs where the creation transaction for each output all spend the same input. This just confuses zero conf coin selection (which maybe itself shouldn't really be a thing).

This comment has been minimized.

Copy link
@wpaulino

wpaulino Mar 27, 2019

Author Contributor

Agreed, but zero conf coin selection does have it uses within lnd and higher level applications. Another reason for wanting to keep track of all transactions that spend the same input would be for RBF, although not completely sure how useful that'd be.

@Roasbeef
Copy link
Member

Roasbeef left a comment

LGTM 🎖

@Roasbeef Roasbeef merged commit 8b90263 into btcsuite:master Mar 27, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@wpaulino wpaulino deleted the wpaulino:utxos-after-remove branch Mar 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.