Skip to content

Commit 55d9f09

Browse files
committed
feat(wallet): add lookahead as optional argument
Using the default argument here, so this should actually be non-breaking. Compared to a builder this is ergonomic in the target languages IMO
1 parent dfb2855 commit 55d9f09

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

bdk-ffi/src/tx_builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ mod tests {
617617
Arc::new(Descriptor::new(internal_descriptor, Network::Signet).unwrap()),
618618
Network::Signet,
619619
Arc::new(Connection::new_in_memory().unwrap()),
620+
None,
620621
)
621622
.unwrap();
622623
let client = EsploraClient::new("https://mutinynet.com/api/".to_string(), None);

bdk-ffi/src/wallet.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,23 @@ impl Wallet {
4141
/// Build a new Wallet.
4242
///
4343
/// If you have previously created a wallet, use load instead.
44-
#[uniffi::constructor]
44+
#[uniffi::constructor(default(lookahead = None))]
4545
pub fn new(
4646
descriptor: Arc<Descriptor>,
4747
change_descriptor: Arc<Descriptor>,
4848
network: Network,
4949
connection: Arc<Connection>,
50+
lookahead: Option<u32>,
5051
) -> Result<Self, CreateWithPersistError> {
5152
let descriptor = descriptor.to_string_with_secret();
5253
let change_descriptor = change_descriptor.to_string_with_secret();
5354
let mut binding = connection.get_store();
5455
let db: &mut BdkConnection = binding.borrow_mut();
55-
56-
let wallet: PersistedWallet<BdkConnection> =
57-
BdkWallet::create(descriptor, change_descriptor)
58-
.network(network)
59-
.create_wallet(db)?;
60-
56+
let mut params = BdkWallet::create(descriptor, change_descriptor).network(network);
57+
if let Some(lookahead) = lookahead {
58+
params = params.lookahead(lookahead);
59+
}
60+
let wallet: PersistedWallet<BdkConnection> = params.create_wallet(db)?;
6161
Ok(Wallet {
6262
inner_mutex: Mutex::new(wallet),
6363
})

0 commit comments

Comments
 (0)