bdk
bdk copied to clipboard
[Feature request] Add timestamp when transaction has been boardcasted/seen first.
Describe the feature I am creating a tool that does batch payouts at the lowest fee possible. After 24hrs, if not confirmed yet, I want to execute a fee bump. It would be very helpful to have a timestamp when the transactions has been boardcasted/first seen. At the moment, I need to create an additional database for that.
Best regards Severin
I suppose we always "see" a transaction at a certain point and can record it so I think this is doable. I'll keep this in mind for bdk_core.
I will work on this issue.
I will work on this issue.
This is already in-progress with the work on the bdk core redesigned structures. #926 #943
This issue should be fixed in #976, that PR includes the field CanonicalTx.observed_as of type ChainPosition which has a variant Unconfirmed(u64) which encapsulates when it was seen in the mempool.
@SeverinAlexB please checkout current master branch now that #976 is merged and let us know if this gives you what you need.
Thx for merging! @gcomte @danielgranhao one of you guys wanna check? I don't work on that specific project anymore.
Ty for the heads up @SeverinAlexB! We ended up developing an alternative solution so we have no feedback to provide.
@danielgranhao sorry you had to develope an alternative approach for your app, but if you want to take another look at how bdk version 1.0.0-alpha.1 will do it here are some details.
The Wallet::transactions() function now returns an Iterator of CanonicalTx:
https://github.com/bitcoindevkit/bdk/blob/5d1f922b3be026031720f2bbb659b3f10fb29f4e/crates/bdk/src/wallet/mod.rs#L531
And CanonicalTx includes an observed_at field of type ChainPosition which will tell you if your transaction is Confirmed or Unconfirmed. If Confirmed you get which "Anchor" (chain tip) block we last saw it associated with. If Unconfirmed you get the unix timestamp of the last time we saw it in the mempool.
https://github.com/bitcoindevkit/bdk/blob/5d1f922b3be026031720f2bbb659b3f10fb29f4e/crates/chain/src/chain_data.rs#L9
Since this should cover the requested feature I'm closing this issue.