Skip to content

Commit

Permalink
Merge pull request #512 from pinheadmz/finalize2
Browse files Browse the repository at this point in the history
txdb: fix lockedUnconfirmed if FINALIZE is inserted with block
  • Loading branch information
chjj committed Nov 22, 2020
2 parents 25173cf + 0e7865c commit dd2cf3c
Show file tree
Hide file tree
Showing 2 changed files with 255 additions and 85 deletions.
8 changes: 6 additions & 2 deletions lib/wallet/txdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,10 +960,14 @@ class TXDB {

// FINALIZE is a special case: locked coins _leave_ the wallet.
if (tx.output(i) && tx.covenant(i).isFinalize()) {
if (!block)
if (!block) {
state.ulocked(path, -tx.outputs[i].value);
else
} else {
state.clocked(path, -tx.outputs[i].value);
// This is the first time we've seen this tx and it is in a block
// (probably from a rescan). Update unconfirmed locked balance also.
state.ulocked(path, -tx.outputs[i].value);
}
}

if (!block) {
Expand Down

0 comments on commit dd2cf3c

Please sign in to comment.