wallet: avoid computing the key fingerprint while looking for matches

Avoids a hash160 for every key we derive to test. Callers that need the
key re-derive it without the skip flag, so there are no side effects
from this optimization.

Changelog-Changed: core: Processing blocks should now be faster

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
This commit is contained in:
Jon Griffiths 2024-02-22 10:03:57 +13:00 committed by Rusty Russell
parent f01e9fe160
commit 156a16e7e6

View file

@ -815,11 +815,11 @@ bool wallet_can_spend(struct wallet *w, const u8 *script,
bip32_max_index = db_get_intvar(w->db, "bip32_max_index", 0);
for (i = 0; i <= bip32_max_index + w->keyscan_gap; i++) {
const u32 flags = BIP32_FLAG_KEY_PUBLIC | BIP32_FLAG_SKIP_HASH;
u8 *s;
if (bip32_key_from_parent(w->ld->bip32_base, i,
BIP32_FLAG_KEY_PUBLIC, &ext)
!= WALLY_OK) {
flags, &ext) != WALLY_OK) {
abort();
}
s = scriptpubkey_p2wpkh_derkey(w, ext.pub_key);