diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 1c716777..06551a12 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -437,6 +437,8 @@ interface Wallet { [Throws=SqliteError] boolean persist(Connection connection); + + ExtendedDescriptor public_descriptor(KeychainKind keychain); }; interface Update {}; @@ -581,6 +583,12 @@ interface Descriptor { constructor([ByRef] DescriptorPublicKey public_key, string fingerprint, KeychainKind keychain, Network network); string to_string_with_secret(); + + ExtendedDescriptor to_extended_descriptor(); +}; + +interface ExtendedDescriptor { + string to_string(); }; // ------------------------------------------------------------------------ diff --git a/bdk-ffi/src/descriptor.rs b/bdk-ffi/src/descriptor.rs index 413df82a..2c29d2df 100644 --- a/bdk-ffi/src/descriptor.rs +++ b/bdk-ffi/src/descriptor.rs @@ -16,6 +16,7 @@ use bdk_wallet::KeychainKind; use std::fmt::Display; use std::str::FromStr; +use std::sync::Arc; #[derive(Debug)] pub struct Descriptor { @@ -266,6 +267,10 @@ impl Descriptor { let key_map = &self.key_map; descriptor.to_string_with_secret(key_map) } + + pub(crate) fn to_extended_descriptor(&self) -> Arc { + self.extended_descriptor.clone().into() + } } impl Display for Descriptor { diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index b8db0d78..d2cceab0 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -71,6 +71,7 @@ use bitcoin_ffi::Network; use bitcoin_ffi::OutPoint; use bitcoin_ffi::Script; +use bdk_wallet::descriptor::ExtendedDescriptor; use bdk_wallet::keys::bip39::WordCount; use bdk_wallet::tx_builder::ChangeSpendPolicy; use bdk_wallet::ChangeSet; diff --git a/bdk-ffi/src/wallet.rs b/bdk-ffi/src/wallet.rs index fd8d4b75..665b1064 100644 --- a/bdk-ffi/src/wallet.rs +++ b/bdk-ffi/src/wallet.rs @@ -16,6 +16,7 @@ use bdk_wallet::bitcoin::{Network, Txid}; use bdk_wallet::rusqlite::Connection as BdkConnection; use bdk_wallet::{KeychainKind, PersistedWallet, SignOptions, Wallet as BdkWallet}; +use bdk_wallet::descriptor::ExtendedDescriptor; use std::borrow::BorrowMut; use std::str::FromStr; use std::sync::{Arc, Mutex, MutexGuard}; @@ -234,4 +235,9 @@ impl Wallet { rusqlite_error: e.to_string(), }) } + + pub fn public_descriptor(&self, keychain: KeychainKind) -> Arc { + let extended_descriptor = self.get_wallet().public_descriptor(keychain).clone(); + Arc::new(extended_descriptor) + } }