Skip to content

Commit

Permalink
wallet: avoid computing the key fingerprint while looking for matches
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jgriffiths authored and rustyrussell committed Mar 18, 2024
1 parent f01e9fe commit 156a16e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 156a16e

Please sign in to comment.