lightningd: fix bug where we didn't correctly change outpoint of splice scid.

We used the original channel funding output number.  I'm not sure if this
was true in the previous code, or a regression I introduced, but it
caused occasonal failures in test_splice_gossip!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-10-02 09:29:52 +10:30
parent 854bda81ac
commit 3ca753e0b4
5 changed files with 13 additions and 9 deletions

View file

@ -543,7 +543,8 @@ static void handle_splice_confirmed_signed(struct lightningd *ld,
}
bool depthcb_update_scid(struct channel *channel,
const struct bitcoin_txid *txid)
const struct bitcoin_txid *txid,
const struct bitcoin_outpoint *outpoint)
{
struct txlocator *loc;
struct lightningd *ld = channel->peer->ld;
@ -553,17 +554,17 @@ bool depthcb_update_scid(struct channel *channel,
loc = wallet_transaction_locate(tmpctx, ld->wallet, txid);
if (!mk_short_channel_id(&scid,
loc->blkheight, loc->index,
channel->funding.n)) {
outpoint->n)) {
channel_fail_permanent(channel,
REASON_LOCAL,
"Invalid funding scid %u:%u:%u",
loc->blkheight, loc->index,
channel->funding.n);
outpoint->n);
return false;
}
if (!channel->scid) {
wallet_annotate_txout(ld->wallet, &channel->funding,
wallet_annotate_txout(ld->wallet, outpoint,
TX_CHANNEL_FUNDING, channel->dbid);
channel->scid = tal_dup(channel, struct short_channel_id, &scid);
@ -606,7 +607,7 @@ static enum watch_result splice_depth_cb(struct lightningd *ld,
if (depth == 0)
return KEEP_WATCHING;
if (!depthcb_update_scid(inflight->channel, txid))
if (!depthcb_update_scid(inflight->channel, txid, &inflight->funding->outpoint))
return DELETE_WATCH;
if (inflight->channel->owner) {

View file

@ -60,5 +60,6 @@ void watch_splice_inflight(struct lightningd *ld,
/* Update/set scid now this txid is mined. */
bool depthcb_update_scid(struct channel *channel,
const struct bitcoin_txid *txid);
const struct bitcoin_txid *txid,
const struct bitcoin_outpoint *outpoint);
#endif /* LIGHTNING_LIGHTNINGD_CHANNEL_CONTROL_H */

View file

@ -1950,7 +1950,7 @@ static enum watch_result funding_depth_cb(struct lightningd *ld,
return KEEP_WATCHING;
}
if (!depthcb_update_scid(channel, txid))
if (!depthcb_update_scid(channel, txid, &channel->funding))
return DELETE_WATCH;
/* Always tell owner about depth change */

View file

@ -200,7 +200,8 @@ void delete_channel(struct channel *channel STEALS UNNEEDED)
{ fprintf(stderr, "delete_channel called!\n"); abort(); }
/* Generated stub for depthcb_update_scid */
bool depthcb_update_scid(struct channel *channel UNNEEDED,
const struct bitcoin_txid *txid UNNEEDED)
const struct bitcoin_txid *txid UNNEEDED,
const struct bitcoin_outpoint *outpoint UNNEEDED)
{ fprintf(stderr, "depthcb_update_scid called!\n"); abort(); }
/* Generated stub for dev_disconnect_permanent */
bool dev_disconnect_permanent(struct lightningd *ld UNNEEDED)

View file

@ -141,7 +141,8 @@ struct onionreply *create_onionreply(const tal_t *ctx UNNEEDED,
{ fprintf(stderr, "create_onionreply called!\n"); abort(); }
/* Generated stub for depthcb_update_scid */
bool depthcb_update_scid(struct channel *channel UNNEEDED,
const struct bitcoin_txid *txid UNNEEDED)
const struct bitcoin_txid *txid UNNEEDED,
const struct bitcoin_outpoint *outpoint UNNEEDED)
{ fprintf(stderr, "depthcb_update_scid called!\n"); abort(); }
/* Generated stub for derive_channel_id */
void derive_channel_id(struct channel_id *channel_id UNNEEDED,