Use EcdsaSig in PSBT partial signatures instead of Vec<u8>

This commit is contained in:
Dr Maxim Orlovsky 2022-01-06 12:06:49 +01:00
parent 141dbbd1b9
commit 2b530000d3
2 changed files with 6 additions and 7 deletions

View File

@ -14,7 +14,7 @@
use prelude::*; use prelude::*;
use io; use ::{EcdsaSig, io};
use blockdata::script::Script; use blockdata::script::Script;
use blockdata::transaction::{EcdsaSigHashType, Transaction, TxOut}; use blockdata::transaction::{EcdsaSigHashType, Transaction, TxOut};
@ -87,9 +87,8 @@ pub struct Input {
/// including P2SH embedded ones. /// including P2SH embedded ones.
pub witness_utxo: Option<TxOut>, pub witness_utxo: Option<TxOut>,
/// A map from public keys to their corresponding signature as would be /// A map from public keys to their corresponding signature as would be
/// pushed to the stack from a scriptSig or witness. /// pushed to the stack from a scriptSig or witness for a non-taproot inputs.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))] pub partial_sigs: BTreeMap<PublicKey, EcdsaSig>,
pub partial_sigs: BTreeMap<PublicKey, Vec<u8>>,
/// The sighash type to be used for this input. Signatures for this input /// The sighash type to be used for this input. Signatures for this input
/// must use the sighash type. /// must use the sighash type.
pub sighash_type: Option<EcdsaSigHashType>, pub sighash_type: Option<EcdsaSigHashType>,
@ -163,7 +162,7 @@ impl Map for Input {
} }
PSBT_IN_PARTIAL_SIG => { PSBT_IN_PARTIAL_SIG => {
impl_psbt_insert_pair! { impl_psbt_insert_pair! {
self.partial_sigs <= <raw_key: PublicKey>|<raw_value: Vec<u8>> self.partial_sigs <= <raw_key: PublicKey>|<raw_value: EcdsaSig>
} }
} }
PSBT_IN_SIGHASH_TYPE => { PSBT_IN_SIGHASH_TYPE => {
@ -267,7 +266,7 @@ impl Map for Input {
} }
impl_psbt_get_pair! { impl_psbt_get_pair! {
rv.push(self.partial_sigs as <PSBT_IN_PARTIAL_SIG, PublicKey>|<Vec<u8>>) rv.push(self.partial_sigs as <PSBT_IN_PARTIAL_SIG, PublicKey>|<EcdsaSig>)
} }
impl_psbt_get_pair! { impl_psbt_get_pair! {

View File

@ -477,7 +477,7 @@ mod tests {
witness_script: None, witness_script: None,
partial_sigs: vec![( partial_sigs: vec![(
"0339880dc92394b7355e3d0439fa283c31de7590812ea011c4245c0674a685e883".parse().unwrap(), "0339880dc92394b7355e3d0439fa283c31de7590812ea011c4245c0674a685e883".parse().unwrap(),
vec![8, 5, 4], "304402204f67e2afb76142d44fae58a2495d33a3419daa26cd0db8d04f3452b63289ac0f022010762a9fb67e94cc5cad9026f6dc99ff7f070f4278d30fbc7d0c869dd38c7fe701".parse().unwrap(),
)].into_iter().collect(), )].into_iter().collect(),
bip32_derivation: keypaths.clone(), bip32_derivation: keypaths.clone(),
final_script_witness: Some(vec![vec![1, 3], vec![5]]), final_script_witness: Some(vec![vec![1, 3], vec![5]]),