Skip to content

Commit

Permalink
wallet: perform wallet_can_spend exit logic only once
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Griffiths <[email protected]>
  • Loading branch information
jgriffiths authored and rustyrussell committed Mar 18, 2024
1 parent 156a16e commit fbd8e8b
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,28 +828,22 @@ bool wallet_can_spend(struct wallet *w, const u8 *script,
tal_free(s);
s = p2sh;
}
if (scripteq(s, script)) {
/* If we found a used key in the keyscan_gap we should
* remember that. */
if (i > bip32_max_index)
db_set_intvar(w->db, "bip32_max_index", i);
if (!scripteq(s, script)) {
/* Try taproot output now */
tal_free(s);
*index = i;
return true;
s = scriptpubkey_p2tr_derkey(w, ext.pub_key);
if (!scripteq(s, script))
s = tal_free(s);
}
tal_free(s);
/* Try taproot output now */
s = scriptpubkey_p2tr_derkey(w, ext.pub_key);
if (scripteq(s, script)) {
if (s) {
/* If we found a used key in the keyscan_gap we should
* remember that. */
if (i > bip32_max_index)
db_set_intvar(w->db, "bip32_max_index", i);
tal_free(s);
*index = i;
return true;
}
tal_free(s);
}
return false;
}
Expand Down

0 comments on commit fbd8e8b

Please sign in to comment.