PSBT: Making RIPEMD160 hash match standard name
This commit is contained in:
parent
9b106ee161
commit
27037e2c72
|
@ -57,8 +57,8 @@ pub struct Input {
|
||||||
/// other scripts necessary for this input to pass validation.
|
/// other scripts necessary for this input to pass validation.
|
||||||
pub final_script_witness: Option<Vec<Vec<u8>>>,
|
pub final_script_witness: Option<Vec<Vec<u8>>>,
|
||||||
/// TODO: Proof of reserves commitment
|
/// TODO: Proof of reserves commitment
|
||||||
/// RIPEMD hash to preimage map
|
/// RIPEMD160 hash to preimage map
|
||||||
pub ripemd_preimages: BTreeMap<ripemd160::Hash, Vec<u8>>,
|
pub ripemd160_preimages: BTreeMap<ripemd160::Hash, Vec<u8>>,
|
||||||
/// SHA256 hash to preimage map
|
/// SHA256 hash to preimage map
|
||||||
pub sha256_preimages: BTreeMap<sha256::Hash, Vec<u8>>,
|
pub sha256_preimages: BTreeMap<sha256::Hash, Vec<u8>>,
|
||||||
/// HSAH160 hash to preimage map
|
/// HSAH160 hash to preimage map
|
||||||
|
@ -72,7 +72,7 @@ serde_struct_impl!(
|
||||||
Input, non_witness_utxo, witness_utxo, partial_sigs,
|
Input, non_witness_utxo, witness_utxo, partial_sigs,
|
||||||
sighash_type, redeem_script, witness_script, bip32_derivation,
|
sighash_type, redeem_script, witness_script, bip32_derivation,
|
||||||
final_script_sig, final_script_witness,
|
final_script_sig, final_script_witness,
|
||||||
ripemd_preimages, sha256_preimages, hash160_preimages, hash256_preimages,
|
ripemd160_preimages, sha256_preimages, hash160_preimages, hash256_preimages,
|
||||||
unknown
|
unknown
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ impl Map for Input {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
10u8 => {
|
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 => {
|
11u8 => {
|
||||||
psbt_insert_hash_pair(&mut self.sha256_preimages, raw_key, raw_value, error::PsbtHash::Sha256)?;
|
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! {
|
impl_psbt_get_pair! {
|
||||||
rv.push(self.ripemd_preimages as <10u8, ripemd160::Hash>|<Vec<u8>>)
|
rv.push(self.ripemd160_preimages as <10u8, ripemd160::Hash>|<Vec<u8>>)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_psbt_get_pair! {
|
impl_psbt_get_pair! {
|
||||||
|
@ -229,7 +229,7 @@ impl Map for Input {
|
||||||
|
|
||||||
self.partial_sigs.extend(other.partial_sigs);
|
self.partial_sigs.extend(other.partial_sigs);
|
||||||
self.bip32_derivation.extend(other.bip32_derivation);
|
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.sha256_preimages.extend(other.sha256_preimages);
|
||||||
self.hash160_preimages.extend(other.hash160_preimages);
|
self.hash160_preimages.extend(other.hash160_preimages);
|
||||||
self.hash256_preimages.extend(other.hash256_preimages);
|
self.hash256_preimages.extend(other.hash256_preimages);
|
||||||
|
|
|
@ -669,7 +669,7 @@ mod tests {
|
||||||
// Now add an ripemd160 with incorrect preimage
|
// Now add an ripemd160 with incorrect preimage
|
||||||
let mut ripemd160_preimages = BTreeMap::new();
|
let mut ripemd160_preimages = BTreeMap::new();
|
||||||
ripemd160_preimages.insert(ripemd160::Hash::hash(&[17u8]), vec![18u8]);
|
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.
|
// Now the roundtrip should fail as the preimage is incorrect.
|
||||||
let rtt : Result<PartiallySignedTransaction, _> = hex_psbt!(&serialize_hex(&unserialized));
|
let rtt : Result<PartiallySignedTransaction, _> = hex_psbt!(&serialize_hex(&unserialized));
|
||||||
|
|
Loading…
Reference in New Issue