fix: use fast fee for savings transfer#1091
Open
piotr-iohk wants to merge 4 commits into
Open
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Greptile SummaryThis PR updates savings-to-spending transfers to use fast on-chain fees. The main changes are:
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| app/src/main/java/to/bitkit/viewmodels/TransferViewModel.kt | Uses fast fees, reserves one mining fee when sizing transfers, and guards send-all funding against underpayment. |
| app/src/test/java/to/bitkit/viewmodels/TransferViewModelTest.kt | Adds coverage for fee reservation, estimation fallback, dust draining, retry draining, and underpayment prevention. |
| changelog.d/next/1091.fixed.md | Documents the updated fee selection, maximum sizing, and wallet-drain behavior. |
Reviews (2): Last reviewed commit: "fix: avoid double mining fee on max tran..." | Re-trigger Greptile
piotr-iohk
marked this pull request as draft
July 17, 2026 10:34
Co-authored-by: Cursor <cursoragent@cursor.com>
jvsena42
requested changes
Jul 17, 2026
| /** Pays for the order and start watching it for state updates */ | ||
| fun onTransferToSpendingConfirm(order: IBtOrder, speed: TransactionSpeed? = null) { | ||
| @Suppress("LongMethod") | ||
| fun onTransferToSpendingConfirm(order: IBtOrder, speed: TransactionSpeed = TransactionSpeed.Fast) { |
Member
There was a problem hiding this comment.
Suggested change
| fun onTransferToSpendingConfirm(order: IBtOrder, speed: TransactionSpeed = TransactionSpeed.Fast) { | |
| fun onTransferToSpendingConfirm(order: IBtOrder) { |
A custom speed is never set anywhere, could remove this parameter
Comment on lines
236
to
237
| val shouldUseSendAll = | ||
| expectedChange >= 0 && expectedChange < TRANSFER_SEND_ALL_THRESHOLD_SATS |
Member
There was a problem hiding this comment.
nit: could apply a small refactor converting this to a range check
Comment on lines
+238
to
+239
| val maxSendable = | ||
| if (sendAllFee >= spendableBalance) 0uL else spendableBalance - sendAllFee |
Member
There was a problem hiding this comment.
use .safe() here. It has this clamp-to-zero internal logic
Comment on lines
+448
to
+449
| val availableAmount = | ||
| if (miningFee >= spendable) 0uL else spendable - miningFee |
| ).onFailure { error -> | ||
| // Match iOS: if fixed send fails (e.g. coin selection), drain only when the | ||
| // drain output still covers order.feeSat — never underpay by emptying the wallet. | ||
| if (maxSendable >= order.feeSat) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1034
This PR makes savings → spending channel funding use a faster on-chain fee rate, matching the “~10 minutes” copy and iOS behavior.
Description
multi_address_2).Preview
N/A
QA Notes
Manual Tests
regression:Transfer → Spending with a partial amount well below balance: still funds with a normal (non-drain) send when change is above dust.Automated Checks
TransferViewModelTest.kt.just test file TransferViewModelTest.multi_address_2should pass once this lands on the resolved e2e branch.Made with Cursor