Once we're run out of new blocks to add, call this. */
| 861 | |
| 862 | /* Once we're run out of new blocks to add, call this. */ |
| 863 | static void updates_complete(struct chain_topology *topo) |
| 864 | { |
| 865 | if (!bitcoin_blkid_eq(&topo->tip->blkid, &topo->prev_tip)) { |
| 866 | /* Tell lightningd about new block. */ |
| 867 | notify_new_block(topo->bitcoind->ld); |
| 868 | |
| 869 | /* Tell blockdepth watchers */ |
| 870 | watch_check_block_added(topo, topo->tip->height); |
| 871 | |
| 872 | /* Tell watch code to re-evaluate all txs. */ |
| 873 | watch_topology_changed(topo); |
| 874 | |
| 875 | /* Maybe need to rebroadcast. */ |
| 876 | rebroadcast_txs(topo); |
| 877 | |
| 878 | /* We've processed these UTXOs */ |
| 879 | db_set_intvar(topo->bitcoind->ld->wallet->db, |
| 880 | "last_processed_block", topo->tip->height); |
| 881 | |
| 882 | topo->prev_tip = topo->tip->blkid; |
| 883 | |
| 884 | /* Send out an account balance snapshot */ |
| 885 | if (!first_update_complete) { |
| 886 | send_account_balance_snapshot(topo->ld); |
| 887 | first_update_complete = true; |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | /* If bitcoind is synced, we're now synced. */ |
| 892 | if (topo->bitcoind->synced && !topology_synced(topo)) { |
| 893 | struct sync_waiter *w; |
| 894 | struct list_head *list = topo->sync_waiters; |
| 895 | |
| 896 | /* Mark topology_synced() before callbacks. */ |
| 897 | topo->sync_waiters = NULL; |
| 898 | |
| 899 | while ((w = list_pop(list, struct sync_waiter, list))) { |
| 900 | /* In case it doesn't free itself. */ |
| 901 | tal_del_destructor(w, destroy_sync_waiter); |
| 902 | tal_steal(list, w); |
| 903 | w->cb(topo, w->arg); |
| 904 | } |
| 905 | tal_free(list); |
| 906 | } |
| 907 | |
| 908 | /* Try again soon. */ |
| 909 | next_topology_timer(topo); |
| 910 | } |
| 911 | |
| 912 | static void record_wallet_spend(struct lightningd *ld, |
| 913 | const struct bitcoin_outpoint *outpoint, |
no test coverage detected