Remove various assertions from BIP-174 test
What changed, and why it matters
This commit only changes a test file. It removes some test assertions that compared the library's PSBT output against fixed BIP-174 test vectors, because the project is switching to a different default signature style (low_r) that produces different but still valid signatures. No production code is changed, and no security vulnerability is introduced or fixed.
No security action needed. Reviewers may want to confirm that the removed assertions are adequately replaced by functional checks elsewhere, but this is a normal test refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies bitcoin/tests/bip_174.rs. It removes equality assertions against BIP-174 reference PSBT/transaction hex files (sign_2_psbt_hex, combine_psbt_hex, finalize_psbt_hex, extract_tx_hex) and renames some helper functions (signer_two_sign -> sign, finalize -> finalize_psbt). The production PSBT signing, combining, finalization, and transaction extraction logic is untouched. The change is a test-maintenance adjustment to accommodate non-deterministic low_r ECDSA signatures.
Changed components
bitcoin/tests/bip_174.rsInspect captured patch +5 / −48
diff --git a/bitcoin/tests/bip_174.rs b/bitcoin/tests/bip_174.rs
index d6e0b86f..dfa03eb3 100644
--- a/bitcoin/tests/bip_174.rs
+++ b/bitcoin/tests/bip_174.rs
@@ -5,7 +5,7 @@ use std::collections::BTreeMap;
use bitcoin::amount::{Amount, Denomination};
use bitcoin::bip32::{Fingerprint, IntoDerivationPath, KeySource, Xpriv, Xpub};
-use bitcoin::consensus::encode::{deserialize, serialize_hex};
+use bitcoin::consensus::encode::deserialize;
use bitcoin::opcodes::all::OP_0;
use bitcoin::psbt::{Psbt, PsbtSighashType};
use bitcoin::script::{PushBytes, ScriptBuf};
@@ -80,7 +80,7 @@ fn bip174_psbt_workflow() {
];
let keys = parse_and_verify_keys(&ext_priv, &test_vector);
- let psbt_2 = signer_two_sign(psbt, keys);
+ let psbt_2 = sign(psbt, keys);
//
// Step 6: Combiner the two signed PSBTs.
@@ -92,13 +92,13 @@ fn bip174_psbt_workflow() {
// Step 7: Finalize the PSBT.
//
- let finalized = finalize(combined);
+ let finalized = finalize_psbt(combined);
//
// Step 8: Extract the transaction.
//
- let _tx = extract_transaction(finalized);
+ let _tx = finalized.extract_tx_unchecked_fee_rate();
//
// Step 9: Test lexicographical PSBT combiner.
@@ -333,56 +333,13 @@ fn signer_one_sign(psbt: Psbt, key_map: BTreeMap<bitcoin::PublicKey, PrivateKey>
psbt
}
-/// Does the second signing according to the BIP, returns the signed PSBT. Verifies against BIP 174 test vector.
-#[track_caller]
-fn signer_two_sign(psbt: Psbt, key_map: BTreeMap<bitcoin::PublicKey, PrivateKey>) -> Psbt {
- let expected_psbt_hex = include_str!("data/sign_2_psbt_hex");
- let expected_psbt: Psbt = hex_psbt(expected_psbt_hex);
-
- let psbt = sign(psbt, key_map);
-
- assert_eq!(psbt, expected_psbt);
- psbt
-}
-
-/// Does the combine according to the BIP, returns the combined PSBT. Verifies against BIP 174 test vector.
+/// Does the combine according to the BIP, returns the combined PSBT.
#[track_caller]
fn combine(mut this: Psbt, that: Psbt) -> Psbt {
- let expected_psbt_hex = include_str!("data/combine_psbt_hex");
- let expected_psbt: Psbt = hex_psbt(expected_psbt_hex);
-
this.combine(that).expect("failed to combine PSBTs");
-
- assert_eq!(this, expected_psbt);
this
}
-/// Does the finalize step according to the BIP, returns the combined PSBT. Verifies against BIP 174
-/// test vector.
-#[track_caller]
-fn finalize(psbt: Psbt) -> Psbt {
- let expected_psbt_hex = include_str!("data/finalize_psbt_hex");
- let expected_psbt: Psbt = hex_psbt(expected_psbt_hex);
-
- let psbt = finalize_psbt(psbt);
-
- assert_eq!(psbt, expected_psbt);
- psbt
-}
-
-/// Does the transaction extractor step according to the BIP, returns the combined PSBT. Verifies
-/// against BIP 174 test vector.
-fn extract_transaction(psbt: Psbt) -> Transaction {
- let expected_tx_hex = include_str!("data/extract_tx_hex");
-
- let tx = psbt.extract_tx_unchecked_fee_rate();
-
- let got = serialize_hex(&tx);
- assert_eq!(got, expected_tx_hex);
-
- tx
-}
-
/// Combines two PSBTs lexicographically according to the BIP. Verifies against BIP 174 test vector.
#[track_caller]
fn combine_lexicographically() {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.