@@ -925,6 +925,8 @@ pub(super) struct ReestablishResponses {
925925 pub order: RAACommitmentOrder,
926926 pub announcement_sigs: Option<msgs::AnnouncementSignatures>,
927927 pub shutdown_msg: Option<msgs::Shutdown>,
928+ pub tx_signatures: Option<msgs::TxSignatures>,
929+ pub tx_abort: Option<msgs::TxAbort>,
928930}
929931
930932/// The result of a shutdown that should be handled.
@@ -6388,6 +6390,8 @@ impl<SP: Deref> Channel<SP> where
63886390 raa: None, commitment_update: None,
63896391 order: RAACommitmentOrder::CommitmentFirst,
63906392 shutdown_msg, announcement_sigs,
6393+ tx_signatures: None,
6394+ tx_abort: None,
63916395 });
63926396 }
63936397
@@ -6397,6 +6401,8 @@ impl<SP: Deref> Channel<SP> where
63976401 raa: None, commitment_update: None,
63986402 order: RAACommitmentOrder::CommitmentFirst,
63996403 shutdown_msg, announcement_sigs,
6404+ tx_signatures: None,
6405+ tx_abort: None,
64006406 });
64016407 }
64026408
@@ -6435,7 +6441,55 @@ impl<SP: Deref> Channel<SP> where
64356441 Some(self.get_channel_ready())
64366442 } else { None };
64376443
6438- if msg.next_local_commitment_number == next_counterparty_commitment_number {
6444+ // if next_funding_txid is set:
6445+ if let Some(next_funding_txid) = msg.next_funding_txid {
6446+ let (commitment_update, tx_signatures, tx_abort) = if let Some(session) = &self.interactive_tx_signing_session {
6447+ // if next_funding_txid matches the latest interactive funding transaction:
6448+ if session.unsigned_tx.compute_txid() == next_funding_txid {
6449+ // if it has not received tx_signatures for that funding transaction:
6450+ if !session.counterparty_sent_tx_signatures {
6451+ // MUST retransmit its commitment_signed for that funding transaction.
6452+ let commitment_signed = self.context.get_initial_commitment_signed(logger)?;
6453+ let commitment_update = Some(msgs::CommitmentUpdate {
6454+ commitment_signed,
6455+ update_add_htlcs: vec![],
6456+ update_fulfill_htlcs: vec![],
6457+ update_fail_htlcs: vec![],
6458+ update_fail_malformed_htlcs: vec![],
6459+ update_fee: None,
6460+ });
6461+ // if it has already received commitment_signed and it should sign first, as specified in the tx_signatures requirements:
6462+ if session.received_commitment_signed && session.holder_sends_tx_signatures_first {
6463+ // MUST send its tx_signatures for that funding transaction.
6464+ (commitment_update, session.holder_tx_signatures.clone(), None)
6465+ } else {
6466+ (commitment_update, None, None)
6467+ }
6468+ } else {
6469+ // if it has already received tx_signatures for that funding transaction:
6470+ // MUST send its tx_signatures for that funding transaction.
6471+ (None, session.holder_tx_signatures.clone(), None)
6472+ }
6473+ } else {
6474+ // MUST send tx_abort to let the sending node know that they can forget this funding transaction.
6475+ (None, None, Some(msgs::TxAbort { channel_id: self.context.channel_id(), data: vec![] }))
6476+ }
6477+ } else {
6478+ // Counterparty set `next_funding_txid` at incorrect state.
6479+ // TODO(dual_funding): Should probably error here (or send tx_abort) but not in spec.
6480+ (None, None, None)
6481+ };
6482+ Ok(ReestablishResponses {
6483+ channel_ready,
6484+ commitment_update,
6485+ announcement_sigs,
6486+ shutdown_msg,
6487+ tx_signatures,
6488+ tx_abort,
6489+ raa: None,
6490+ order: self.context.resend_order.clone(),
6491+ })
6492+ } else if msg.next_local_commitment_number == next_counterparty_commitment_number {
64396493 if required_revoke.is_some() || self.context.signer_pending_revoke_and_ack {
64406494 log_debug!(logger, "Reconnected channel {} with only lost outbound RAA", &self.context.channel_id());
64416495 } else {
@@ -6447,6 +6501,8 @@ impl<SP: Deref> Channel<SP> where
64476501 raa: required_revoke,
64486502 commitment_update: None,
64496503 order: self.context.resend_order.clone(),
6504+ tx_signatures: None,
6505+ tx_abort: None,
64506506 })
64516507 } else if msg.next_local_commitment_number == next_counterparty_commitment_number - 1 {
64526508 if required_revoke.is_some() || self.context.signer_pending_revoke_and_ack {
@@ -6461,6 +6517,8 @@ impl<SP: Deref> Channel<SP> where
64616517 channel_ready, shutdown_msg, announcement_sigs,
64626518 commitment_update: None, raa: None,
64636519 order: self.context.resend_order.clone(),
6520+ tx_signatures: None,
6521+ tx_abort: None,
64646522 })
64656523 } else {
64666524 let commitment_update = if self.context.resend_order == RAACommitmentOrder::RevokeAndACKFirst
@@ -6483,6 +6541,8 @@ impl<SP: Deref> Channel<SP> where
64836541 channel_ready, shutdown_msg, announcement_sigs,
64846542 raa, commitment_update,
64856543 order: self.context.resend_order.clone(),
6544+ tx_signatures: None,
6545+ tx_abort: None,
64866546 })
64876547 }
64886548 } else if msg.next_local_commitment_number < next_counterparty_commitment_number {
0 commit comments