Skip to content

fix: send at the fee rates confirm showed - #1724

Merged
ovitrif merged 1 commit into
masterfrom
fix/send-confirmed-fee-rates
Oct 28, 2026
Merged

ovitrif merged 1 commit into
masterfrom
fix/send-confirmed-fee-rates

Conversation

@ovitrif

@ovitrif ovitrif commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1722

Description

  • Passes the send flow's fee rates (SendUiState.feeRates) from AppViewModel.sendOnchain to LightningRepo.sendOnChain, so the broadcast pays the rate the Confirm screen showed. Before, feeRates was left null and the repo fetched fresh rates at swipe time; if Blocktank's rates moved between review and swipe, the transaction paid a different rate from the one the user approved. When the send flow has no rates, the repo still fetches them as before.
  • iOS has no twin gap: Confirm and the send both read selectedFeeRateSatsPerVByte (comment on the issue).

Out of Scope

  • AppViewModel.kt: the fee sanity check that runs on swipe (calculateTotalFee before the fee warning) still estimates with freshly fetched rates. It only decides whether to warn and never sets the fee paid.

Design

N/A — no UI changes.

Preview

N/A — no user-visible changes.

QA Notes

Setup

Dev build (regtest, staging Blocktank). Fund the wallet's savings address with ./lsp POST /regtest/chain/deposit and mine 3 blocks with ./lsp POST /regtest/chain/mine '{"count":3}', as in journeys/README.md.

Journeys

N/A — not drivable; see Manual Tests.

Manual Tests

  • 1. Open an on-chain send, stay on Confirm while the regtest fee rates change, then swipe → the fee paid (activity details and the sendOnChain: … satsPerVByte= log line) matches the rate and fee Confirm showed — changing fee rates during a send is not in Capabilities

Automated Checks

  • added AppViewModelSendFlowTest.kt — an ordinary send passes the Confirm screen's fee rates to sendOnChain

Evidence

  • f3ec065, dev debug build, Pixel 7 emulator (Android 16), staging regtest: an on-chain send of 50 000 sats at Normal. Confirm showed Normal (₿ 141). The app logged sendOnChain: sats=50000, isTransfer=false, isMaxAmount=false, satsPerVByte=1, and the activity shows a fee of 141. This covers the send path at an unchanged rate.

onchain-send2x.mp4

  • Case 1 passes on f3ec065, same setup, with a debug-only hook in a local copy (never pushed) that makes CoreService.getFees() return every fresh rate ×10 once a flag file exists; the flag was set while Confirm showed Normal (₿ 141). Fresh rates moved to mid=10, and the swipe-time fee check estimated 1405, but the app logged sendOnChain: … satsPerVByte=1 and the activity shows a fee of 141 (result).

case12x.mp4

  • The new test fails without the fix: sendOnChain receives null instead of the Confirm rates.

Gaps

None.

Models used

  • Planning/scoping: claude-opus-5-5 (reasoning: low)
  • Implementation: claude-opus-5-5 (reasoning: low)
  • Review: claude-sonnet-5-5 (reasoning: low)

@ovitrif ovitrif added this to the 3.1.0 milestone Oct 27, 2026
@ovitrif ovitrif self-assigned this Oct 27, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T19:34:37.075729Z f3ec065 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

On-chain sends now pass the fee rates saved in SendUiState to sendOnChain, matching the rates used for Confirm's fee estimate.

  • Ordinary on-chain sends use the fee rates shown on Confirm.

Acknowledged scope: ovitrif explicitly leaves the swipe-time fee warning's fresh-rate estimate out of scope. It does not set the rate paid.

Reviews (1) · Last reviewed commit: "fix: send at the fee rates confirm showe..." · Reviewed by Greptile

@talosmachina talosmachina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings. Passes the send flow's SendUiState.feeRates to LightningRepo.sendOnChain, so the broadcast uses the rates the Confirm fee was computed from instead of a fresh Blocktank fetch at swipe time. Reviewed f3ec065, light tier (1 production line), static: the branch was not built here, CI is the gate.

