Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# HSD Release Notes & Changelog

## unreleased

### Wallet changes

- Fixes a bug that ignored the effect of sending or receiving a FINALIZE on a
wallet's `lockedConfirmed` and `lockedUnconfirmed` balance.

## v2.2.0

### Upgrading
Expand Down
42 changes: 42 additions & 0 deletions lib/wallet/txdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,14 @@ class TXDB {
state.coin(path, -1);
state.unconfirmed(path, -coin.value);

// FINALIZE is a special case: locked coins _leave_ the wallet.
Comment thread
pinheadmz marked this conversation as resolved.
if (tx.output(i) && tx.covenant(i).isFinalize()) {
if (!block)
state.ulocked(path, -tx.outputs[i].value);
else
state.clocked(path, -tx.outputs[i].value);
}

if (!block) {
// If the tx is not mined, we do not
// disconnect the coin, we simply mark
Expand Down Expand Up @@ -1157,6 +1165,10 @@ class TXDB {
// been removed on-chain.
state.confirmed(path, -coin.value);

// FINALIZE is a special case: locked coins _leave_ the wallet.
if (tx.output(i) && tx.covenant(i).isFinalize())
state.clocked(path, -tx.outputs[i].value);

await this.removeCredit(b, credit, path);

view.addCoin(coin);
Expand Down Expand Up @@ -1300,6 +1312,15 @@ class TXDB {
state.coin(path, 1);
state.unconfirmed(path, coin.value);

// FINALIZE is a special case: locked coins _leave_ the wallet.
// In this case a TX is erased, adding them back.
if (tx.output(i) && tx.covenant(i).isFinalize()) {
if (!block)
state.ulocked(path, tx.outputs[i].value);
else
state.clocked(path, tx.outputs[i].value);
}

if (block)
state.confirmed(path, coin.value);

Expand Down Expand Up @@ -1499,6 +1520,11 @@ class TXDB {

state.confirmed(path, coin.value);

// FINALIZE is a special case: locked coins _leave_ the wallet.
// In this case a TX is reversed, adding them back.
if (tx.output(i) && tx.covenant(i).isFinalize())
state.clocked(path, tx.outputs[i].value);

// Resave the credit and mark it
// as spent in the mempool instead.
credit.spent = true;
Expand Down Expand Up @@ -1719,6 +1745,14 @@ class TXDB {

break;
}

case types.FINALIZE: {
if (height === -1)
state.ulocked(path, output.value);
else
state.clocked(path, output.value);
break;
}
}
}

Expand Down Expand Up @@ -1792,6 +1826,14 @@ class TXDB {

break;
}

case types.FINALIZE: {
if (height === -1)
state.ulocked(path, -output.value);
else
state.clocked(path, -output.value);
break;
}
}
}

Expand Down
Loading