refactor: extract Bip21Parser and PaymentRecord.fromPayment
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user