diff --git a/src/util/psbt/macros.rs b/src/util/psbt/macros.rs index 5109b94f..43970504 100644 --- a/src/util/psbt/macros.rs +++ b/src/util/psbt/macros.rs @@ -14,7 +14,7 @@ #[allow(unused_macros)] macro_rules! hex_psbt { - ($s:expr) => { ::consensus::deserialize(& as ::hashes::hex::FromHex>::from_hex($s).unwrap()) }; + ($s:expr) => { $crate::consensus::deserialize(& as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()) }; } macro_rules! merge { @@ -34,9 +34,9 @@ macro_rules! impl_psbt_de_serialize { macro_rules! impl_psbt_deserialize { ($thing:ty) => { - impl ::util::psbt::serialize::Deserialize for $thing { - fn deserialize(bytes: &[u8]) -> Result { - ::consensus::deserialize(&bytes[..]) + impl $crate::util::psbt::serialize::Deserialize for $thing { + fn deserialize(bytes: &[u8]) -> Result { + $crate::consensus::deserialize(&bytes[..]) } } }; @@ -44,9 +44,9 @@ macro_rules! impl_psbt_deserialize { macro_rules! impl_psbt_serialize { ($thing:ty) => { - impl ::util::psbt::serialize::Serialize for $thing { + impl $crate::util::psbt::serialize::Serialize for $thing { fn serialize(&self) -> Vec { - ::consensus::serialize(self) + $crate::consensus::serialize(self) } } }; @@ -54,20 +54,20 @@ macro_rules! impl_psbt_serialize { macro_rules! impl_psbtmap_consensus_encoding { ($thing:ty) => { - impl ::consensus::Encodable for $thing { - fn consensus_encode( + impl $crate::consensus::Encodable for $thing { + fn consensus_encode( &self, mut s: S, - ) -> Result { + ) -> Result { let mut len = 0; - for pair in ::util::psbt::Map::get_pairs(self)? { - len += ::consensus::Encodable::consensus_encode( + for pair in $crate::util::psbt::Map::get_pairs(self)? { + len += $crate::consensus::Encodable::consensus_encode( &pair, &mut s, )?; } - Ok(len + ::consensus::Encodable::consensus_encode(&0x00_u8, s)?) + Ok(len + $crate::consensus::Encodable::consensus_encode(&0x00_u8, s)?) } } }; @@ -75,16 +75,16 @@ macro_rules! impl_psbtmap_consensus_encoding { macro_rules! impl_psbtmap_consensus_decoding { ($thing:ty) => { - impl ::consensus::Decodable for $thing { - fn consensus_decode( + impl $crate::consensus::Decodable for $thing { + fn consensus_decode( mut d: D, - ) -> Result { - let mut rv: Self = ::std::default::Default::default(); + ) -> Result { + let mut rv: Self = $crate::std::default::Default::default(); loop { - match ::consensus::Decodable::consensus_decode(&mut d) { - Ok(pair) => ::util::psbt::Map::insert_pair(&mut rv, pair)?, - Err(::consensus::encode::Error::Psbt(::util::psbt::Error::NoMorePairs)) => return Ok(rv), + match $crate::consensus::Decodable::consensus_decode(&mut d) { + Ok(pair) => $crate::util::psbt::Map::insert_pair(&mut rv, pair)?, + Err($crate::consensus::encode::Error::Psbt($crate::util::psbt::Error::NoMorePairs)) => return Ok(rv), Err(e) => return Err(e), } } @@ -105,29 +105,27 @@ macro_rules! impl_psbt_insert_pair { ($slf:ident.$unkeyed_name:ident <= <$raw_key:ident: _>|<$raw_value:ident: $unkeyed_value_type:ty>) => { if $raw_key.key.is_empty() { if $slf.$unkeyed_name.is_none() { - let val: $unkeyed_value_type = ::util::psbt::serialize::Deserialize::deserialize(&$raw_value)?; - + let val: $unkeyed_value_type = $crate::util::psbt::serialize::Deserialize::deserialize(&$raw_value)?; $slf.$unkeyed_name = Some(val) } else { - return Err(::util::psbt::Error::DuplicateKey($raw_key).into()); + return Err($crate::util::psbt::Error::DuplicateKey($raw_key).into()); } } else { - return Err(::util::psbt::Error::InvalidKey($raw_key).into()); + return Err($crate::util::psbt::Error::InvalidKey($raw_key).into()); } }; ($slf:ident.$keyed_name:ident <= <$raw_key:ident: $keyed_key_type:ty>|<$raw_value:ident: $keyed_value_type:ty>) => { if !$raw_key.key.is_empty() { - let key_val: $keyed_key_type = ::util::psbt::serialize::Deserialize::deserialize(&$raw_key.key)?; - + let key_val: $keyed_key_type = $crate::util::psbt::serialize::Deserialize::deserialize(&$raw_key.key)?; match $slf.$keyed_name.entry(key_val) { ::std::collections::btree_map::Entry::Vacant(empty_key) => { - let val: $keyed_value_type = ::util::psbt::serialize::Deserialize::deserialize(&$raw_value)?; + let val: $keyed_value_type = $crate::util::psbt::serialize::Deserialize::deserialize(&$raw_value)?; empty_key.insert(val); } - ::std::collections::btree_map::Entry::Occupied(_) => return Err(::util::psbt::Error::DuplicateKey($raw_key).into()), + ::std::collections::btree_map::Entry::Occupied(_) => return Err($crate::util::psbt::Error::DuplicateKey($raw_key).into()), } } else { - return Err(::util::psbt::Error::InvalidKey($raw_key).into()); + return Err($crate::util::psbt::Error::InvalidKey($raw_key).into()); } }; } @@ -136,23 +134,23 @@ macro_rules! impl_psbt_insert_pair { macro_rules! impl_psbt_get_pair { ($rv:ident.push($slf:ident.$unkeyed_name:ident as <$unkeyed_typeval:expr, _>|<$unkeyed_value_type:ty>)) => { if let Some(ref $unkeyed_name) = $slf.$unkeyed_name { - $rv.push(::util::psbt::raw::Pair { - key: ::util::psbt::raw::Key { + $rv.push($crate::util::psbt::raw::Pair { + key: $crate::util::psbt::raw::Key { type_value: $unkeyed_typeval, key: vec![], }, - value: ::util::psbt::serialize::Serialize::serialize($unkeyed_name), + value: $crate::util::psbt::serialize::Serialize::serialize($unkeyed_name), }); } }; ($rv:ident.push($slf:ident.$keyed_name:ident as <$keyed_typeval:expr, $keyed_key_type:ty>|<$keyed_value_type:ty>)) => { for (key, val) in &$slf.$keyed_name { - $rv.push(::util::psbt::raw::Pair { - key: ::util::psbt::raw::Key { + $rv.push($crate::util::psbt::raw::Pair { + key: $crate::util::psbt::raw::Key { type_value: $keyed_typeval, - key: ::util::psbt::serialize::Serialize::serialize(key), + key: $crate::util::psbt::serialize::Serialize::serialize(key), }, - value: ::util::psbt::serialize::Serialize::serialize(val), + value: $crate::util::psbt::serialize::Serialize::serialize(val), }); } };