Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wallet)!: make LoadParams implicitly satisfy Send #1562

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading