fix(electrum): Fix fetch_prev_txout#1443
Conversation
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.
|
This looks like the right solution but Is it possible to create a test that fails before the change and passes after? I'd like to make sure an issue like this doesn't sneak in again. |
|
Would it also make sense to fix |
|
As I understand the behavior of |
|
Damn this is a huge oversight by @LagginTimes and myself. Thanks for taking this on. |
|
ACK af15ebb |
|
We definitely need more tests for this. We can add these tests in subsequent PRs. I propose a separate test specific to testing fee calculation that takes into account what @ValuedMammal mentioned in #1443 (comment):
|
Previously we inserted every
TxOutof a previous tx at the same outpoint, which is incorrect because an outpoint only points to a singleTxOut. Now just get theTxOutcorresponding 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_feeto fail withNegativeFeeerror.fixes #1419
Checklists
All Submissions:
cargo fmtandcargo clippybefore committingBugfixes: