From: 志宇 Date: Wed, 15 May 2024 12:34:47 +0000 (+0800) Subject: Merge bitcoindevkit/bdk#1443: fix(electrum): Fix `fetch_prev_txout` X-Git-Tag: v1.0.0-alpha.12~4 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/struct.EncoderStringWriter.html?a=commitdiff_plain;h=2f059a1588ee3159992249c2c04e3a17fe128be3;p=bdk Merge bitcoindevkit/bdk#1443: fix(electrum): Fix `fetch_prev_txout` af15ebba94f6d96a4d266fbbdee7c49150f80b96 fix(electrum): Fix `fetch_prev_txout` (valued mammal) Pull request description: Previously we inserted every `TxOut` of a previous tx at the same outpoint, which is incorrect because an outpoint only points to a single `TxOut`. Now just get the `TxOut` corresponding to the txin prevout and insert it with its outpoint. ### Notes to the reviewers The bug in question was demonstrated in a discord comment https://discord.com/channels/753336465005608961/1239693193159639073/1239704153400414298 but I don't think we've opened an issue yet. Essentially, because of a mismatch between the outpoint and txout stored in TxGraph, we weren't summing the inputs correctly which caused `calculate_fee` to fail with `NegativeFee` error. fixes #1419 ### 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 #### Bugfixes: * [ ] I've added tests to reproduce the issue which are now passing ACKs for top commit: LagginTimes: ACK af15ebba94f6d96a4d266fbbdee7c49150f80b96 evanlinjin: ACK af15ebba94f6d96a4d266fbbdee7c49150f80b96 Tree-SHA512: c3a2c374069b0863076784856d90c7760b8f411e4881c3e42367015542b02ea6010c37745fb6dde95422af7222b7939ec51bc0fd1f63f816813c2159a17e08e5 --- 2f059a1588ee3159992249c2c04e3a17fe128be3