Skip to content

key-wallet: confirm_transaction should refresh TransactionRecord derived metadata on gap-limit rescan #714

@QuantumExplorer

Description

@QuantumExplorer

Context

Surfaced by CodeRabbit during review of #711. Pre-existing behavior — #711 is a structural-only split and moves this code unchanged.

Problem

ManagedCoreFundsAccount::confirm_transaction is documented to handle "potentially new address matches from gap limit rescans," but for an already-recorded transaction it only updates context and runs update_utxos. The derived fields on the stored TransactionRecordnet_amount, direction, and the per-input/output role flags — are computed once at record_transaction time and never refreshed.

Consequence: a transaction that was first recorded with a partial account_match (e.g. before a gap-limit rescan widened the matching address set) will keep stale wallet metadata even after the rescan re-confirms it.

Suggested fix

When confirm_transaction sees an existing record and the incoming account_match differs from what was used the first time, recompute the derived metadata (re-running the same logic as record_transaction or replacing the entry while preserving transaction_type and context), then continue with the UTXO update.

Files

  • key-wallet/src/managed_account/managed_core_funds_account.rs (confirm_transaction, record_transaction)

Original review thread: #711 (review comment 3178371385)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions