lightning-kmp icon indicating copy to clipboard operation
lightning-kmp copied to clipboard

Get transaction's confirmation information (including block timestamp)

Open robbiehanson opened this issue 1 year ago • 3 comments

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.

robbiehanson avatar Jul 19 '23 20:07 robbiehanson

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 avatar Aug 14 '23 15:08 robbiehanson

@robbiehanson you can probably rebase that and do it more easily now!

t-bast avatar Sep 28 '23 09:09 t-bast

@robbiehanson if you want this feature, you can rebase now and we should be able to integrate this.

t-bast avatar Sep 18 '24 13:09 t-bast