Skip to content

Commit da7b603

Browse files
authored
Update Bolt11 test vectors (#293)
We now match the spec once lightning/bolts#898 is merged.
1 parent 9dfee75 commit da7b603

File tree

2 files changed

+61
-23
lines changed

2 files changed

+61
-23
lines changed

src/commonMain/kotlin/fr/acinq/lightning/payment/PaymentRequest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,10 @@ data class PaymentRequest(
248248
fun decodeAmount(input: String): MilliSatoshi? {
249249
val amount = when {
250250
input.isEmpty() -> null
251-
input.last() == 'p' -> MilliSatoshi(input.dropLast(1).toLong() / 10L)
251+
input.last() == 'p' -> {
252+
require(input.endsWith("0p")) { "invalid sub-millisatoshi precision" }
253+
MilliSatoshi(input.dropLast(1).toLong() / 10L)
254+
}
252255
input.last() == 'n' -> MilliSatoshi(input.dropLast(1).toLong() * 100L)
253256
input.last() == 'u' -> MilliSatoshi(input.dropLast(1).toLong() * 100000L)
254257
input.last() == 'm' -> MilliSatoshi(input.dropLast(1).toLong() * 100000000L)

0 commit comments

Comments
 (0)