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
This commit is contained in:
commit
2f059a1588
@ -523,10 +523,10 @@ fn fetch_prev_txout<C: ElectrumApi>(
|
|||||||
for tx in full_txs {
|
for tx in full_txs {
|
||||||
for vin in &tx.input {
|
for vin in &tx.input {
|
||||||
let outpoint = vin.previous_output;
|
let outpoint = vin.previous_output;
|
||||||
|
let vout = outpoint.vout;
|
||||||
let prev_tx = fetch_tx(client, tx_cache, outpoint.txid)?;
|
let prev_tx = fetch_tx(client, tx_cache, outpoint.txid)?;
|
||||||
for txout in prev_tx.output.clone() {
|
let txout = prev_tx.output[vout as usize].clone();
|
||||||
let _ = graph_update.insert_txout(outpoint, txout);
|
let _ = graph_update.insert_txout(outpoint, txout);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user