@@ -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.
@@ -6388,6 +6390,8 @@ impl<SP: Deref> Channel<SP> where
6388
6390
raa: None, commitment_update: None,
6389
6391
order: RAACommitmentOrder::CommitmentFirst,
6390
6392
shutdown_msg, announcement_sigs,
6393
+ tx_signatures: None,
6394
+ tx_abort: None,
6391
6395
});
6392
6396
}
6393
6397
@@ -6397,6 +6401,8 @@ impl<SP: Deref> Channel<SP> where
6397
6401
raa: None, commitment_update: None,
6398
6402
order: RAACommitmentOrder::CommitmentFirst,
6399
6403
shutdown_msg, announcement_sigs,
6404
+ tx_signatures: None,
6405
+ tx_abort: None,
6400
6406
});
6401
6407
}
6402
6408
@@ -6435,7 +6441,55 @@ impl<SP: Deref> Channel<SP> where
6435
6441
Some(self.get_channel_ready())
6436
6442
} else { None };
6437
6443
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 {
6439
6493
if required_revoke.is_some() || self.context.signer_pending_revoke_and_ack {
6440
6494
log_debug!(logger, "Reconnected channel {} with only lost outbound RAA", &self.context.channel_id());
6441
6495
} else {
@@ -6447,6 +6501,8 @@ impl<SP: Deref> Channel<SP> where
6447
6501
raa: required_revoke,
6448
6502
commitment_update: None,
6449
6503
order: self.context.resend_order.clone(),
6504
+ tx_signatures: None,
6505
+ tx_abort: None,
6450
6506
})
6451
6507
} else if msg.next_local_commitment_number == next_counterparty_commitment_number - 1 {
6452
6508
if required_revoke.is_some() || self.context.signer_pending_revoke_and_ack {
@@ -6461,6 +6517,8 @@ impl<SP: Deref> Channel<SP> where
6461
6517
channel_ready, shutdown_msg, announcement_sigs,
6462
6518
commitment_update: None, raa: None,
6463
6519
order: self.context.resend_order.clone(),
6520
+ tx_signatures: None,
6521
+ tx_abort: None,
6464
6522
})
6465
6523
} else {
6466
6524
let commitment_update = if self.context.resend_order == RAACommitmentOrder::RevokeAndACKFirst
@@ -6483,6 +6541,8 @@ impl<SP: Deref> Channel<SP> where
6483
6541
channel_ready, shutdown_msg, announcement_sigs,
6484
6542
raa, commitment_update,
6485
6543
order: self.context.resend_order.clone(),
6544
+ tx_signatures: None,
6545
+ tx_abort: None,
6486
6546
})
6487
6547
}
6488
6548
} else if msg.next_local_commitment_number < next_counterparty_commitment_number {
0 commit comments