| 966 | } |
| 967 | |
| 968 | static void check_blockcount(struct chain_topology *topo, u32 blockcount) |
| 969 | { |
| 970 | /* If bitcoind's current blockheight is below the requested |
| 971 | * height, refuse. You can always explicitly request a reindex from |
| 972 | * that block number using --rescan=. */ |
| 973 | if (blockcount < topo->max_blockheight) { |
| 974 | /* UINT32_MAX == no blocks in database */ |
| 975 | if (topo->max_blockheight == UINT32_MAX) { |
| 976 | /* Relative rescan, but we didn't know the blockheight */ |
| 977 | /* Protect against underflow in subtraction. |
| 978 | * Possible in regtest mode. */ |
| 979 | if (blockcount < topo->bitcoind->ld->config.rescan) |
| 980 | topo->max_blockheight = 0; |
| 981 | else |
| 982 | topo->max_blockheight = blockcount - topo->bitcoind->ld->config.rescan; |
| 983 | } else |
| 984 | fatal("bitcoind has gone backwards from %u to %u blocks!", |
| 985 | topo->max_blockheight, blockcount); |
| 986 | } |
| 987 | |
| 988 | /* Rollback to the given blockheight, so we start track |
| 989 | * correctly again */ |
| 990 | wallet_blocks_rollback(topo->ld->wallet, topo->max_blockheight); |
| 991 | /* This may have unconfirmed txs: reconfirm as we add blocks. */ |
| 992 | watch_for_utxo_reconfirmation(topo, topo->ld->wallet); |
| 993 | } |
| 994 | |
| 995 | static void retry_check_chain(struct chain_topology *topo); |
| 996 |
no test coverage detected