~ 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. */
| 585 | * keep the maximum-ever-used key index in the db, and add them all to the |
| 586 | * filter here. */ |
| 587 | static 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. |
no test coverage detected