File tree Expand file tree Collapse file tree
app/src/main/java/to/bitkit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ fun LnurlPayData.isFixedAmount(): Boolean =
2828 * For variable-amount requests the user-selected sat amount is converted to msats.
2929 */
3030fun LnurlPayData.callbackAmountMsats (userSats : ULong? = null): ULong =
31- if (isFixedAmount()) minSendable else (userSats ? : minSendableSat()) * 1000u
31+ if (isFixedAmount()) minSendable else (userSats ? : minSendableSat()) * MSat . PER_SAT
3232
3333fun LnurlWithdrawData.minWithdrawableSat (): ULong = MSat (minWithdrawable ? : 0u ).ceil()
3434fun LnurlWithdrawData.maxWithdrawableSat (): ULong = MSat (maxWithdrawable).floor()
Original file line number Diff line number Diff line change @@ -11,9 +11,13 @@ package to.bitkit.models
1111@JvmInline
1212value class MSat (val value : ULong ) {
1313
14+ companion object {
15+ const val PER_SAT : ULong = 1000u
16+ }
17+
1418 /* * Round up to the nearest whole sat. Use for payment/display amounts. */
15- fun ceil (): ULong = (value + 999u ) / 1000u
19+ fun ceil (): ULong = (value + PER_SAT - 1u ) / PER_SAT
1620
1721 /* * Truncate sub-sat remainder. Use for fees and upper bounds. */
18- fun floor (): ULong = value / 1000u
22+ fun floor (): ULong = value / PER_SAT
1923}
Original file line number Diff line number Diff line change @@ -361,7 +361,9 @@ private fun ChannelsSection(
361361 )
362362 ChannelDetailRow (
363363 title = stringResource(R .string.lightning__inbound_htlc_max),
364- value = " ₿ ${(channel.inboundHtlcMaximumMsat?.let { MSat (it).floor() } ? : 0u ).formatToModernDisplay()} " ,
364+ value = " ₿ ${
365+ (channel.inboundHtlcMaximumMsat?.let { MSat (it).floor() } ? : 0u ).formatToModernDisplay()
366+ } " ,
365367 )
366368 ChannelDetailRow (
367369 title = stringResource(R .string.lightning__inbound_htlc_min),
You can’t perform that action at this time.
0 commit comments