-
Notifications
You must be signed in to change notification settings - Fork 2
fix: avoid msat truncation when paying invoices with built-in amounts #512
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f7fc9ae
fix: avoid msat truncation when paying invoices with built-in amounts
ben-kaufman 548dcb1
chore: add changelog entry for msat fix
ben-kaufman 8f01a90
Merge branch 'master' into fix/msat-invoice-precision
piotr-iohk 617ecdc
fix: preserve msat precision for LNURL pay and withdraw callbacks
ben-kaufman 0723c7e
chore: update changelog with LNURL msat fix
ben-kaufman ef88089
fix: use msat-precision invoices for fixed-amount LNURL withdraw
ben-kaufman 851826f
fix: use satsCeil for LNURL display amounts and revert LDK Node rev
ben-kaufman 91a35c5
fix: use ceiling division for PaymentDetails.amountSats
ben-kaufman 36af4da
fix: use ceiling for received payment notification amount
ben-kaufman fd1d1f8
fix: restore LDK Node rev to v0.7.0-rc.36 and add LightningAmountConv…
ovitrif ec303d7
fix: link CoreBluetooth for BitkitCore iOS builds
ovitrif 0e32c43
Merge branch 'master' into fix/msat-invoice-precision
ovitrif 6bf7773
fix: add LightningAmountConversion to BitkitTests target
ovitrif c72b745
fix: add LNURL amount extensions and fix sub-sat rounding checks
ovitrif 1274929
fix: show amount on LNURL quickpay screen
ovitrif e2d0056
chore: enforce single changelog entry per PR rule
ovitrif c17ee16
fix: show send-success amount from lnurl and invoices
piotr-iohk b987e7c
Merge pull request #514 from synonymdev/fix/lnurl-amount-rounding
ovitrif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
3 changes: 1 addition & 2 deletions
3
Bitkit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import BitkitCore | ||
|
|
||
| extension LnurlPayData { | ||
| var minSendableSat: UInt64 { | ||
| LightningAmountConversion.satsCeil(fromMsats: minSendable) | ||
| } | ||
|
|
||
| var maxSendableSat: UInt64 { | ||
| LightningAmountConversion.satsFloor(fromMsats: maxSendable) | ||
| } | ||
|
|
||
| /// True when the LNURL-pay endpoint specifies a single exact amount. | ||
| /// | ||
| /// Also covers the sub-sat edge case where `minSendable` and `maxSendable` | ||
| /// differ in their sub-sat fraction but map to the same (or inverted) sat | ||
| /// range after rounding, e.g. `min=222222, max=222538` → `minSat=223, maxSat=222`. | ||
| var isFixedAmount: Bool { | ||
| minSendable == maxSendable || (minSendable > 0 && minSendableSat > maxSendableSat) | ||
| } | ||
|
|
||
| /// Returns the amount in millisatoshis for the LNURL-pay callback. | ||
| /// | ||
| /// For fixed-amount requests the original msat value is returned verbatim, | ||
| /// avoiding precision loss from the msat→sat→msat round-trip. | ||
| /// For variable-amount requests the user-selected sat amount is converted to msats. | ||
| func callbackAmountMsats(userSats: UInt64? = nil) -> UInt64 { | ||
| if isFixedAmount { | ||
| return minSendable | ||
| } | ||
| return (userSats ?? minSendableSat) * Env.msatsPerSat | ||
| } | ||
| } | ||
|
|
||
| extension LnurlWithdrawData { | ||
| var minWithdrawableSat: UInt64 { | ||
| LightningAmountConversion.satsCeil(fromMsats: minWithdrawable ?? 0) | ||
| } | ||
|
|
||
| var maxWithdrawableSat: UInt64 { | ||
| LightningAmountConversion.satsFloor(fromMsats: maxWithdrawable) | ||
| } | ||
|
|
||
| /// True when the LNURL-withdraw endpoint specifies a single exact amount, | ||
| /// including the sub-sat edge case where rounding causes `min > max` in whole sats. | ||
| var isFixedAmount: Bool { | ||
| let min = minWithdrawable ?? 0 | ||
| return min == maxWithdrawable || (min > 0 && minWithdrawableSat > maxWithdrawableSat) | ||
| } | ||
| } |
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.