From 27037e2c723e250049cf70f5fba2d382d7da1673 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sat, 5 Dec 2020 15:46:30 +0100 Subject: [PATCH] PSBT: Making RIPEMD160 hash match standard name --- src/util/psbt/map/input.rs | 12 ++++++------ src/util/psbt/mod.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/psbt/map/input.rs b/src/util/psbt/map/input.rs index a0e9c6ad..34ee93a1 100644 --- a/src/util/psbt/map/input.rs +++ b/src/util/psbt/map/input.rs @@ -57,8 +57,8 @@ pub struct Input { /// other scripts necessary for this input to pass validation. pub final_script_witness: Option>>, /// TODO: Proof of reserves commitment - /// RIPEMD hash to preimage map - pub ripemd_preimages: BTreeMap>, + /// RIPEMD160 hash to preimage map + pub ripemd160_preimages: BTreeMap>, /// SHA256 hash to preimage map pub sha256_preimages: BTreeMap>, /// HSAH160 hash to preimage map @@ -72,7 +72,7 @@ serde_struct_impl!( Input, non_witness_utxo, witness_utxo, partial_sigs, sighash_type, redeem_script, witness_script, bip32_derivation, final_script_sig, final_script_witness, - ripemd_preimages, sha256_preimages, hash160_preimages, hash256_preimages, + ripemd160_preimages, sha256_preimages, hash160_preimages, hash256_preimages, unknown ); @@ -130,7 +130,7 @@ impl Map for Input { } } 10u8 => { - psbt_insert_hash_pair(&mut self.ripemd_preimages, raw_key, raw_value, error::PsbtHash::Ripemd)?; + psbt_insert_hash_pair(&mut self.ripemd160_preimages, raw_key, raw_value, error::PsbtHash::Ripemd)?; } 11u8 => { psbt_insert_hash_pair(&mut self.sha256_preimages, raw_key, raw_value, error::PsbtHash::Sha256)?; @@ -194,7 +194,7 @@ impl Map for Input { } impl_psbt_get_pair! { - rv.push(self.ripemd_preimages as <10u8, ripemd160::Hash>|>) + rv.push(self.ripemd160_preimages as <10u8, ripemd160::Hash>|>) } impl_psbt_get_pair! { @@ -229,7 +229,7 @@ impl Map for Input { self.partial_sigs.extend(other.partial_sigs); self.bip32_derivation.extend(other.bip32_derivation); - self.ripemd_preimages.extend(other.ripemd_preimages); + self.ripemd160_preimages.extend(other.ripemd160_preimages); self.sha256_preimages.extend(other.sha256_preimages); self.hash160_preimages.extend(other.hash160_preimages); self.hash256_preimages.extend(other.hash256_preimages); diff --git a/src/util/psbt/mod.rs b/src/util/psbt/mod.rs index 613d5e7d..236643d7 100644 --- a/src/util/psbt/mod.rs +++ b/src/util/psbt/mod.rs @@ -669,7 +669,7 @@ mod tests { // Now add an ripemd160 with incorrect preimage let mut ripemd160_preimages = BTreeMap::new(); ripemd160_preimages.insert(ripemd160::Hash::hash(&[17u8]), vec![18u8]); - unserialized.inputs[0].ripemd_preimages = ripemd160_preimages; + unserialized.inputs[0].ripemd160_preimages = ripemd160_preimages; // Now the roundtrip should fail as the preimage is incorrect. let rtt : Result = hex_psbt!(&serialize_hex(&unserialized));