Skip to content

Commit 1605c13

Browse files
rustyrussellendothermicdev
authored andcommitted
lightningd: fix crash in onchaind replay.
If a tx has already spent one tx we're watching, and it spends another, we try to add it to the hash table twice, which isn't allowed: ``` 2025-02-28T23:00:32.155Z **BROKEN** lightningd: backtrace: ../sysdeps/unix/sysv/linux/raise.c:51 (__GI_raise) 0x7fab2e363d51 2025-02-28T23:00:32.155Z **BROKEN** lightningd: backtrace: ./stdlib/abort.c:79 (__GI_abort) 0x7fab2e34d536 2025-02-28T23:00:32.155Z **BROKEN** lightningd: backtrace: ./assert/assert.c:92 (__assert_fail_base) 0x7fab2e34d40e 2025-02-28T23:00:32.155Z **BROKEN** lightningd: backtrace: ./assert/assert.c:101 (__GI___assert_fail) 0x7fab2e35c6d1 2025-02-28T23:00:32.155Z **BROKEN** lightningd: backtrace: lightningd/onchain_control.c:48 (replay_tx_hash_add) 0x556928d4e114 2025-02-28T23:00:32.155Z **BROKEN** lightningd: backtrace: lightningd/onchain_control.c:365 (replay_watch_tx) 0x556928d4e114 2025-02-28T23:00:32.155Z **BROKEN** lightningd: backtrace: lightningd/onchain_control.c:419 (replay_block) 0x556928d4e835 2025-02-28T23:00:32.155Z **BROKEN** lightningd: backtrace: lightningd/bitcoind.c:506 (getrawblockbyheight_callback) 0x556928d1c791 ``` Fixes: #8131 Reported-by: Vincenzo Palazzo Changelog-None: introduced this release, when we banned htable dups. Signed-off-by: Rusty Russell <[email protected]>
1 parent 3f81dc0 commit 1605c13

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lightningd/onchain_control.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,11 @@ static void replay_watch_tx(struct channel *channel,
362362
rtx->blockheight = blockheight;
363363
rtx->tx = clone_bitcoin_tx(rtx, tx);
364364

365-
replay_tx_hash_add(channel->onchaind_replay_watches, rtx);
365+
/* We might already be watching, in which case don't re-add! */
366+
if (replay_tx_hash_get(channel->onchaind_replay_watches, &rtx->txid))
367+
tal_free(rtx);
368+
else
369+
replay_tx_hash_add(channel->onchaind_replay_watches, rtx);
366370
}
367371

368372
/* We've finished replaying, turn any txs left into live watches */

0 commit comments

Comments
 (0)