fix: report CCH receive amount including fee#1547
Open
jjyr wants to merge 1 commit into
Open
Conversation
jjyr
marked this pull request as ready for review
July 10, 2026 11:38
Contributor
|
lgtm |
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.
Summary
receive_btcstore and report the actual incoming Lightning amount, including the CCH feeRoot cause
The
receive_btcflow correctly created a Lightning hold invoice forprincipal + CCH fee, but persisted only the outgoing Fiber principal inCchOrder.amount_sats. The RPC conversion returned that stored value unchanged even though the API contract definesamount_satsas the amount required to pay, including the fee.A direct replacement with the total would also make the outgoing Fiber fee-rate calculation use the wrong denominator, reducing the effective route-fee allowance. This change therefore derives the outgoing principal from the signed Fiber invoice.
Compatibility
Historical ReceiveBTC orders are normalized from their persisted incoming invoice rather than by blindly adding
fee_sats. This preserves orders created before Lightning invoices started including the CCH fee while correcting orders affected by this issue. The serialized order layout is unchanged.Validation
TDD regression evidence:
test_get_receive_btc_legacy_order_reports_incoming_invoice_amountfailed with stored98000versus required100000cargo nextest run -p fnn -p fiber-bin receive_btc— 21 passedcargo nextest run -p fnn -p fiber-bin cch::tests— 126 passedcargo clippy --all-targets --all-features -p fnn -p fiber-bin -- -D warningscargo fmt --all -- --checkgit diff --checkCloses #1499