diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 529e7a7..e9fa9ec 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -271,6 +271,9 @@ interface Wallet { [Throws=WalletCreationError] constructor(Descriptor descriptor, Descriptor? change_descriptor, string persistence_backend_path, Network network); + [Name=new_no_persist, Throws=DescriptorError] + constructor(Descriptor descriptor, Descriptor? change_descriptor, Network network); + [Throws=PersistenceError] AddressInfo reveal_next_address(KeychainKind keychain); diff --git a/bdk-ffi/src/wallet.rs b/bdk-ffi/src/wallet.rs index 6e19f91..2470371 100644 --- a/bdk-ffi/src/wallet.rs +++ b/bdk-ffi/src/wallet.rs @@ -2,8 +2,8 @@ use crate::bitcoin::Amount; use crate::bitcoin::{FeeRate, OutPoint, Psbt, Script, Transaction}; use crate::descriptor::Descriptor; use crate::error::{ - CalculateFeeError, CannotConnectError, CreateTxError, PersistenceError, SignerError, - TxidParseError, WalletCreationError, + CalculateFeeError, CannotConnectError, CreateTxError, DescriptorError, PersistenceError, + SignerError, TxidParseError, WalletCreationError, }; use crate::types::{ AddressInfo, Balance, CanonicalTx, FullScanRequest, LocalOutput, ScriptAmount, SyncRequest, @@ -49,6 +49,22 @@ impl Wallet { }) } + pub fn new_no_persist( + descriptor: Arc, + change_descriptor: Option>, + network: Network, + ) -> Result { + let descriptor = descriptor.as_string_private(); + let change_descriptor = change_descriptor.map(|d| d.as_string_private()); + + let wallet: BdkWallet = + BdkWallet::new_no_persist(&descriptor, change_descriptor.as_ref(), network)?; + + Ok(Wallet { + inner_mutex: Mutex::new(wallet), + }) + } + pub(crate) fn get_wallet(&self) -> MutexGuard { self.inner_mutex.lock().expect("wallet") }