@@ -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.
@@ -6391,6 +6393,8 @@ impl<SP: Deref> Channel<SP> where
63916393 raa: None, commitment_update: None,
63926394 order: RAACommitmentOrder::CommitmentFirst,
63936395 shutdown_msg, announcement_sigs,
6396+ tx_signatures: None,
6397+ tx_abort: None,
63946398 });
63956399 }
63966400
@@ -6400,6 +6404,8 @@ impl<SP: Deref> Channel<SP> where
64006404 raa: None, commitment_update: None,
64016405 order: RAACommitmentOrder::CommitmentFirst,
64026406 shutdown_msg, announcement_sigs,
6407+ tx_signatures: None,
6408+ tx_abort: None,
64036409 });
64046410 }
64056411
@@ -6445,11 +6451,53 @@ impl<SP: Deref> Channel<SP> where
64456451 log_debug!(logger, "Reconnected channel {} with no loss", &self.context.channel_id());
64466452 }
64476453
6454+ // if next_funding_txid is set:
6455+ let (commitment_update, tx_signatures, tx_abort) = if let Some(next_funding_txid) = msg.next_funding_txid {
6456+ if let Some(session) = &self.interactive_tx_signing_session {
6457+ // if next_funding_txid matches the latest interactive funding transaction:
6458+ if session.unsigned_tx.compute_txid() == next_funding_txid {
6459+ // if it has not received tx_signatures for that funding transaction:
6460+ if !session.counterparty_sent_tx_signatures {
6461+ // MUST retransmit its commitment_signed for that funding transaction.
6462+ let commitment_signed = self.context.get_initial_commitment_signed(logger)?;
6463+ let commitment_update = Some(msgs::CommitmentUpdate {
6464+ commitment_signed,
6465+ update_add_htlcs: vec![],
6466+ update_fulfill_htlcs: vec![],
6467+ update_fail_htlcs: vec![],
6468+ update_fail_malformed_htlcs: vec![],
6469+ update_fee: None,
6470+ });
6471+ // if it has already received commitment_signed and it should sign first, as specified in the tx_signatures requirements:
6472+ if session.received_commitment_signed && session.holder_sends_tx_signatures_first {
6473+ // MUST send its tx_signatures for that funding transaction.
6474+ (commitment_update, session.holder_tx_signatures.clone(), None)
6475+ } else {
6476+ (commitment_update, None, None)
6477+ }
6478+ } else {
6479+ // if it has already received tx_signatures for that funding transaction:
6480+ // MUST send its tx_signatures for that funding transaction.
6481+ (None, session.holder_tx_signatures.clone(), None)
6482+ }
6483+ } else {
6484+ // MUST send tx_abort to let the sending node know that they can forget this funding transaction.
6485+ (None, None, Some(msgs::TxAbort { channel_id: self.context.channel_id(), data: vec![] }))
6486+ }
6487+ } else {
6488+ // Counterparty set `next_funding_txid` at incorrect state.
6489+ // TODO(dual_funding): Should probably error here (or send tx_abort) but not in spec.
6490+ (None, None, None)
6491+ }
6492+ } else { (None, None, None) };
6493+
64486494 Ok(ReestablishResponses {
64496495 channel_ready, shutdown_msg, announcement_sigs,
64506496 raa: required_revoke,
6451- commitment_update: None ,
6497+ commitment_update,
64526498 order: self.context.resend_order.clone(),
6499+ tx_signatures,
6500+ tx_abort,
64536501 })
64546502 } else if msg.next_local_commitment_number == next_counterparty_commitment_number - 1 {
64556503 if required_revoke.is_some() || self.context.signer_pending_revoke_and_ack {
@@ -6464,6 +6512,8 @@ impl<SP: Deref> Channel<SP> where
64646512 channel_ready, shutdown_msg, announcement_sigs,
64656513 commitment_update: None, raa: None,
64666514 order: self.context.resend_order.clone(),
6515+ tx_signatures: None,
6516+ tx_abort: None,
64676517 })
64686518 } else {
64696519 let commitment_update = if self.context.resend_order == RAACommitmentOrder::RevokeAndACKFirst
@@ -6486,6 +6536,8 @@ impl<SP: Deref> Channel<SP> where
64866536 channel_ready, shutdown_msg, announcement_sigs,
64876537 raa, commitment_update,
64886538 order: self.context.resend_order.clone(),
6539+ tx_signatures: None,
6540+ tx_abort: None,
64896541 })
64906542 }
64916543 } else if msg.next_local_commitment_number < next_counterparty_commitment_number {
0 commit comments