feat: expose Wallet create and load params - #1044
Conversation
|
I kept it in 2 commits because 2nd commit built on #1042, but will squash into 1 commit when merge |
There was a problem hiding this comment.
ACK af845a5.
We're now at 12 constructors on the wallet, which is a bit of a code smell for me (and the lookahead is now potentially passed twice, once as a straight argument and then again in the params argument).
Looking at this I wonder if adding the Params as a default of None would solve this (12 constructors to 6). The issues is maybe how downstream languages handle default arguments (I haven't dug into whether that'd be breaking for JS for example).
#[derive(Clone, Debug, uniffi::Record)]
pub struct CreateParams {
#[uniffi(default = None)]
pub genesis_hash: Option<Arc<BlockHash>>,
#[uniffi(default = false)]
pub use_spk_cache: bool,
}
#[uniffi::constructor(default(lookahead = 25, params = None))]
pub fn new(
descriptor: Arc<Descriptor>,
change_descriptor: Arc<Descriptor>,
network: Network,
persister: Arc<Persister>,
lookahead: u32,
params: Option<CreateParams>,
) -> Result<Self, CreateWithPersistError>Overall this is a good addition and non-breaking, so I think we can just go ahead and ship 3.1 with it. But looking at 4.0 cleaning this up would be a good goal.
#1030 first
Description
Exposes CreateParams and LoadParams so callers can configure genesis hash, lookahead, SPK cache, and loadtime checks when creating or loading wallets.
Notes to the reviewers
Documentation
bdk_walletCreateParamsLoadParamsLoadParams::two_path_descriptorbitcoinuniffiOther:
Changelog
Checklists
All Submissions:
cargo fmtandcargo clippybefore committingchangelog:*labelNew Features:
Bugfixes: