commonMain.fr.acinq.lightning.payment.PaymentRequest.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lightning-kmp-jvm Show documentation
Show all versions of lightning-kmp-jvm Show documentation
A Kotlin Multiplatform implementation of the Lightning Network
package fr.acinq.lightning.payment
import fr.acinq.bitcoin.ByteVector32
import fr.acinq.bitcoin.PublicKey
import fr.acinq.bitcoin.utils.Try
import fr.acinq.lightning.Features
import fr.acinq.lightning.MilliSatoshi
import fr.acinq.lightning.utils.currentTimestampSeconds
sealed class PaymentRequest {
abstract val amount: MilliSatoshi?
abstract val paymentHash: ByteVector32
abstract val nodeId: PublicKey
abstract val features: Features
abstract fun isExpired(currentTimestampSeconds: Long = currentTimestampSeconds()): Boolean
abstract fun write(): String
companion object {
fun read(input: String): Try =
if (input.startsWith(Bolt12Invoice.hrp, ignoreCase = true)) {
Bolt12Invoice.fromString(input).map { it }
} else {
Bolt11Invoice.read(input).map { it }
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy