MCPcopy Create free account
hub / github.com/ElementsProject/lightning / init_txfilter

Function init_txfilter

lightningd/lightningd.c:587–603  ·  view source on GitHub ↗

~ Our wallet logic needs to know what outputs we might be interested in. We * use BIP32 (a.k.a. "HD wallet") to generate keys from a single seed, so we * keep the maximum-ever-used key index in the db, and add them all to the * filter here. */

Source from the content-addressed store, hash-verified

585 * keep the maximum-ever-used key index in the db, and add them all to the
586 * filter here. */
587static void init_txfilter(struct wallet *w, struct txfilter *filter)
588{
589 /*~ This is defined in libwally, so we didn't have to reimplement */
590 struct ext_key ext;
591 /*~ Note the use of ccan/short_types u64 rather than uint64_t.
592 * Thank me later. */
593 u64 bip32_max_index;
594
595 bip32_max_index = db_get_intvar(w->db, "bip32_max_index", 0);
596 /*~ One of the C99 things I unequivocally approve: for-loop scope. */
597 for (u64 i = 0; i <= bip32_max_index + w->keyscan_gap; i++) {
598 if (bip32_key_from_parent(w->bip32_base, i, BIP32_FLAG_KEY_PUBLIC, &ext) != WALLY_OK) {
599 abort();
600 }
601 txfilter_add_derkey(filter, ext.pub_key);
602 }
603}
604
605/*~ The normal advice for daemons is to move into the root directory, so you
606 * don't prevent unmounting whatever filesystem you happen to start in.

Callers 1

mainFunction · 0.85

Calls 3

abortFunction · 0.85
db_get_intvarFunction · 0.50
txfilter_add_derkeyFunction · 0.50

Tested by

no test coverage detected