Skip to content

feat(fees): working network fee selection for sell and pay - #2536

Draft
BullishNode wants to merge 1 commit into
fix/sell-hardeningfrom
fix/fee-selection
Draft

feat(fees): working network fee selection for sell and pay#2536
BullishNode wants to merge 1 commit into
fix/sell-hardeningfrom
fix/fee-selection

Conversation

@BullishNode

Copy link
Copy Markdown
Contributor

⚠️ Requires emulator/device review before merge — draft until verified. Test: on a bitcoin-wallet sell (and pay), tapping "Network fee priority" opens the fee dialog; the row shows the actual selection; the summary network fee updates with the choice; and ideally one real staging sell at economy/custom rate confirming the broadcast transaction pays the selected sat/vB. This is the money path — the riskiest PR of the set.

Stacked on #2535 (fix/sell-hardening) — review only the last commit. After #2535 merges, this retargets to main. Must merge AFTER #2534 (pay-status PR): that branch constructs sendPaymentConfirmed event params this PR removes — the rebase reconciles two one-line call sites (pay_send_payment_screen.dart, test/features/pay/pay_bloc_test.dart), already verified on the integration branch.

Problem (#2521)

The "Network fee priority" row on sell and pay confirmation screens was a debugPrint stub with a // TODO; every transaction paid the fastest rate end-to-end — the bloc ignored the fee selection its confirm event already declared.

Changes

  • SellBloc/PayBloc implement the shared fee modal's FeeModalViewState/FeeModalActions ports, following SendCubit semantics: presets, custom sat/vB or absolute fees with arm/disarm/finalize, epoch-guarded previews, relay-floor gate
  • The row opens the shared FeeOptionsModal and displays the committed selection; the summary fee reprices from a real PSBT built at the selected rate
  • Confirm prepares/signs/broadcasts at the committed selection. Unlike send/swap, preview PSBTs are display-only: sell/pay rebuild at broadcast time because a price-lock refresh can move the order's payin amount. The built fee is re-asserted against the relay floor before signing
  • Fee editing locks while confirming or once the payin is broadcast; every post-await emit merges into live state — a recalculation or preview landing after the flow moved on emits nothing (reviewer-caught blocker, regression-tested in both blocs)
  • Previews price against the order's real payin address; Liquid payins keep no fee row

Validation

Sell suite 13/13, pay suite 8/8 (selected-preset-reaches-prepare, custom-fee path, below-floor rollback, events-inert-once-latched, preset previews, post-success recalc emits nothing — the money-path tests capture every networkFee handed to prepare and assert it equals the picked tier); analyze clean; reviewed with a verification pass (1 blocker + 2 should-fixes applied).

Closes #2521

The Network fee priority row on the sell and pay confirmation screens
was a debugPrint stub and every transaction paid the fastest rate.

- SellBloc and PayBloc implement the shared fee modal's view-state and
  actions ports, following SendCubit's semantics: preset selection,
  custom sat/vB or absolute fees with arm/disarm/finalize, epoch-guarded
  previews, and a relay-floor gate on finalize.
- The row opens the shared FeeOptionsModal and shows the committed
  selection; the summary fee reprices from a real PSBT built at the
  selected rate on every change.
- Confirm prepares, signs and broadcasts at the committed selection.
  Unlike send and swap, the preview PSBT is display-only: sell and pay
  rebuild at broadcast time because a price-lock refresh can move the
  order's payin amount. The built fee is re-asserted against the relay
  floor before signing.
- Fee editing locks while a confirmation is in flight or the payin is
  broadcast; handlers re-read live state so queued events are dropped,
  and every post-await emit merges into live state - a recalculation
  or preview landing after the flow moved on emits nothing instead of
  resurrecting a pre-broadcast state.
- Previews price against the order's real payin address.

Closes #2521
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