Skip to content

Commit 1e04e86

Browse files
ovitrifclaude
andcommitted
fix: address review comments
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 15889b8 commit 1e04e86

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

app/src/main/java/to/bitkit/ext/Lnurl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
*/
3030
fun 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

3333
fun LnurlWithdrawData.minWithdrawableSat(): ULong = MSat(minWithdrawable ?: 0u).ceil()
3434
fun LnurlWithdrawData.maxWithdrawableSat(): ULong = MSat(maxWithdrawable).floor()
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package 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
129
value 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
}

app/src/main/java/to/bitkit/ui/NodeInfoScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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),

0 commit comments

Comments
 (0)