Skip to content

Commit 9c2ead2

Browse files
committed
Update commitment_signed retransmission for next_funding
The next_funding TLV is included in channel_reestablish when either tx_signatures or commitment_signed is needed for an interactive-tx session. This commit largely includes the spec requirements in the comments, including when to retransmit commitment_signed. But it also adds an additional check that tx_signatures has not yet been received.
1 parent 3564646 commit 9c2ead2

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

lightning/src/ln/channel.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9451,9 +9451,10 @@ where
94519451
let mut tx_signatures = None;
94529452
let mut tx_abort = None;
94539453

9454-
// if next_funding is set:
9454+
// A receiving node:
9455+
// - if the `next_funding` TLV is set:
94559456
if let Some(next_funding) = &msg.next_funding {
9456-
// - if `next_funding` matches the latest interactive funding transaction
9457+
// - if `next_funding_txid` matches the latest interactive funding transaction
94579458
// or the current channel funding transaction:
94589459
if let Some(session) = &self.context.interactive_tx_signing_session {
94599460
let our_next_funding_txid = session.unsigned_tx().compute_txid();
@@ -9468,8 +9469,12 @@ where
94689469
self.context.expecting_peer_commitment_signed = true;
94699470
}
94709471

9471-
// TODO(splicing): Add comment for spec requirements
9472-
if next_funding.should_retransmit(msgs::NextFundingFlag::CommitmentSigned) {
9472+
// - if it has not received `tx_signatures` for that funding transaction:
9473+
// - if the `commitment_signed` bit is set in `retransmit_flags`:
9474+
if !session.has_received_tx_signatures()
9475+
&& next_funding.should_retransmit(msgs::NextFundingFlag::CommitmentSigned)
9476+
{
9477+
// - MUST retransmit its `commitment_signed` for that funding transaction.
94739478
let funding = self
94749479
.pending_splice
94759480
.as_ref()
@@ -11307,26 +11312,31 @@ where
1130711312
}
1130811313

1130911314
fn maybe_get_next_funding(&self) -> Option<msgs::NextFunding> {
11310-
// If we've sent `commtiment_signed` for an interactively constructed transaction
11311-
// during a signing session, but have not received `tx_signatures` we MUST set `next_funding`
11312-
// to the txid of that interactive transaction, else we MUST NOT set it.
11315+
// The sending node:
11316+
// - if it has sent `commitment_signed` for an interactive transaction construction but
11317+
// it has not received `tx_signatures`:
1131311318
self.context
1131411319
.interactive_tx_signing_session
1131511320
.as_ref()
1131611321
.filter(|session| !session.has_received_tx_signatures())
1131711322
.map(|signing_session| {
11323+
// - MUST include the `next_funding` TLV.
11324+
// - MUST set `next_funding_txid` to the txid of that interactive transaction.
1131811325
let mut next_funding = msgs::NextFunding {
1131911326
txid: signing_session.unsigned_tx().compute_txid(),
1132011327
retransmit_flags: 0,
1132111328
};
1132211329

11323-
// TODO(splicing): Add comment for spec requirements
11330+
// - if it has not received `commitment_signed` for this `next_funding_txid`:
11331+
// - MUST set the `commitment_signed` bit in `retransmit_flags`.
1132411332
if !signing_session.has_received_commitment_signed() {
1132511333
next_funding.retransmit(msgs::NextFundingFlag::CommitmentSigned);
1132611334
}
1132711335

1132811336
next_funding
1132911337
})
11338+
// - otherwise:
11339+
// - MUST NOT include the `next_funding` TLV.
1133011340
}
1133111341

1133211342
fn maybe_get_my_current_funding_locked(&self) -> Option<msgs::FundingLocked> {

0 commit comments

Comments
 (0)