Skip to content

Commit

Permalink
(android) Truncate msat when input is converted fiat->btc
Browse files Browse the repository at this point in the history
See #388
  • Loading branch information
dpad85 committed Jul 26, 2023
1 parent ccce1b4 commit 4ddfd80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ object AmountInputHelper {
onConverted(context.getString(R.string.utils_no_conversion))
null
} else {
val msat = amount.toMilliSatoshi(rate.price)
// convert fiat amount to millisat, but truncate the msat part to avoid issues with
// services/wallets that don't understand millisats. We only do this when converting
// from fiat. If amount is in btc, we use the real value entered by the user.
val msat = amount.toMilliSatoshi(rate.price).truncateToSatoshi().toMilliSatoshi()
if (msat.toUnit(BitcoinUnit.Btc) > 21e6) {
onError(context.getString(R.string.send_error_amount_too_large))
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class LnurlManager(

// SPECS: LN WALLET verifies that the amount in the provided invoice equals the amount previously specified by user.
if (amount != invoice.paymentRequest.amount) {
log.error { "rejecting invoice from $origin with amount_invoice=${invoice.paymentRequest.amount} requested_amount=$amount" }
throw LnurlError.Pay.Invoice.InvalidAmount(origin)
}

Expand Down

1 comment on commit 4ddfd80

@tohrxyz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this ASAP, the bug is annoying

Please sign in to comment.