Skip to content

Commit 94d5eba

Browse files
committed
Cleanup psbt translator APIs
We no longer need to maintain mappings from hash160::Hash as Pkh now stores the Pk instead of Pk::Hash
1 parent fff727c commit 94d5eba

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

src/psbt/mod.rs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -998,33 +998,6 @@ impl PsbtOutputExt for psbt::Output {
998998
}
999999
}
10001000

1001-
// Traverse the pkh lookup while maintaining a reverse map for storing the map
1002-
// hash160 -> (XonlyPublicKey)/PublicKey
1003-
struct XOnlyHashLookUp(
1004-
pub BTreeMap<hash160::Hash, bitcoin::XOnlyPublicKey>,
1005-
pub secp256k1::Secp256k1<VerifyOnly>,
1006-
);
1007-
1008-
impl Translator<DefiniteDescriptorKey, bitcoin::PublicKey, descriptor::ConversionError>
1009-
for XOnlyHashLookUp
1010-
{
1011-
fn pk(
1012-
&mut self,
1013-
xpk: &DefiniteDescriptorKey,
1014-
) -> Result<bitcoin::PublicKey, descriptor::ConversionError> {
1015-
xpk.derive_public_key(&self.1)
1016-
}
1017-
1018-
// TODO: cleanup this code in a later commit
1019-
1020-
// Clone all the associated types in translation
1021-
translate_hash_clone!(
1022-
DescriptorPublicKey,
1023-
bitcoin::PublicKey,
1024-
descriptor::ConversionError
1025-
);
1026-
}
1027-
10281001
// Traverse the pkh lookup while maintaining a reverse map for storing the map
10291002
// hash160 -> (XonlyPublicKey)/PublicKey
10301003
struct KeySourceLookUp(
@@ -1155,9 +1128,7 @@ fn update_item_with_descriptor_helper<F: PsbtFields>(
11551128
let secp = secp256k1::Secp256k1::verification_only();
11561129

11571130
let derived = if let Descriptor::Tr(_) = &descriptor {
1158-
let mut hash_lookup = XOnlyHashLookUp(BTreeMap::new(), secp);
1159-
// Feed in information about pkh -> pk mapping here
1160-
let derived = descriptor.translate_pk(&mut hash_lookup)?;
1131+
let derived = descriptor.derived_descriptor(&secp)?;
11611132

11621133
if let Some(check_script) = check_script {
11631134
if check_script != &derived.script_pubkey() {

0 commit comments

Comments
 (0)