Skip to content

Commit c31de7f

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 a2de231 commit c31de7f

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

src/psbt/mod.rs

+1-30
Original file line numberDiff line numberDiff line change
@@ -927,33 +927,6 @@ impl PsbtInputExt for psbt::Input {
927927
}
928928
}
929929

930-
// Traverse the pkh lookup while maintaining a reverse map for storing the map
931-
// hash160 -> (XonlyPublicKey)/PublicKey
932-
struct XOnlyHashLookUp(
933-
pub BTreeMap<hash160::Hash, bitcoin::XOnlyPublicKey>,
934-
pub secp256k1::Secp256k1<VerifyOnly>,
935-
);
936-
937-
impl Translator<DefiniteDescriptorKey, bitcoin::PublicKey, descriptor::ConversionError>
938-
for XOnlyHashLookUp
939-
{
940-
fn pk(
941-
&mut self,
942-
xpk: &DefiniteDescriptorKey,
943-
) -> Result<bitcoin::PublicKey, descriptor::ConversionError> {
944-
xpk.derive_public_key(&self.1)
945-
}
946-
947-
// TODO: cleanup this code in a later commit
948-
949-
// Clone all the associated types in translation
950-
translate_hash_clone!(
951-
DescriptorPublicKey,
952-
bitcoin::PublicKey,
953-
descriptor::ConversionError
954-
);
955-
}
956-
957930
// Traverse the pkh lookup while maintaining a reverse map for storing the map
958931
// hash160 -> (XonlyPublicKey)/PublicKey
959932
struct KeySourceLookUp(
@@ -994,9 +967,7 @@ fn update_input_with_descriptor_helper(
994967
let secp = secp256k1::Secp256k1::verification_only();
995968

996969
let derived = if let Descriptor::Tr(_) = &descriptor {
997-
let mut hash_lookup = XOnlyHashLookUp(BTreeMap::new(), secp);
998-
// Feed in information about pkh -> pk mapping here
999-
let derived = descriptor.translate_pk(&mut hash_lookup)?;
970+
let derived = descriptor.derived_descriptor(&secp)?;
1000971

1001972
if let Some(check_script) = check_script {
1002973
if check_script != derived.script_pubkey() {

0 commit comments

Comments
 (0)