refactor: extract Bip21Parser and PaymentRecord.fromPayment

This commit is contained in:
2026-06-06 16:29:43 +02:00
parent ca2273f3e4
commit f73f7f348f
3 changed files with 53 additions and 40 deletions
@@ -175,6 +175,32 @@ data class PaymentRecord(
val amountSat: Long get() = kotlin.math.abs(amountMsat) / 1000L
val feeSat: Long get() = kotlin.math.abs(feeMsat) / 1000L
val isOutgoing: Boolean get() = amountMsat < 0
companion object {
fun fromPayment(
paymentHash : String,
amountSats : Long,
feeSats : Long?,
bolt11 : String?,
memo : String?,
pubkey : String?,
alias : String?,
): PaymentRecord = PaymentRecord(
paymentHash = paymentHash,
checkingId = paymentHash,
amountMsat = -(amountSats * 1_000L),
feeMsat = (feeSats ?: 0L) * 1_000L,
memo = memo,
time = (System.currentTimeMillis() / 1_000L).toString(),
status = "complete",
bolt11 = bolt11,
pending = false,
preimage = null,
extra = null,
pubkey = pubkey,
alias = alias,
)
}
}
data class PaymentExtra(