@@ -8636,16 +8636,38 @@ where
8636
8636
}
8637
8637
}
8638
8638
8639
- fn on_tx_signatures_exchange(&mut self, funding_tx: Transaction) {
8639
+ fn on_tx_signatures_exchange<'a, L: Deref>(
8640
+ &mut self, funding_tx: Transaction, best_block_height: u32,
8641
+ logger: &WithChannelContext<'a, L>,
8642
+ ) -> Option<msgs::SpliceLocked>
8643
+ where
8644
+ L::Target: Logger,
8645
+ {
8640
8646
debug_assert!(!self.context.channel_state.is_monitor_update_in_progress());
8641
8647
debug_assert!(!self.context.channel_state.is_awaiting_remote_revoke());
8642
8648
8649
+ let mut splice_locked = None;
8643
8650
if let Some(pending_splice) = self.pending_splice.as_mut() {
8644
8651
if let Some(FundingNegotiation::AwaitingSignatures { mut funding }) =
8645
8652
pending_splice.funding_negotiation.take()
8646
8653
{
8647
8654
funding.funding_transaction = Some(funding_tx);
8648
8655
pending_splice.negotiated_candidates.push(funding);
8656
+ splice_locked = pending_splice.check_get_splice_locked(
8657
+ &self.context,
8658
+ pending_splice.negotiated_candidates.len() - 1,
8659
+ best_block_height,
8660
+ );
8661
+ if let Some(splice_txid) =
8662
+ splice_locked.as_ref().map(|splice_locked| splice_locked.splice_txid)
8663
+ {
8664
+ log_info!(
8665
+ logger,
8666
+ "Sending 0conf splice_locked txid {} to our peer for channel {}",
8667
+ splice_txid,
8668
+ &self.context.channel_id
8669
+ );
8670
+ }
8649
8671
} else {
8650
8672
debug_assert!(false);
8651
8673
}
@@ -8655,11 +8677,20 @@ where
8655
8677
self.context.channel_state =
8656
8678
ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
8657
8679
}
8680
+
8681
+ splice_locked
8658
8682
}
8659
8683
8660
- pub fn funding_transaction_signed(
8661
- &mut self, funding_txid_signed: Txid, witnesses: Vec<Witness>,
8662
- ) -> Result<(Option<msgs::TxSignatures>, Option<Transaction>), APIError> {
8684
+ pub fn funding_transaction_signed<L: Deref>(
8685
+ &mut self, funding_txid_signed: Txid, witnesses: Vec<Witness>, best_block_height: u32,
8686
+ logger: &L,
8687
+ ) -> Result<
8688
+ (Option<msgs::TxSignatures>, Option<msgs::SpliceLocked>, Option<Transaction>),
8689
+ APIError,
8690
+ >
8691
+ where
8692
+ L::Target: Logger,
8693
+ {
8663
8694
let signing_session =
8664
8695
if let Some(signing_session) = self.context.interactive_tx_signing_session.as_mut() {
8665
8696
if let Some(pending_splice) = self.pending_splice.as_ref() {
@@ -8674,17 +8705,17 @@ where
8674
8705
}
8675
8706
8676
8707
if signing_session.holder_tx_signatures().is_some() {
8677
- // Our `tx_signatures` either should've been the first time we processed them,
8678
- // or we're waiting for our counterparty to send theirs first.
8679
- return Ok((None, None));
8708
+ // Our `tx_signatures` either should've been sent the first time we processed
8709
+ // them, or we're waiting for our counterparty to send theirs first.
8710
+ return Ok((None, None, None ));
8680
8711
}
8681
8712
8682
8713
signing_session
8683
8714
} else {
8684
8715
if Some(funding_txid_signed) == self.funding.get_funding_txid() {
8685
8716
// We may be handling a duplicate call and the funding was already locked so we
8686
8717
// no longer have the signing session present.
8687
- return Ok((None, None));
8718
+ return Ok((None, None, None ));
8688
8719
}
8689
8720
let err =
8690
8721
format!("Channel {} not expecting funding signatures", self.context.channel_id);
@@ -8726,17 +8757,31 @@ where
8726
8757
.provide_holder_witnesses(tx_signatures, &self.context.secp_ctx)
8727
8758
.map_err(|err| APIError::APIMisuseError { err })?;
8728
8759
8729
- if let Some(funding_tx) = funding_tx_opt.clone() {
8730
- debug_assert!(tx_signatures_opt.is_some());
8731
- self.on_tx_signatures_exchange(funding_tx);
8760
+ let logger = WithChannelContext::from(logger, &self.context, None);
8761
+ if tx_signatures_opt.is_some() {
8762
+ log_info!(
8763
+ logger,
8764
+ "Sending tx_signatures for interactive funding transaction {funding_txid_signed}"
8765
+ );
8732
8766
}
8733
8767
8734
- Ok((tx_signatures_opt, funding_tx_opt))
8768
+ let splice_locked_opt = funding_tx_opt.clone().and_then(|funding_tx| {
8769
+ debug_assert!(tx_signatures_opt.is_some());
8770
+ self.on_tx_signatures_exchange(funding_tx, best_block_height, &logger)
8771
+ });
8772
+
8773
+ Ok((tx_signatures_opt, splice_locked_opt, funding_tx_opt))
8735
8774
}
8736
8775
8737
- pub fn tx_signatures(
8738
- &mut self, msg: &msgs::TxSignatures,
8739
- ) -> Result<(Option<msgs::TxSignatures>, Option<Transaction>), ChannelError> {
8776
+ pub fn tx_signatures<L: Deref>(
8777
+ &mut self, msg: &msgs::TxSignatures, best_block_height: u32, logger: &L,
8778
+ ) -> Result<
8779
+ (Option<msgs::TxSignatures>, Option<msgs::SpliceLocked>, Option<Transaction>),
8780
+ ChannelError,
8781
+ >
8782
+ where
8783
+ L::Target: Logger,
8784
+ {
8740
8785
let signing_session = if let Some(signing_session) =
8741
8786
self.context.interactive_tx_signing_session.as_mut()
8742
8787
{
@@ -8782,11 +8827,18 @@ where
8782
8827
let (holder_tx_signatures_opt, funding_tx_opt) =
8783
8828
signing_session.received_tx_signatures(msg).map_err(|msg| ChannelError::Warn(msg))?;
8784
8829
8785
- if let Some(funding_tx) = funding_tx_opt.clone() {
8786
- self.on_tx_signatures_exchange(funding_tx);
8787
- }
8830
+ let logger = WithChannelContext::from(logger, &self.context, None);
8831
+ log_info!(
8832
+ logger,
8833
+ "Received tx_signatures for interactive funding transaction {}",
8834
+ msg.tx_hash
8835
+ );
8836
+
8837
+ let splice_locked_opt = funding_tx_opt.clone().and_then(|funding_tx| {
8838
+ self.on_tx_signatures_exchange(funding_tx, best_block_height, &logger)
8839
+ });
8788
8840
8789
- Ok((holder_tx_signatures_opt, funding_tx_opt))
8841
+ Ok((holder_tx_signatures_opt, splice_locked_opt, funding_tx_opt))
8790
8842
}
8791
8843
8792
8844
/// Queues up an outbound update fee by placing it in the holding cell. You should call
@@ -11113,7 +11165,11 @@ where
11113
11165
confirmed_funding_index,
11114
11166
height,
11115
11167
) {
11116
- log_info!(logger, "Sending a splice_locked to our peer for channel {}", &self.context.channel_id);
11168
+ log_info!(
11169
+ logger, "Sending splice_locked txid {} to our peer for channel {}",
11170
+ splice_locked.splice_txid,
11171
+ &self.context.channel_id
11172
+ );
11117
11173
11118
11174
let (funding_txo, monitor_update, announcement_sigs, discarded_funding) = chain_node_signer
11119
11175
.and_then(|(chain_hash, node_signer, user_config)| {
0 commit comments