Skip to content

fix(history): count a received silent payment's confirmations from its block - #229

Open
coolstack-coder wants to merge 1 commit into
CypherCommons:masterfrom
coolstack-coder:fix/sp-incoming-confirmations
Open

coolstack-coder wants to merge 1 commit into
CypherCommons:masterfrom
coolstack-coder:fix/sp-incoming-confirmations

Conversation

@coolstack-coder

Copy link
Copy Markdown

Problem

getTransactions() lists every received silent payment with confirmations: 7 (// FIXME: dont assume stuff). Two user-visible effects:

  • A payment confirmed one block ago shows as settled: the list skips "1 conf" and details shows "6+".
  • A payment still in the mempool, added by Track a payment (scanByTxid, height 0), shows as confirmed instead of pending.

Fix

  • Derive confirmations from the UTXO height against lastScannedBlock: 0 at height 0, otherwise max(tip - height + 1, 1). The floor covers a payment found by scanByTxid in a block the range scan hasn't reached yet.
  • Compare confirmations in TransactionListItem's memo, so a row on screen updates as the count rises.

Outgoing SP-only spends keep their own count. #183 and #170 already handle those.

Tests

New cases in tests/unit/bip352.test.ts cover the scan tip, the mempool and a block past the scan tip. They fail on master and pass here. tsc and eslint are clean.

sendDetails.test.tsx › "fills in a payment request opened from home" fails on master too, so it's unrelated to this change.

…s block

An incoming silent payment was always listed with 7 confirmations. A
payment that had just confirmed read as settled ("6+" in details, no
"1 conf" in the list), and one still in the mempool, found with Track a
payment, read as confirmed rather than pending.

Confirmations now come from the UTXO's height against the scan tip:
0 while the payment is unconfirmed, and at least 1 once it has a block,
even if the scan hasn't reached that block yet. The list row re-renders
when the count changes, so it doesn't stay stuck on the first value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant