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 11package to.bitkit.models
22
33/* *
4- * A wrapper for millisatoshi [ULong] values that provides explicit sat conversions.
4+ * A non-boxing wrapper for millisatoshi [ULong] values that provides explicit sat conversions.
55 *
6- * Eliminates scattered `/ 1000u` and `(x + 999u) / 1000u` patterns by encoding
7- * the rounding intent directly in the API: [ceil] rounds up, [floor] truncates.
8- *
9- * Zero runtime overhead — this is an [inline value class][JvmInline].
6+ * Encapsulates the rounding intent directly in the API: [ceil] rounds up, [floor] truncates.
107 */
118@JvmInline
129value class MSat (val value : ULong ) {
1310
11+ companion object {
12+ const val PER_SAT : ULong = 1000u
13+ }
14+
1415 /* * Round up to the nearest whole sat. Use for payment/display amounts. */
15- fun ceil (): ULong = (value + 999u ) / 1000u
16+ fun ceil (): ULong = (value + PER_SAT - 1u ) / PER_SAT
1617
1718 /* * Truncate sub-sat remainder. Use for fees and upper bounds. */
18- fun floor (): ULong = value / 1000u
19+ fun floor (): ULong = value / PER_SAT
1920}
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