lightning-kmp
lightning-kmp copied to clipboard
Get transaction's confirmation information (including block timestamp)
The OnChainOutgoingPayment
has a confirmedAt
timestamp:
sealed class OnChainOutgoingPayment : OutgoingPayment() {
abstract override val id: UUID
abstract val miningFees: Satoshi
abstract val channelId: ByteVector32
abstract val txId: ByteVector32
abstract override val createdAt: Long
abstract val confirmedAt: Long?
abstract val lockedAt: Long?
}
Currently this is being set (in Phoenix) by monitoring the blockchain for unconfirmed tx's, and setting confirmedAt = currentTimestampMillis()
. However, the timestamp isn't ideal.
It's usually the case that a user sends an on-chain payment, and then backgrounds the app. (Which means the socket connections are closed on iOS.) Only when the user returns to the app (possibly days later) do we realize that the payment was mined, and we set confirmedAt = currentTimestampMillis()
. Which, in this example, is days later than when the tx was actually mined.
I'm proposing we add a method like this:
data class ConfirmationStatus(
val minedAtBlockHeight: Int,
val currentConfirmationCount: Int,
val firstBlock: BlockHeader // includes timestamp of when block was mined
)
suspend fun IElectrumClient.getConfirmationStatus(txId: ByteVector32): ConfirmationStatus?
Using this function, we'll be able to set the confirmedAt
property to the timestamp of the block, which would be more accurate.
this will be cleaner to do on top of https://github.com/ACINQ/lightning-kmp/pull/512
Sounds good. Let's wait for 512, and then revisit.
@robbiehanson you can probably rebase that and do it more easily now!
@robbiehanson if you want this feature, you can rebase now and we should be able to integrate this.