@@ -4406,6 +4406,16 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
44064406 peer_failed_warn (peer -> pps , & peer -> channel_id ,
44074407 "Splice internal error: mismatched channelid" );
44084408
4409+ /* The spec requires us to fail if they splice out more than their current channel balance */
4410+ if (!amount_msat_can_add_sat_s64 (peer -> channel -> view -> owed [REMOTE ],
4411+ peer -> splicing -> opener_relative ))
4412+ peer_failed_warn (peer -> pps , & peer -> channel_id ,
4413+ "Splice contribution %" PRId64 "sat exceeds"
4414+ " peer balance %s" ,
4415+ peer -> splicing -> opener_relative ,
4416+ fmt_amount_msat (tmpctx ,
4417+ peer -> channel -> view -> owed [REMOTE ]));
4418+
44094419 if (!pubkey_eq (& peer -> splicing -> remote_funding_pubkey ,
44104420 & peer -> channel -> funding_pubkey [REMOTE ]))
44114421 status_info ("Splice peer is rotating funding pubkey" );
@@ -4614,6 +4624,16 @@ static void splice_initiator(struct peer *peer, const u8 *inmsg)
46144624 peer_failed_warn (peer -> pps , & peer -> channel_id ,
46154625 "Splice[ACK] internal error: mismatched channelid" );
46164626
4627+ /* The spec requires us to fail if they splice out more than their current channel balance */
4628+ if (!amount_msat_can_add_sat_s64 (peer -> channel -> view -> owed [REMOTE ],
4629+ peer -> splicing -> accepter_relative ))
4630+ peer_failed_warn (peer -> pps , & peer -> channel_id ,
4631+ "Splice[ACK] contribution %" PRId64 "sat exceeds"
4632+ " peer balance %s" ,
4633+ peer -> splicing -> accepter_relative ,
4634+ fmt_amount_msat (tmpctx ,
4635+ peer -> channel -> view -> owed [REMOTE ]));
4636+
46174637 if (!pubkey_eq (& peer -> splicing -> remote_funding_pubkey ,
46184638 & peer -> channel -> funding_pubkey [REMOTE ]))
46194639 status_info ("Splice[ACK] peer is rotating funding pubkey" );
0 commit comments