Merge rust-bitcoin/rust-bitcoin#786: Fix unused arg in PSBT impl_psbt_get_pair macro

1b77e3609c Fix unused arg in PSBT impl_psbt_get_pair macro (Dr Maxim Orlovsky)

Pull request description:

  Closes #754

ACKs for top commit:
  apoelstra:
    ACK 1b77e3609c
  RCasatta:
    utACK 1b77e3609c
  Kixunil:
    ACK 1b77e3609c

Tree-SHA512: 339aae0a9b6adef34bc6bca27ea19eb89205c4b4694e3a95721590696b7eefbfded9294fd9101a66110b4bdfb69da7a7ef97a8e8321d9e05b3777c3fa9afff7c
This commit is contained in:
Andrew Poelstra 2022-01-17 19:53:27 +00:00
commit 8acdb1ab64
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
3 changed files with 27 additions and 29 deletions

View File

@ -125,7 +125,7 @@ macro_rules! impl_psbt_insert_pair {
#[cfg_attr(rustfmt, rustfmt_skip)]
macro_rules! impl_psbt_get_pair {
($rv:ident.push($slf:ident.$unkeyed_name:ident as <$unkeyed_typeval:expr, _>|<$unkeyed_value_type:ty>)) => {
($rv:ident.push($slf:ident.$unkeyed_name:ident, $unkeyed_typeval:ident)) => {
if let Some(ref $unkeyed_name) = $slf.$unkeyed_name {
$rv.push($crate::util::psbt::raw::Pair {
key: $crate::util::psbt::raw::Key {
@ -136,7 +136,7 @@ macro_rules! impl_psbt_get_pair {
});
}
};
($rv:ident.push($slf:ident.$keyed_name:ident as <$keyed_typeval:expr, $keyed_key_type:ty>|<$keyed_value_type:ty>)) => {
($rv:ident.push_map($slf:ident.$keyed_name:ident, $keyed_typeval:ident)) => {
for (key, val) in &$slf.$keyed_name {
$rv.push($crate::util::psbt::raw::Pair {
key: $crate::util::psbt::raw::Key {

View File

@ -310,80 +310,79 @@ impl Map for Input {
let mut rv: Vec<raw::Pair> = Default::default();
impl_psbt_get_pair! {
rv.push(self.non_witness_utxo as <PSBT_IN_NON_WITNESS_UTXO, _>|<Transaction>)
rv.push(self.non_witness_utxo, PSBT_IN_NON_WITNESS_UTXO)
}
impl_psbt_get_pair! {
rv.push(self.witness_utxo as <PSBT_IN_WITNESS_UTXO, _>|<TxOut>)
rv.push(self.witness_utxo, PSBT_IN_WITNESS_UTXO)
}
impl_psbt_get_pair! {
rv.push(self.partial_sigs as <PSBT_IN_PARTIAL_SIG, PublicKey>|<EcdsaSig>)
rv.push_map(self.partial_sigs, PSBT_IN_PARTIAL_SIG)
}
impl_psbt_get_pair! {
rv.push(self.sighash_type as <PSBT_IN_SIGHASH_TYPE, _>|<SigHashType>)
rv.push(self.sighash_type, PSBT_IN_SIGHASH_TYPE)
}
impl_psbt_get_pair! {
rv.push(self.redeem_script as <PSBT_IN_REDEEM_SCRIPT, _>|<Script>)
rv.push(self.redeem_script, PSBT_IN_REDEEM_SCRIPT)
}
impl_psbt_get_pair! {
rv.push(self.witness_script as <PSBT_IN_WITNESS_SCRIPT, _>|<Script>)
rv.push(self.witness_script, PSBT_IN_WITNESS_SCRIPT)
}
impl_psbt_get_pair! {
rv.push(self.bip32_derivation as <PSBT_IN_BIP32_DERIVATION, secp256k1::PublicKey>|<KeySource>)
rv.push_map(self.bip32_derivation, PSBT_IN_BIP32_DERIVATION)
}
impl_psbt_get_pair! {
rv.push(self.final_script_sig as <PSBT_IN_FINAL_SCRIPTSIG, _>|<Script>)
rv.push(self.final_script_sig, PSBT_IN_FINAL_SCRIPTSIG)
}
impl_psbt_get_pair! {
rv.push(self.final_script_witness as <PSBT_IN_FINAL_SCRIPTWITNESS, _>|<Witness>)
rv.push(self.final_script_witness, PSBT_IN_FINAL_SCRIPTWITNESS)
}
impl_psbt_get_pair! {
rv.push(self.ripemd160_preimages as <PSBT_IN_RIPEMD160, ripemd160::Hash>|<Vec<u8>>)
rv.push_map(self.ripemd160_preimages, PSBT_IN_RIPEMD160)
}
impl_psbt_get_pair! {
rv.push(self.sha256_preimages as <PSBT_IN_SHA256, sha256::Hash>|<Vec<u8>>)
rv.push_map(self.sha256_preimages, PSBT_IN_SHA256)
}
impl_psbt_get_pair! {
rv.push(self.hash160_preimages as <PSBT_IN_HASH160, hash160::Hash>|<Vec<u8>>)
rv.push_map(self.hash160_preimages, PSBT_IN_HASH160)
}
impl_psbt_get_pair! {
rv.push(self.hash256_preimages as <PSBT_IN_HASH256, sha256d::Hash>|<Vec<u8>>)
rv.push_map(self.hash256_preimages, PSBT_IN_HASH256)
}
impl_psbt_get_pair! {
rv.push(self.tap_key_sig as <PSBT_IN_TAP_KEY_SIG, _>|<SchnorrSig>)
rv.push(self.tap_key_sig, PSBT_IN_TAP_KEY_SIG)
}
impl_psbt_get_pair! {
rv.push(self.tap_script_sigs as <PSBT_IN_TAP_SCRIPT_SIG, (XOnlyPublicKey, TapLeafHash)>|<SchnorrSig>)
rv.push_map(self.tap_script_sigs, PSBT_IN_TAP_SCRIPT_SIG)
}
impl_psbt_get_pair! {
rv.push(self.tap_scripts as <PSBT_IN_TAP_LEAF_SCRIPT, ControlBlock>|<(Script, LeafVersion)>)
rv.push_map(self.tap_scripts, PSBT_IN_TAP_LEAF_SCRIPT)
}
impl_psbt_get_pair! {
rv.push(self.tap_key_origins as <PSBT_IN_TAP_BIP32_DERIVATION,
XOnlyPublicKey>|<(Vec<TapLeafHash>, KeySource)>)
rv.push_map(self.tap_key_origins, PSBT_IN_TAP_BIP32_DERIVATION)
}
impl_psbt_get_pair! {
rv.push(self.tap_internal_key as <PSBT_IN_TAP_INTERNAL_KEY, _>|<XOnlyPublicKey>)
rv.push(self.tap_internal_key, PSBT_IN_TAP_INTERNAL_KEY)
}
impl_psbt_get_pair! {
rv.push(self.tap_merkle_root as <PSBT_IN_TAP_MERKLE_ROOT, _>|<TapBranchHash>)
rv.push(self.tap_merkle_root, PSBT_IN_TAP_MERKLE_ROOT)
}
for (key, value) in self.proprietary.iter() {
rv.push(raw::Pair {

View File

@ -184,28 +184,27 @@ impl Map for Output {
let mut rv: Vec<raw::Pair> = Default::default();
impl_psbt_get_pair! {
rv.push(self.redeem_script as <PSBT_OUT_REDEEM_SCRIPT, _>|<Script>)
rv.push(self.redeem_script, PSBT_OUT_REDEEM_SCRIPT)
}
impl_psbt_get_pair! {
rv.push(self.witness_script as <PSBT_OUT_WITNESS_SCRIPT, _>|<Script>)
rv.push(self.witness_script, PSBT_OUT_WITNESS_SCRIPT)
}
impl_psbt_get_pair! {
rv.push(self.bip32_derivation as <PSBT_OUT_BIP32_DERIVATION, secp256k1::PublicKey>|<KeySource>)
rv.push_map(self.bip32_derivation, PSBT_OUT_BIP32_DERIVATION)
}
impl_psbt_get_pair! {
rv.push(self.tap_internal_key as <PSBT_OUT_TAP_INTERNAL_KEY, _>|<schnorr::PublicKey>)
rv.push(self.tap_internal_key, PSBT_OUT_TAP_INTERNAL_KEY)
}
impl_psbt_get_pair! {
rv.push(self.tap_tree as <PSBT_OUT_TAP_TREE, _>|<TaprootBuilder>)
rv.push(self.tap_tree, PSBT_OUT_TAP_TREE)
}
impl_psbt_get_pair! {
rv.push(self.tap_key_origins as <PSBT_OUT_TAP_BIP32_DERIVATION,
schnorr::PublicKey>|<(Vec<TapLeafHash>, KeySource)>)
rv.push_map(self.tap_key_origins, PSBT_OUT_TAP_BIP32_DERIVATION)
}
for (key, value) in self.proprietary.iter() {