What I checked, and 4 candidates I ruled out

Read: AppViewModel.sendOnchain, proceedWithOnchainPayment, resetSendState, refreshOnchainSendIfNeeded, refreshOnchainFeeUi, getFeeEstimate; LightningRepo.sendOnChain, calculateTotalFee, getFeeRateForSpeed; CoreService.getFees.
Call sites traced: sendOnchain has one caller (proceedWithOnchainPayment); SendUiState.feeRates is written only in resetSendState.

Ruled out

  • Confirm and broadcast still disagree: the Confirm fee comes from getFeeEstimate -> calculateTotalFee(feeRates = currentState.feeRates), and UTXO preselection uses getFeeRateForSpeed(speed, currentState.feeRates), so all three now read the same snapshot.
  • Null rates when Blocktank was unreachable at flow start: getFeeRateForSpeed falls back to getFees() on null, the same path as before the change.
  • Custom speed: getSatsPerVByteFor is applied to the same FeeRates object on both sides, so a custom rate resolves the same way at Confirm and at send.
  • Other on-chain senders (transfers, CPFP, hardware) losing fresh rates: they call sendOnChain or their own paths directly, not AppViewModel.sendOnchain, and are untouched.

CI: build, build-local and lint pending at review time; Greptile passed.
Test: ordinary send pays the fee rates shown on confirm asserts feeRates = eq(confirmedRates) on sendOnChain.

Merge confidence: 4/5, no findings and the change is covered by the new test, but CI had not finished when this was posted.

Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the reviewer session's run metadata does not report it)

@github-actions

Copy link
Copy Markdown
Contributor

Regtest APK

Built from f3ec065 (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

@jvsena42 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. No findings.

Every on-chain send path now uses the same fee-rate snapshot Confirm showed: ordinary, max, Paykit request, custom fee, hardware wallet, transfer and boost. When no rates are available, the fallback is unchanged. iOS needs no twin, because Confirm and the send both read selectedFeeRateSatsPerVByte there.

Out of scope, pre-existing: the swipe-time sanity warning and maxSendOnchainSats still use a fresh getFees(), and neither platform puts an age limit on the snapshot. The age limit is tracked in #1723.

No device check needed: the change is the fee-rate source, the new unit test in AppViewModelSendFlowTest covers it, and it changes nothing visible unless rates move between Confirm and the swipe.

@ovitrif

ovitrif commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

QA: case 1 passes

Tested f3ec065, dev debug build, Pixel 7 emulator (Android 16), staging regtest. To make the rates move on demand, a local copy had a debug-only hook (never pushed): once a flag file exists, CoreService.getFees() returns every fresh rate ×10. Confirm reads the rates it already loaded, so the hook leaves it unchanged.

  • 1. Open an on-chain send, stay on Confirm while the fee rates change, then swipe → the fee paid matches the rate and fee Confirm showed
    • Confirm showed Normal (₿ 141) at 1 sat/vB. The flag was set while Confirm was open, then the swipe.
    • Fresh rates moved: QA_HOOK getFees returning moved rates 'FeeRates(fast=30, mid=10, slow=10)' instead of 'FeeRates(fast=3, mid=1, slow=1)'. The swipe-time fee check then estimated Calculated fee='1405' … satsPerVByte=10.
    • The send used the Confirm rate: sendOnChain: sats=50000, isTransfer=false, isMaxAmount=false, satsPerVByte=1. Activity details show a fee of 141 (total 50 141).

case12x.mp4

@ovitrif
ovitrif merged commit 3c19f49 into master Oct 28, 2026
22 checks passed
@ovitrif
ovitrif deleted the fix/send-confirmed-fee-rates branch October 28, 2026 07:23
@ovi-reviewer ovi-reviewer Bot mentioned this pull request Oct 28, 2026
3 tasks done
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.

On-chain send can pay a different fee rate than Confirm showed

3 participants