fix(types): use bounds-checked access in Utxo::txout() for Foreign variant#445
fix(types): use bounds-checked access in Utxo::txout() for Foreign variant#445tnull wants to merge 1 commit intobitcoindevkit:masterfrom
Utxo::txout() for Foreign variant#445Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #445 +/- ##
==========================================
+ Coverage 80.04% 80.46% +0.42%
==========================================
Files 24 24
Lines 5336 5417 +81
Branches 242 242
==========================================
+ Hits 4271 4359 +88
+ Misses 987 980 -7
Partials 78 78
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
cACK, can you fix the clippy warning? let psbt_input = psbt::Input {
non_witness_utxo: Some(prev_tx),
..Default::default()
}; |
…variant Replace unchecked array indexing of `prev_tx.output[outpoint.vout]` with `.get().expect()` to provide a descriptive panic message instead of an opaque index-out-of-bounds if the outpoint vout is invalid. Co-Authored-By: HAL 9000 Signed-off-by: Elias Rohrer <dev@tnull.de>
4c0ab73 to
2bd536f
Compare
Done. |
ValuedMammal
left a comment
There was a problem hiding this comment.
I suppose this is marginally better than before. I'm not too concerned with asserting the content of the panic message string. If anything the method should state how it panics in the documentation. Noting that it generally works when combined with add_foreign_utxo, by throwing for MissingUtxo, since we can't control how the foreign Utxo is constructed in all cases, I guess the right solution long term is to handle a missing txout using Option or Result.
Description
Replace unchecked array indexing of
prev_tx.output[outpoint.vout]with.get().expect()to provide a descriptive panic message instead of an opaque index-out-of-bounds if the outpoint vout is invalid.Co-Authored-By: HAL 9000
Checklists
All Submissions:
just pbefore pushingBugfixes: