From: valued mammal Date: Thu, 1 May 2025 15:07:40 +0000 (-0400) Subject: Merge bitcoindevkit/bdk#1857: feat(rpc)!: Update `Emitter::mempool` to support `evict... X-Git-Tag: core-0.5.0~1 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/scripts/struct.InsertBlockNotMatchingError.html?a=commitdiff_plain;h=add65bc4f24581bd5f3219bf258746e94ff9cd44;p=bdk Merge bitcoindevkit/bdk#1857: feat(rpc)!: Update `Emitter::mempool` to support `evicted_at` 8513d83a2ef2fe748e9007984187a7f08d256ee6 feat(bitcoind_rpc)!: Reduce friction of `Emitter` API. (志宇) 0a02d26835a41556cf0f6899f97fdb42bf4d0f9d feat(chain): Add convenience conversions for `CanonicalTx` (志宇) d11f6efe8f6feddaa115cde32ebead19f92c2f64 feat(graph): add convenience function for inserting relevant `evicted_at`s (Wei Chen) 28ef7c9a22c4364925329628fa84fd09ecc82e2e refactor(rpc)!: update `mempool` interface and test code (valued mammal) Pull request description: Fixes #1740 ### Description Work for this began as part of #1811, based on this [comment](https://github.com/bitcoindevkit/bdk/pull/1811#discussion_r1945941691). `Emitter::mempool` now returns a `MempoolEvent` which provides the data for tracking `evicted_at`: ``` pub struct MempoolEvent { /// Unemitted transactions or transactions with ancestors that are unseen by the receiver. /// /// To understand the second condition, consider a receiver which filters transactions based on /// whether it alters the UTXO set of tracked script pubkeys. If an emitted mempool transaction /// spends a tracked UTXO which is confirmed at height `h`, but the receiver has only seen up to /// block of height `h-1`, we want to re-emit this transaction until the receiver has seen the /// block at height `h`. pub new_txs: Vec<(Transaction, u64)>, /// [`Txid`]s of all transactions that have been evicted from mempool. pub evicted_txids: HashSet, /// The latest timestamp of when a transaction entered the mempool. /// /// This is useful for setting the timestamp for evicted transactions. pub latest_update_time: u64, } ``` ### Changelog notice * Change `Emitter::mempool` to return `MempoolEvent`s which contain mempool-eviction data. * Change `Emitter::client` to have more relaxed generic bounds. `C: Deref, C::Target: RpcApi` are the new bounds. * Add conversion impls for `CanonicalTx` to `Txid`/`Arc`. * Add `ChainPosition::is_unconfirmed` method. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [x] I've added tests for the new feature * [x] I've added docs for the new feature #### Bugfixes: * [x] This pull request breaks the existing API * [x] I've added tests to reproduce the issue which are now passing * [x] I'm linking the issue being fixed by this PR ACKs for top commit: ValuedMammal: ACK 8513d83a2ef2fe748e9007984187a7f08d256ee6 Tree-SHA512: 28149458085dc4cefefe06656769d701b53f891c1ecb5d400aba8b23d63c026d6e4db1c9e6f47c8ad167edc1559d897d28e9bb71e7bd144792b5cecc0bcd31ce --- add65bc4f24581bd5f3219bf258746e94ff9cd44