We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a84e332 commit a9ae186Copy full SHA for a9ae186
1 file changed
app/src/main/java/to/bitkit/models/MSat.kt
@@ -0,0 +1,19 @@
1
+package to.bitkit.models
2
+
3
+/**
4
+ * A wrapper for millisatoshi [ULong] values that provides explicit sat conversions.
5
+ *
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].
10
+ */
11
+@JvmInline
12
+value class MSat(val value: ULong) {
13
14
+ /** Round up to the nearest whole sat. Use for payment/display amounts. */
15
+ fun ceil(): ULong = (value + 999u) / 1000u
16
17
+ /** Truncate sub-sat remainder. Use for fees and upper bounds. */
18
+ fun floor(): ULong = value / 1000u
19
+}
0 commit comments