bdk icon indicating copy to clipboard operation
bdk copied to clipboard

User should have a way to know that a transaction changed its state

Open danielabrozzoni opened this issue 1 year ago • 3 comments

Right now if users want to know if a transaction was removed from the chain, or dropped from the mempool, they need to compare two versions of list_unspent obtained in different moments.

We should investigate if we can provide some method to do this on our end.

The use case for this is: a user just synced with the backend, wants to know which transactions disappeared.

Edit: this can be further generalized to be a way to notify users when transactions/utxos change state (confirmation, drop from mempool, reorg, but also replacement, etc)

danielabrozzoni avatar Feb 16 '24 18:02 danielabrozzoni

Right now if users want to know if a transaction was removed from the chain, or dropped from the mempool, they need to compare two versions of list_unspent obtained in different moments.

Module Data type Method(s) to compare state with
bdk_chain UTXOs TxGraph::filter_chain_unspents, TxGraph::try_filter_chain_unspents
bdk_chain Transactions TxGraph::list_chain_txs, TxGraph::try_list_chain_txs
bdk_wallet UTXOs Wallet::list_unspent
bdk_wallet Transactions Wallet::transactions

evanlinjin avatar Feb 18 '24 15:02 evanlinjin

Before introducing a way of notifying users of a state change we should have a way of determining the current state of a transaction more precisely. Right now we only have canonical (confirmed or unconfirmed) or not canonical. This is not enough -- I want to know why a transaction is non-canonical. This is usually a conflict was confirmed or seen more recently.

In terms of listing I think we should have a way of listing all transactions in the order they were first seen (see: https://github.com/bitcoindevkit/bdk/issues/1333) and what the current state of them is. You usually don't want to just forget about a transaction when you've broadcast it. RBF happens infrequently enough it's better to leave it in the app's transaction list and just indicate that the tx was replaced by another.

LLFourn avatar Feb 19 '24 05:02 LLFourn

A potentially big change I think we should push to 2.0 milestone.

notmandatory avatar Mar 20 '24 02:03 notmandatory