Skip to content

Commit

Permalink
bdk: set a reasonable default lookahead when creating a wallet
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
darosior committed Nov 27, 2023
1 parent 55b680c commit 2194abb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/bdk/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ use crate::wallet::error::{BuildFeeBumpError, CreateTxError, MiniscriptPsbtError

const COINBASE_MATURITY: u32 = 100;

// The default "gap limit" for a wallet.
const DEFAULT_LOOKAHEAD: u32 = 1_000;

/// A Bitcoin wallet
///
/// The `Wallet` struct acts as a way of coherently interfacing with output descriptors and related transactions.
Expand Down Expand Up @@ -456,6 +459,7 @@ impl<D> Wallet<D> {
let secp = Secp256k1::new();
let (chain, chain_changeset) = LocalChain::from_genesis_hash(genesis_hash);
let mut index = KeychainTxOutIndex::<KeychainKind>::default();
index.set_lookahead_for_all(DEFAULT_LOOKAHEAD);

let (signers, change_signers) =
create_signers(&mut index, &secp, descriptor, change_descriptor, network)
Expand Down

0 comments on commit 2194abb

Please sign in to comment.