diff --git a/channeld/channeld.c b/channeld/channeld.c index 812f2a117b71..ba2c083e399e 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -444,8 +444,20 @@ static void check_mutual_splice_locked(struct peer *peer) if (short_channel_id_eq(peer->short_channel_ids[LOCAL], peer->splice_state->short_channel_id)) - peer_failed_warn(peer->pps, &peer->channel_id, - "Duplicate splice_locked events detected"); + peer_failed_err(peer->pps, &peer->channel_id, + "Duplicate splice_locked events detected" + " by scid check"); + + if (!peer->splice_state->remote_locked_txid + || !bitcoin_txid_eq(peer->splice_state->remote_locked_txid, + &peer->splice_state->locked_txid)) + peer_failed_err(peer->pps, &peer->channel_id, + "splice_locked message txid %s does not match" + " our locked txid %s", + fmt_bitcoin_txid(tmpctx, + peer->splice_state->remote_locked_txid), + fmt_bitcoin_txid(tmpctx, + &peer->splice_state->locked_txid)); peer->splice_state->await_commitment_succcess = true; @@ -473,7 +485,7 @@ static void check_mutual_splice_locked(struct peer *peer) inflight = peer->splice_state->inflights[i]; if (!inflight) - peer_failed_warn(peer->pps, &peer->channel_id, + peer_failed_err(peer->pps, &peer->channel_id, "Unable to find inflight txid amoung %zu" " inflights. new funding txid: %s", tal_count(peer->splice_state->inflights), @@ -487,7 +499,7 @@ static void check_mutual_splice_locked(struct peer *peer) inflight->amnt, inflight->splice_amnt); if (error) - peer_failed_warn(peer->pps, &peer->channel_id, + peer_failed_err(peer->pps, &peer->channel_id, "Splice lock unable to update funding. %s", error); @@ -508,6 +520,7 @@ static void check_mutual_splice_locked(struct peer *peer) peer->splice_state->inflights = tal_free(peer->splice_state->inflights); peer->splice_state->count = 0; + peer->splice_state->remote_locked_txid = tal_free(peer->splice_state->remote_locked_txid); } /* Our peer told us they saw our splice confirm on chain with `splice_locked`. @@ -522,6 +535,16 @@ static void handle_peer_splice_locked(struct peer *peer, const u8 *msg) peer_failed_warn(peer->pps, &peer->channel_id, "Bad splice_locked %s", tal_hex(msg, msg)); + if (peer->splice_state->remote_locked_txid) + peer_failed_err(peer->pps, &chanid, + "Peer sent duplicate splice_locked message %s", + tal_hex(tmpctx, msg)); + + peer->splice_state->remote_locked_txid = tal(peer->splice_state, + struct bitcoin_txid); + + *peer->splice_state->remote_locked_txid = splice_txid; + if (!channel_id_eq(&chanid, &peer->channel_id)) peer_failed_err(peer->pps, &chanid, "Wrong splice lock channel id in %s " diff --git a/channeld/splice.c b/channeld/splice.c index 3ef245f7d9ed..e72b4af54830 100644 --- a/channeld/splice.c +++ b/channeld/splice.c @@ -11,6 +11,7 @@ struct splice_state *splice_state_new(const tal_t *ctx) splice_state->locked_ready[REMOTE] = false; splice_state->await_commitment_succcess = false; splice_state->inflights = NULL; + splice_state->remote_locked_txid = NULL; return splice_state; } diff --git a/channeld/splice.h b/channeld/splice.h index 92bea28284e4..be6f7ff583d1 100644 --- a/channeld/splice.h +++ b/channeld/splice.h @@ -21,6 +21,8 @@ struct splice_state { bool await_commitment_succcess; /* The txid of which splice inflight was confirmed */ struct bitcoin_txid locked_txid; + /* The txid our peer locked their splice on */ + struct bitcoin_txid *remote_locked_txid; /* The number of splices that are active (awaiting confirmation) */ u32 count; };