From 53b93321c87ed57680e0ca49a0691c4deb7edde7 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Mon, 23 Jun 2025 20:04:54 +0000 Subject: [PATCH] psbt: add test vector where non-witness UTXO TXID does not match input txid --- bitcoin/src/psbt/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bitcoin/src/psbt/mod.rs b/bitcoin/src/psbt/mod.rs index e55480b88..4fe91060e 100644 --- a/bitcoin/src/psbt/mod.rs +++ b/bitcoin/src/psbt/mod.rs @@ -2113,6 +2113,28 @@ mod tests { } } + #[test] + fn invalid_vector_4617() { + let err = hex_psbt("70736274ff01007374ff0103010000000000000000002e2873007374ff0107736205000000000000000000000000000000000006060005feffffff74ff01000a000000000000002cc760008530b38dac0100030500000074ff01070100000000000000000000000000c0316888e006000600050000736274ff00d90001007374ff41030100000000000a0a06002e2873007374ff01070100000000000000000000000000000000ff0000060600050000736274ff01000a0080000000000024c7600005193b1e400700030500000074ff0107010000000000a9c7df3f07000570ed62c76004c3ca95c5f90200010742420a0a000000000000").unwrap_err(); + match err { + Error::IncorrectNonWitnessUtxo { index: 0, input_outpoint, non_witness_utxo_txid } => { + assert_eq!( + input_outpoint, + "00000000000000000000000562730701ff74730073282e000000000000000000:0" + .parse() + .unwrap(), + ); + assert_eq!( + non_witness_utxo_txid, + "9ed45fd3f73b038649bee6e763dbd70868745c48a0d2b0299f42c68f957995f4" + .parse() + .unwrap(), + ); + } + _ => panic!("expected output hash mismatch error, got {}", err), + } + } + #[test] fn serialize_and_deserialize_preimage_psbt() { // create a sha preimage map