Skip to content

Keep stored hash when invalidating a transaction - #720

Merged
rafaelekol merged 1 commit into
masterfrom
fix-missing-tx-metadata
Oct 15, 2026
Merged

rafaelekol merged 1 commit into
masterfrom
fix-missing-tx-metadata

Conversation

@rafaelekol

Copy link
Copy Markdown
Contributor

Fixes the wallet crash NoSuchElementException in Storage.getFullTransactionInfo when the transaction list loads.

Why this approach: the stored hash is authoritative. Rebuilding a stored transaction rehashed it from stored input rows, which a same-outpoint, same-sequence conflict can replace, so the invalidator filed the InvalidTransaction under a hash with no metadata and left the original row behind. Falling back on missing metadata alone would hide the crash but keep the duplicate pending copy, so the migration also finishes the interrupted move.

How to verify: ./gradlew :bitcoincore:connectedDebugAndroidTest on an emulator. InvalidTransactionMetadataTest reproduces the crash on the previous code, builds the broken v19 state and checks that the migration repairs it.

Risky: Migration_19_20 matches the misfiled row to the original by uid; only InvalidTransaction's constructor copies a uid, so a uid in both tables comes only from this bug. Input rows are still keyed without transactionHash, so conflicting transactions can still take over each other's input rows; that is left for a separate change.

A conflicting transaction that spends the same outpoint with the same
sequence replaces the stored input row of the original. Rebuilding the
original from stored rows then rehashed it to a different hash, and the
invalidator saved the InvalidTransaction under that hash, which has no
TransactionMetadata, and left the original row in place. Loading the
transaction list then threw NoSuchElementException.

Transactions loaded from storage now keep their stored hash, the list
tolerates a missing metadata row, and migration 19 to 20 moves already
misfiled invalid transactions back to their real hash by uid and removes
the leftover original.
@rafaelekol
rafaelekol merged commit 8a4715c into master Oct 15, 2026
1 check passed
@rafaelekol
rafaelekol deleted the fix-missing-tx-metadata branch October 15, 2026 08:46
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.

2 participants