Skip to content

fix(sell-bitbox): make deposit retry idempotent — never re-broadcast a sent tx#682

Open
joshuakrueger-dfx wants to merge 1 commit into
RealUnitCH:developfrom
joshuakrueger-dfx:joshua/fix-657-p4bb1-deposit-idempotent
Open

fix(sell-bitbox): make deposit retry idempotent — never re-broadcast a sent tx#682
joshuakrueger-dfx wants to merge 1 commit into
RealUnitCH:developfrom
joshuakrueger-dfx:joshua/fix-657-p4bb1-deposit-idempotent

Conversation

@joshuakrueger-dfx
Copy link
Copy Markdown
Collaborator

Addresses Issue #657 — Part 4, finding BB1 (HIGH, financial).

Problem

_broadcastDepositAndConfirm broadcast the deposit tx and confirmed the payment in one try/catch, emitting SellBitboxDepositRetry on any failure. When the broadcast succeeded but the confirmation failed, retryDeposit re-ran the whole helper and re-broadcast the already-on-chain deposit transaction — a duplicate send and a perpetual retry loop.

Fix

Split broadcast from confirm and carry the resulting txHash in the retry state:

  • broadcast failure → retry may broadcast again (broadcastTxHash == null)
  • confirm failure after a successful broadcast → retry confirms only using the stored txHash, never re-broadcasting (broadcastTxHash != null)

Tests (RED→GREEN, proven)

confirm-only retry asserts verifyNever(broadcastTransaction) after a confirm failure; broadcast-failure retry still re-broadcasts. The RED case fails on the old code (verified). Full sell-bitbox suite 68/68 green, flutter analyze clean.

🤖 Big Brother fleet flagged + operator hand-finish. Ref #657.

…a sent tx

_broadcastDepositAndConfirm broadcast the deposit tx and then confirmed the
payment in one try/catch, emitting SellBitboxDepositRetry on ANY failure. When
the broadcast succeeded but the confirmation failed, retryDeposit re-ran the
whole helper and re-broadcast the already-on-chain deposit transaction — a
duplicate send and a perpetual retry loop.

Split broadcast from confirm and carry the resulting txHash in the retry state:
- broadcast failure → retry may broadcast again (broadcastTxHash == null)
- confirm failure after a successful broadcast → retry confirms ONLY using the
  stored txHash, never re-broadcasting (broadcastTxHash != null)

Regressions: sell_bitbox_cubit_test.dart (confirm-only retry asserts
verifyNever(broadcastTransaction); broadcast-failure retry still broadcasts) +
sell_bitbox_state_test.dart (broadcastTxHash in props).

Issue RealUnitCH#657 — Part 4, finding BB1 (HIGH, financial).
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