Skip to content

Commit

Permalink
fix(wallet)!: make LoadParams implicitly satisfy Send
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlinjin committed Aug 16, 2024
1 parent e0822d7 commit 295b979
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
12 changes: 8 additions & 4 deletions crates/wallet/src/wallet/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 295b979

Please sign in to comment.