@@ -925,6 +925,8 @@ pub(super) struct ReestablishResponses {
925
925
pub order: RAACommitmentOrder,
926
926
pub announcement_sigs: Option<msgs::AnnouncementSignatures>,
927
927
pub shutdown_msg: Option<msgs::Shutdown>,
928
+ pub tx_signatures: Option<msgs::TxSignatures>,
929
+ pub tx_abort: Option<msgs::TxAbort>,
928
930
}
929
931
930
932
/// The result of a shutdown that should be handled.
@@ -6391,6 +6393,8 @@ impl<SP: Deref> Channel<SP> where
6391
6393
raa: None, commitment_update: None,
6392
6394
order: RAACommitmentOrder::CommitmentFirst,
6393
6395
shutdown_msg, announcement_sigs,
6396
+ tx_signatures: None,
6397
+ tx_abort: None,
6394
6398
});
6395
6399
}
6396
6400
@@ -6400,6 +6404,8 @@ impl<SP: Deref> Channel<SP> where
6400
6404
raa: None, commitment_update: None,
6401
6405
order: RAACommitmentOrder::CommitmentFirst,
6402
6406
shutdown_msg, announcement_sigs,
6407
+ tx_signatures: None,
6408
+ tx_abort: None,
6403
6409
});
6404
6410
}
6405
6411
@@ -6445,11 +6451,53 @@ impl<SP: Deref> Channel<SP> where
6445
6451
log_debug!(logger, "Reconnected channel {} with no loss", &self.context.channel_id());
6446
6452
}
6447
6453
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
+
6448
6494
Ok(ReestablishResponses {
6449
6495
channel_ready, shutdown_msg, announcement_sigs,
6450
6496
raa: required_revoke,
6451
- commitment_update: None ,
6497
+ commitment_update,
6452
6498
order: self.context.resend_order.clone(),
6499
+ tx_signatures,
6500
+ tx_abort,
6453
6501
})
6454
6502
} else if msg.next_local_commitment_number == next_counterparty_commitment_number - 1 {
6455
6503
if required_revoke.is_some() || self.context.signer_pending_revoke_and_ack {
@@ -6464,6 +6512,8 @@ impl<SP: Deref> Channel<SP> where
6464
6512
channel_ready, shutdown_msg, announcement_sigs,
6465
6513
commitment_update: None, raa: None,
6466
6514
order: self.context.resend_order.clone(),
6515
+ tx_signatures: None,
6516
+ tx_abort: None,
6467
6517
})
6468
6518
} else {
6469
6519
let commitment_update = if self.context.resend_order == RAACommitmentOrder::RevokeAndACKFirst
@@ -6486,6 +6536,8 @@ impl<SP: Deref> Channel<SP> where
6486
6536
channel_ready, shutdown_msg, announcement_sigs,
6487
6537
raa, commitment_update,
6488
6538
order: self.context.resend_order.clone(),
6539
+ tx_signatures: None,
6540
+ tx_abort: None,
6489
6541
})
6490
6542
}
6491
6543
} else if msg.next_local_commitment_number < next_counterparty_commitment_number {
0 commit comments