Commit 1e66414
committed
wallet: make sure we re-watch outpoints after blocks are rolled back.
At startup, we load the outpoints to watch, *then* roll back 15
blocks. If there were things in those blocks we wanted to watch, we
no longer do!
1. We load the utxoset into memory: everything in the utxoset table
which has spendheight null.
2. We roll back 15 blocks to re-read. Deleting a block from the
database causes the utxo spentheights referring to it to be set
to null.
3. We roll forward, but we didn't update the in-memory utxoset,
so we're not watching those utxos which are spent.
The main symptom of this is that we spam peers with obsolete gossip
(if we get sent a channel announcement for a closed channel, we can
think it isn't spent yet). But it could *also* mean we don't notice
onchain txs, if we restart at the wrong time!
Changelog-Fixed: lightningd: we could miss tx spends which happened in the past blocks when we restarted.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>1 parent 8caffde commit 1e66414
2 files changed
+21
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2538 | 2538 | | |
2539 | 2539 | | |
2540 | 2540 | | |
2541 | | - | |
2542 | 2541 | | |
2543 | 2542 | | |
2544 | 2543 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
| 184 | + | |
184 | 185 | | |
185 | 186 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | 187 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | 188 | | |
197 | 189 | | |
198 | 190 | | |
199 | 191 | | |
200 | 192 | | |
201 | 193 | | |
| 194 | + | |
202 | 195 | | |
203 | 196 | | |
204 | 197 | | |
205 | 198 | | |
206 | 199 | | |
207 | 200 | | |
208 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
209 | 216 | | |
210 | 217 | | |
211 | 218 | | |
| |||
4867 | 4874 | | |
4868 | 4875 | | |
4869 | 4876 | | |
| 4877 | + | |
| 4878 | + | |
| 4879 | + | |
4870 | 4880 | | |
4871 | 4881 | | |
4872 | 4882 | | |
| |||
4875 | 4885 | | |
4876 | 4886 | | |
4877 | 4887 | | |
| 4888 | + | |
4878 | 4889 | | |
4879 | 4890 | | |
4880 | 4891 | | |
| |||
0 commit comments