@@ -927,6 +927,8 @@ pub(super) struct ReestablishResponses {
927927 pub order: RAACommitmentOrder,
928928 pub announcement_sigs: Option<msgs::AnnouncementSignatures>,
929929 pub shutdown_msg: Option<msgs::Shutdown>,
930+ pub tx_signatures: Option<msgs::TxSignatures>,
931+ pub tx_abort: Option<msgs::TxAbort>,
930932}
931933
932934/// The result of a shutdown that should be handled.
@@ -6594,6 +6596,8 @@ impl<SP: Deref> FundedChannel<SP> where
65946596 raa: None, commitment_update: None,
65956597 order: RAACommitmentOrder::CommitmentFirst,
65966598 shutdown_msg, announcement_sigs,
6599+ tx_signatures: None,
6600+ tx_abort: None,
65976601 });
65986602 }
65996603
@@ -6603,6 +6607,8 @@ impl<SP: Deref> FundedChannel<SP> where
66036607 raa: None, commitment_update: None,
66046608 order: RAACommitmentOrder::CommitmentFirst,
66056609 shutdown_msg, announcement_sigs,
6610+ tx_signatures: None,
6611+ tx_abort: None,
66066612 });
66076613 }
66086614
@@ -6648,11 +6654,53 @@ impl<SP: Deref> FundedChannel<SP> where
66486654 log_debug!(logger, "Reconnected channel {} with no loss", &self.context.channel_id());
66496655 }
66506656
6657+ // if next_funding_txid is set:
6658+ let (commitment_update, tx_signatures, tx_abort) = if let Some(next_funding_txid) = msg.next_funding_txid {
6659+ if let Some(session) = &self.interactive_tx_signing_session {
6660+ // if next_funding_txid matches the latest interactive funding transaction:
6661+ if session.unsigned_tx.compute_txid() == next_funding_txid {
6662+ // if it has not received tx_signatures for that funding transaction:
6663+ if !session.counterparty_sent_tx_signatures {
6664+ // MUST retransmit its commitment_signed for that funding transaction.
6665+ let commitment_signed = self.context.get_initial_commitment_signed(logger)?;
6666+ let commitment_update = Some(msgs::CommitmentUpdate {
6667+ commitment_signed,
6668+ update_add_htlcs: vec![],
6669+ update_fulfill_htlcs: vec![],
6670+ update_fail_htlcs: vec![],
6671+ update_fail_malformed_htlcs: vec![],
6672+ update_fee: None,
6673+ });
6674+ // if it has already received commitment_signed and it should sign first, as specified in the tx_signatures requirements:
6675+ if session.received_commitment_signed && session.holder_sends_tx_signatures_first {
6676+ // MUST send its tx_signatures for that funding transaction.
6677+ (commitment_update, session.holder_tx_signatures.clone(), None)
6678+ } else {
6679+ (commitment_update, None, None)
6680+ }
6681+ } else {
6682+ // if it has already received tx_signatures for that funding transaction:
6683+ // MUST send its tx_signatures for that funding transaction.
6684+ (None, session.holder_tx_signatures.clone(), None)
6685+ }
6686+ } else {
6687+ // MUST send tx_abort to let the sending node know that they can forget this funding transaction.
6688+ (None, None, Some(msgs::TxAbort { channel_id: self.context.channel_id(), data: vec![] }))
6689+ }
6690+ } else {
6691+ // Counterparty set `next_funding_txid` at incorrect state.
6692+ // TODO(dual_funding): Should probably error here (or send tx_abort) but not in spec.
6693+ (None, None, None)
6694+ }
6695+ } else { (None, None, None) };
6696+
66516697 Ok(ReestablishResponses {
66526698 channel_ready, shutdown_msg, announcement_sigs,
66536699 raa: required_revoke,
6654- commitment_update: None ,
6700+ commitment_update,
66556701 order: self.context.resend_order.clone(),
6702+ tx_signatures,
6703+ tx_abort,
66566704 })
66576705 } else if msg.next_local_commitment_number == next_counterparty_commitment_number - 1 {
66586706 if required_revoke.is_some() || self.context.signer_pending_revoke_and_ack {
@@ -6667,6 +6715,8 @@ impl<SP: Deref> FundedChannel<SP> where
66676715 channel_ready, shutdown_msg, announcement_sigs,
66686716 commitment_update: None, raa: None,
66696717 order: self.context.resend_order.clone(),
6718+ tx_signatures: None,
6719+ tx_abort: None,
66706720 })
66716721 } else {
66726722 let commitment_update = if self.context.resend_order == RAACommitmentOrder::RevokeAndACKFirst
@@ -6689,6 +6739,8 @@ impl<SP: Deref> FundedChannel<SP> where
66896739 channel_ready, shutdown_msg, announcement_sigs,
66906740 raa, commitment_update,
66916741 order: self.context.resend_order.clone(),
6742+ tx_signatures: None,
6743+ tx_abort: None,
66926744 })
66936745 }
66946746 } else if msg.next_local_commitment_number < next_counterparty_commitment_number {
0 commit comments