fix: avoid msat truncation when paying invoices with built-in amounts#879
Open
ben-kaufman wants to merge 2 commits intomasterfrom
Open
fix: avoid msat truncation when paying invoices with built-in amounts#879ben-kaufman wants to merge 2 commits intomasterfrom
ben-kaufman wants to merge 2 commits intomasterfrom
Conversation
Bump bitkit-core to v0.1.56 which rounds up sub-satoshi invoice amounts. Additionally, stop overriding the amount for invoices that already have one. Pass null so LDK uses the invoice's native msat precision instead of our truncated sats value converted back to msat. Only pass the amount for zero-amount invoices where the user specifies it. Closes #877
| // When the invoice has a built-in amount, pass null so LDK uses the | ||
| // invoice's native msat precision (avoids truncation to whole sats). | ||
| val paymentAmount = if (decodedInvoice.amountSatoshis > 0uL) null else amount | ||
| // For display/UI purposes, use the invoice amount (in sats) when available. |
There was a problem hiding this comment.
CLAUDE.md compliance: Comments should not be added inside private functions.
From CLAUDE.md: "NEVER add code comments to private functions, classes, etc"
These two new comments are inside private suspend fun proceedWithPayment():
bitkit-android/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
Lines 1758 to 1764 in e16b3fa
Consider removing the inline comments — the logic is self-evident from the variable names (paymentAmount vs displayAmountSats).
Suggested change
| // For display/UI purposes, use the invoice amount (in sats) when available. | |
| val paymentAmount = if (decodedInvoice.amountSatoshis > 0uL) null else amount | |
| val displayAmountSats = decodedInvoice.amountSatoshis.takeIf { it > 0uL } ?: amount ?: 0uL |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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
nullso LDK uses the invoice's native msat precision instead of our truncated sats value converted back to msatTest plan
lnd.addInvoice({ valueMsat })using amounts222538,222222,500500msatDepends on synonymdev/bitkit-core#85
Closes #877
🤖 Generated with Claude Code