-
Notifications
You must be signed in to change notification settings - Fork 56
feat(platform-wallet): return the exact network fee from send_payment #4095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -364,7 +364,7 @@ struct SendDashPayPaymentSheet: View { | |
| // useful to pass. The Rust-side | ||
| // `PaymentEntry.memo` slot stays available for | ||
| // future local-note wiring. | ||
| let txid = try await wallet.sendDashPayPayment( | ||
| let (txid, _) = try await wallet.sendDashPayPayment( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 Nitpick: In-repo reference implementation discards the newly-exposed fee This PR's stated motivation is that wallets could previously only re-estimate the fee after the fact. source: ['claude'] |
||
| fromIdentityId: senderIdentity.identityId, | ||
| toContactIdentityId: contact.identityId, | ||
| amountDuffs: duffs, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Blocking: Piped-through fee is a size-based recomputation, not the actual inputs-minus-outputs fee
I traced this through to
TransactionBuilder::build_signedin the pinnedkey-walletcrate (rev1ee1c94,key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs). The value now surfaced by this PR isfee_rate.calculate_fee(encoded_size(&signed_tx))— a fee-rate × final-serialized-size recomputation done after signing.That is provably not the same quantity as the fee the broadcast transaction actually pays. During
assemble_unsigned, the change output (if any) is sized astotal_input - total_output - selection.estimated_fee, so the true on-chain fee (inputs minus outputs) always equalsselection.estimated_fee— a value computed before signing from an estimated per-input size (148 bytes) and the coin-selector's dust-folding rules, not from the final signed size. The two numbers only match by coincidence:change_amountfalls below the dust threshold,accumulate_coins_with_sizefolds the dust intoestimated_fee(total_value - target_amount) so the true paid fee is inflated by up to 546 duffs.build_signed's returned value is oblivious to this — it just does size × rate — so it undercounts the actual fee by exactly the folded-in dust amount whenever no change output is created.This PR's whole purpose is to let wallets show the exact fee instead of re-estimating after the fact — but the plumbed-through value inherits an estimate that's decoupled from what the change output / dust folding actually paid. Since
send_paymentpreviously discarded this value entirely (_fee), this inaccuracy had no consumer before; this PR is what turns it into an externally-relied-upon contract, which is why it's in scope here even though the root computation lives in the externalkey-walletcrate.source: ['codex']