From 4055393ad5bae021305b2e7c32916e5a2a8a30b2 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Thu, 22 Feb 2024 10:03:18 +1300 Subject: [PATCH] wallet: avoid database lookups for non-interesting script types Signed-off-by: Jon Griffiths --- wallet/wallet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wallet/wallet.c b/wallet/wallet.c index 29537737c..9c75d90ef 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -798,7 +798,7 @@ bool wallet_can_spend(struct wallet *w, const u8 *script, u32 *index, bool *output_is_p2sh) { struct ext_key ext; - u64 bip32_max_index = db_get_intvar(w->db, "bip32_max_index", 0); + u64 bip32_max_index; size_t script_len = tal_bytelen(script); u32 i; @@ -812,6 +812,7 @@ bool wallet_can_spend(struct wallet *w, const u8 *script, else return false; + bip32_max_index = db_get_intvar(w->db, "bip32_max_index", 0); for (i = 0; i <= bip32_max_index + w->keyscan_gap; i++) { u8 *s;