Skip to content

Commit d7b0f1f

Browse files
enaplesmadelinevibes
authored andcommitted
lightningd: don't try to re-xmit funding tx for already-confirmed channels.
`resend_opening_transactions` runs at startup before `begin_topology()`, so `channel->depth` is still 0 (its DB-load default) for every channel. The `depth != 0` guard was therefore a no-op, and we issued a `sendrawtransaction` for every committed channel on every restart. For long-confirmed channels bitcoind replies with error `-27` ("Transaction outputs already in utxo set"), surfacing as an `UNUSUAL` log on every startup. Gate on channel state instead: only the three states where the funding or splice tx can still be unconfirmed (`CHANNELD_AWAITING_LOCKIN`, DUALOPEND_AWAITING_LOCKIN`, `CHANNELD_AWAITING_SPLICE`) qualify for rebroadcast. Changelog-Fixed: lightningd: don't spuriously try to re-broadcast funding txs of already-confirmed channels on startup.
1 parent 6aae3d4 commit d7b0f1f

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

lightningd/peer_control.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,12 +565,16 @@ void resend_opening_transactions(struct lightningd *ld)
565565
peer = peer_node_id_map_next(ld->peers, &it)) {
566566
list_for_each(&peer->channels, channel, list) {
567567
struct wally_tx *wtx;
568-
if (channel_state_uncommitted(channel->state))
568+
/* Only states where the funding/splice tx might
569+
* still be unconfirmed. channel->depth can't be
570+
* used here: it's reset to 0 on DB load and only
571+
* repopulated once topology starts. */
572+
if (channel->state != CHANNELD_AWAITING_LOCKIN
573+
&& channel->state != DUALOPEND_AWAITING_LOCKIN
574+
&& channel->state != CHANNELD_AWAITING_SPLICE)
569575
continue;
570576
if (!channel->funding_psbt || channel->withheld)
571577
continue;
572-
if (channel->depth != 0)
573-
continue;
574578
wtx = psbt_final_tx(tmpctx, channel->funding_psbt);
575579
if (!wtx)
576580
continue;

tests/test_opening.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3087,5 +3087,5 @@ def test_no_retransmit_confirmed_funding(node_factory):
30873087
l1.restart()
30883088

30893089
# Should not have attempted (and failed) to re-broadcast the funding tx.
3090-
assert l1.daemon.is_in_log('Failed to re-transmit funding tx')
3090+
assert not l1.daemon.is_in_log('Failed to re-transmit funding tx')
30913091
assert not l1.daemon.is_in_log('Successfully rexmitted funding tx')

0 commit comments

Comments
 (0)