Skip to content

Commit 6008897

Browse files
committed
Merge #1562: fix(wallet)!: make LoadParams implicitly satisfy Send
295b979 fix(wallet)!: make `LoadParams` implicitly satisfy `Send` (志宇) Pull request description: ### Description Make `LoadParams` implicitly satisfy `Send`. This will hopefully make `AsyncWalletPersister` easier to implement. Refer to the [conversation on Discord](https://discord.com/channels/753336465005608961/753367451319926827/1273667818528964714). cc. @matthiasdebernardini ### Notes to the reviewers This is a breaking change, since we are tightening the bounds to some methods. ### Changelog notice * Change `LoadParams` to implicitly satisfy `Send`. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing ACKs for top commit: LLFourn: ACK 295b979 notmandatory: ACK 295b979 Tree-SHA512: 952cd7fbb058166af93af0b8afa3e0f3c1afe600f5782364da8e3c74e7388ca682bab34e2c60b221055e25ade2f6ddb4a2e9451d6d181f14b0bcca053522155c
2 parents 37314dc + 295b979 commit 6008897

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

crates/wallet/src/wallet/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl Wallet {
334334
/// [`reveal_next_address`]: Self::reveal_next_address
335335
pub fn create_single<D>(descriptor: D) -> CreateParams
336336
where
337-
D: IntoWalletDescriptor + Clone + 'static,
337+
D: IntoWalletDescriptor + Send + Clone + 'static,
338338
{
339339
CreateParams::new_single(descriptor)
340340
}
@@ -369,7 +369,7 @@ impl Wallet {
369369
/// ```
370370
pub fn create<D>(descriptor: D, change_descriptor: D) -> CreateParams
371371
where
372-
D: IntoWalletDescriptor + Clone + 'static,
372+
D: IntoWalletDescriptor + Send + Clone + 'static,
373373
{
374374
CreateParams::new(descriptor, change_descriptor)
375375
}

crates/wallet/src/wallet/params.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ use super::{ChangeSet, LoadError, PersistedWallet};
1818
/// [object safety rules](https://doc.rust-lang.org/reference/items/traits.html#object-safety).
1919
type DescriptorToExtract = Box<
2020
dyn FnOnce(&SecpCtx, Network) -> Result<(ExtendedDescriptor, KeyMap), DescriptorError>
21+
+ Send
2122
+ 'static,
2223
>;
2324

2425
fn make_descriptor_to_extract<D>(descriptor: D) -> DescriptorToExtract
2526
where
26-
D: IntoWalletDescriptor + 'static,
27+
D: IntoWalletDescriptor + Send + 'static,
2728
{
2829
Box::new(|secp, network| descriptor.into_wallet_descriptor(secp, network))
2930
}
@@ -51,7 +52,7 @@ impl CreateParams {
5152
///
5253
/// Use this method only when building a wallet with a single descriptor. See
5354
/// also [`Wallet::create_single`].
54-
pub fn new_single<D: IntoWalletDescriptor + 'static>(descriptor: D) -> Self {
55+
pub fn new_single<D: IntoWalletDescriptor + Send + 'static>(descriptor: D) -> Self {
5556
Self {
5657
descriptor: make_descriptor_to_extract(descriptor),
5758
descriptor_keymap: KeyMap::default(),
@@ -69,7 +70,10 @@ impl CreateParams {
6970
/// * `network` = [`Network::Bitcoin`]
7071
/// * `genesis_hash` = `None`
7172
/// * `lookahead` = [`DEFAULT_LOOKAHEAD`]
72-
pub fn new<D: IntoWalletDescriptor + 'static>(descriptor: D, change_descriptor: D) -> Self {
73+
pub fn new<D: IntoWalletDescriptor + Send + 'static>(
74+
descriptor: D,
75+
change_descriptor: D,
76+
) -> Self {
7377
Self {
7478
descriptor: make_descriptor_to_extract(descriptor),
7579
descriptor_keymap: KeyMap::default(),
@@ -185,7 +189,7 @@ impl LoadParams {
185189
/// for an expected descriptor containing secrets.
186190
pub fn descriptor<D>(mut self, keychain: KeychainKind, expected_descriptor: Option<D>) -> Self
187191
where
188-
D: IntoWalletDescriptor + 'static,
192+
D: IntoWalletDescriptor + Send + 'static,
189193
{
190194
let expected = expected_descriptor.map(|d| make_descriptor_to_extract(d));
191195
match keychain {

0 commit comments

Comments
 (0)