mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
chaintopology: always cap max block to bitcoind's block height.
We only did this when we were first creating a wallet, or when we asked for a relative rescan, not in the normal case! Fixes: #1843 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
74521b3fb7
commit
ab0fa7a1bd
@ -568,15 +568,7 @@ static void get_init_blockhash(struct bitcoind *bitcoind, u32 blockcount,
|
||||
* go back to that height. This might be a new node catching up, or
|
||||
* bitcoind is processing a reorg. */
|
||||
if (blockcount < topo->max_blockheight) {
|
||||
if (bitcoind->ld->config.rescan < 0) {
|
||||
/* Absolute blockheight, but bitcoind's blockheight isn't there yet */
|
||||
/* Protect against underflow in subtraction.
|
||||
* Possible in regtest mode. */
|
||||
if (blockcount < 1)
|
||||
topo->max_blockheight = 0;
|
||||
else
|
||||
topo->max_blockheight = blockcount - 1;
|
||||
} else if (topo->max_blockheight == UINT32_MAX) {
|
||||
if (topo->max_blockheight == UINT32_MAX) {
|
||||
/* Relative rescan, but we didn't know the blockheight */
|
||||
/* Protect against underflow in subtraction.
|
||||
* Possible in regtest mode. */
|
||||
@ -584,6 +576,14 @@ static void get_init_blockhash(struct bitcoind *bitcoind, u32 blockcount,
|
||||
topo->max_blockheight = 0;
|
||||
else
|
||||
topo->max_blockheight = blockcount - bitcoind->ld->config.rescan;
|
||||
} else {
|
||||
/* Absolute blockheight, but bitcoind's blockheight isn't there yet */
|
||||
/* Protect against underflow in subtraction.
|
||||
* Possible in regtest mode. */
|
||||
if (blockcount < 1)
|
||||
topo->max_blockheight = 0;
|
||||
else
|
||||
topo->max_blockheight = blockcount - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user