Skip to content

Commit 2194abb

Browse files
committed
bdk: set a reasonable default lookahead when creating a wallet
The wallet is currently created without setting any lookahead value for the keychain. This implicitly makes it a lookahead of 0. As this is a high-level interface we should avoid footguns and aim for a reasonable default.
1 parent 55b680c commit 2194abb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/bdk/src/wallet/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ use crate::wallet::error::{BuildFeeBumpError, CreateTxError, MiniscriptPsbtError
7575

7676
const COINBASE_MATURITY: u32 = 100;
7777

78+
// The default "gap limit" for a wallet.
79+
const DEFAULT_LOOKAHEAD: u32 = 1_000;
80+
7881
/// A Bitcoin wallet
7982
///
8083
/// The `Wallet` struct acts as a way of coherently interfacing with output descriptors and related transactions.
@@ -456,6 +459,7 @@ impl<D> Wallet<D> {
456459
let secp = Secp256k1::new();
457460
let (chain, chain_changeset) = LocalChain::from_genesis_hash(genesis_hash);
458461
let mut index = KeychainTxOutIndex::<KeychainKind>::default();
462+
index.set_lookahead_for_all(DEFAULT_LOOKAHEAD);
459463

460464
let (signers, change_signers) =
461465
create_signers(&mut index, &secp, descriptor, change_descriptor, network)

0 commit comments

Comments
 (0)