[descriptors] Transform a descriptor into its "public" version

This commit is contained in:
Alekos Filini
2020-05-10 17:42:02 +02:00
parent 0e432f3b26
commit c1b01e4d8c
6 changed files with 267 additions and 106 deletions

View File

@@ -496,6 +496,17 @@ where
}
}
pub fn public_descriptor(
&self,
script_type: ScriptType,
) -> Result<Option<ExtendedDescriptor>, Error> {
match (script_type, self.change_descriptor.as_ref()) {
(ScriptType::External, _) => Ok(Some(self.descriptor.as_public_version()?)),
(ScriptType::Internal, None) => Ok(None),
(ScriptType::Internal, Some(desc)) => Ok(Some(desc.as_public_version()?)),
}
}
// Internals
#[cfg(not(target_arch = "wasm32"))]