From 295b9794caf142707c49666529268197694534e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Fri, 16 Aug 2024 04:21:33 +0000 Subject: [PATCH] fix(wallet)!: make `LoadParams` implicitly satisfy `Send` --- crates/wallet/src/wallet/mod.rs | 4 ++-- crates/wallet/src/wallet/params.rs | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/wallet/src/wallet/mod.rs b/crates/wallet/src/wallet/mod.rs index f98b16e91..d75c6524b 100644 --- a/crates/wallet/src/wallet/mod.rs +++ b/crates/wallet/src/wallet/mod.rs @@ -343,7 +343,7 @@ impl Wallet { /// [`reveal_next_address`]: Self::reveal_next_address pub fn create_single(descriptor: D) -> CreateParams where - D: IntoWalletDescriptor + Clone + 'static, + D: IntoWalletDescriptor + Send + Clone + 'static, { CreateParams::new_single(descriptor) } @@ -378,7 +378,7 @@ impl Wallet { /// ``` pub fn create(descriptor: D, change_descriptor: D) -> CreateParams where - D: IntoWalletDescriptor + Clone + 'static, + D: IntoWalletDescriptor + Send + Clone + 'static, { CreateParams::new(descriptor, change_descriptor) } diff --git a/crates/wallet/src/wallet/params.rs b/crates/wallet/src/wallet/params.rs index 9b0795395..8e3402973 100644 --- a/crates/wallet/src/wallet/params.rs +++ b/crates/wallet/src/wallet/params.rs @@ -17,12 +17,13 @@ use super::{ChangeSet, LoadError, PersistedWallet}; /// [object safety rules](https://doc.rust-lang.org/reference/items/traits.html#object-safety). type DescriptorToExtract = Box< dyn FnOnce(&SecpCtx, Network) -> Result<(ExtendedDescriptor, KeyMap), DescriptorError> + + Send + 'static, >; fn make_descriptor_to_extract(descriptor: D) -> DescriptorToExtract where - D: IntoWalletDescriptor + 'static, + D: IntoWalletDescriptor + Send + 'static, { Box::new(|secp, network| descriptor.into_wallet_descriptor(secp, network)) } @@ -50,7 +51,7 @@ impl CreateParams { /// /// Use this method only when building a wallet with a single descriptor. See /// also [`Wallet::create_single`]. - pub fn new_single(descriptor: D) -> Self { + pub fn new_single(descriptor: D) -> Self { Self { descriptor: make_descriptor_to_extract(descriptor), descriptor_keymap: KeyMap::default(), @@ -68,7 +69,10 @@ impl CreateParams { /// * `network` = [`Network::Bitcoin`] /// * `genesis_hash` = `None` /// * `lookahead` = [`DEFAULT_LOOKAHEAD`] - pub fn new(descriptor: D, change_descriptor: D) -> Self { + pub fn new( + descriptor: D, + change_descriptor: D, + ) -> Self { Self { descriptor: make_descriptor_to_extract(descriptor), descriptor_keymap: KeyMap::default(), @@ -184,7 +188,7 @@ impl LoadParams { /// for an expected descriptor containing secrets. pub fn descriptor(mut self, keychain: KeychainKind, expected_descriptor: Option) -> Self where - D: IntoWalletDescriptor + 'static, + D: IntoWalletDescriptor + Send + 'static, { let expected = expected_descriptor.map(|d| make_descriptor_to_extract(d)); match keychain {