]> Untitled Git - bdk/commitdiff
fix(wallet)!: make `LoadParams` implicitly satisfy `Send`
author志宇 <hello@evanlinjin.me>
Fri, 16 Aug 2024 04:21:33 +0000 (04:21 +0000)
committer志宇 <hello@evanlinjin.me>
Fri, 16 Aug 2024 04:21:33 +0000 (04:21 +0000)
crates/wallet/src/wallet/mod.rs
crates/wallet/src/wallet/params.rs

index f98b16e911646e3bd40865a45f3fdb4d8a866d70..d75c6524be6c28d98707575f19928278ddbb43ca 100644 (file)
@@ -343,7 +343,7 @@ impl Wallet {
     /// [`reveal_next_address`]: Self::reveal_next_address
     pub fn create_single<D>(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<D>(descriptor: D, change_descriptor: D) -> CreateParams
     where
-        D: IntoWalletDescriptor + Clone + 'static,
+        D: IntoWalletDescriptor + Send + Clone + 'static,
     {
         CreateParams::new(descriptor, change_descriptor)
     }
index 9b0795395815bd9286ddc5b52daf17cc8f5bbe2d..8e340297322505600ef9ec540e5a414c1ab301ac 100644 (file)
@@ -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<D>(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<D: IntoWalletDescriptor + 'static>(descriptor: D) -> Self {
+    pub fn new_single<D: IntoWalletDescriptor + Send + 'static>(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<D: IntoWalletDescriptor + 'static>(descriptor: D, change_descriptor: D) -> Self {
+    pub fn new<D: IntoWalletDescriptor + Send + 'static>(
+        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<D>(mut self, keychain: KeychainKind, expected_descriptor: Option<D>) -> Self
     where
-        D: IntoWalletDescriptor + 'static,
+        D: IntoWalletDescriptor + Send + 'static,
     {
         let expected = expected_descriptor.map(|d| make_descriptor_to_extract(d));
         match keychain {