feat: add memory wallet
This commit is contained in:
parent
f169b1a52f
commit
79e7ab73ea
@ -271,6 +271,9 @@ interface Wallet {
|
|||||||
[Throws=WalletCreationError]
|
[Throws=WalletCreationError]
|
||||||
constructor(Descriptor descriptor, Descriptor? change_descriptor, string persistence_backend_path, Network network);
|
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]
|
[Throws=PersistenceError]
|
||||||
AddressInfo reveal_next_address(KeychainKind keychain);
|
AddressInfo reveal_next_address(KeychainKind keychain);
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ use crate::bitcoin::Amount;
|
|||||||
use crate::bitcoin::{FeeRate, OutPoint, Psbt, Script, Transaction};
|
use crate::bitcoin::{FeeRate, OutPoint, Psbt, Script, Transaction};
|
||||||
use crate::descriptor::Descriptor;
|
use crate::descriptor::Descriptor;
|
||||||
use crate::error::{
|
use crate::error::{
|
||||||
CalculateFeeError, CannotConnectError, CreateTxError, PersistenceError, SignerError,
|
CalculateFeeError, CannotConnectError, CreateTxError, DescriptorError, PersistenceError,
|
||||||
TxidParseError, WalletCreationError,
|
SignerError, TxidParseError, WalletCreationError,
|
||||||
};
|
};
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
AddressInfo, Balance, CanonicalTx, FullScanRequest, LocalOutput, ScriptAmount, SyncRequest,
|
AddressInfo, Balance, CanonicalTx, FullScanRequest, LocalOutput, ScriptAmount, SyncRequest,
|
||||||
@ -49,6 +49,22 @@ impl Wallet {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_no_persist(
|
||||||
|
descriptor: Arc<Descriptor>,
|
||||||
|
change_descriptor: Option<Arc<Descriptor>>,
|
||||||
|
network: Network,
|
||||||
|
) -> Result<Self, DescriptorError> {
|
||||||
|
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<BdkWallet> {
|
pub(crate) fn get_wallet(&self) -> MutexGuard<BdkWallet> {
|
||||||
self.inner_mutex.lock().expect("wallet")
|
self.inner_mutex.lock().expect("wallet")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user