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