@@ -60,8 +60,8 @@ use crate::ln::chan_utils::selected_commitment_sat_per_1000_weight;
6060use crate::ln::channel::QuiescentAction;
6161use crate::ln::channel::{
6262 self, hold_time_since, Channel, ChannelError, ChannelUpdateStatus, FundedChannel,
63- InboundV1Channel, OutboundV1Channel, PendingV2Channel, ReconnectionMsg, ShutdownResult ,
64- StfuResponse, UpdateFulfillCommitFetch, WithChannelContext,
63+ FundingTxSigned, InboundV1Channel, OutboundV1Channel, PendingV2Channel, ReconnectionMsg,
64+ ShutdownResult, StfuResponse, UpdateFulfillCommitFetch, WithChannelContext,
6565};
6666use crate::ln::channel_state::ChannelDetails;
6767use crate::ln::funding::SpliceContribution;
@@ -6298,10 +6298,26 @@ where
62986298 .filter(|witness| !witness.is_empty())
62996299 .collect();
63006300 match chan.funding_transaction_signed(txid, witnesses) {
6301- Ok((Some(tx_signatures), funding_tx_opt)) => {
6302- if let Some(funding_tx) = funding_tx_opt {
6301+ Ok(FundingTxSigned {
6302+ tx_signatures: Some(tx_signatures),
6303+ funding_tx,
6304+ splice_negotiated,
6305+ }) => {
6306+ if let Some(funding_tx) = funding_tx {
63036307 self.broadcast_interactive_funding(chan, &funding_tx);
63046308 }
6309+ if let Some(splice_negotiated) = splice_negotiated {
6310+ self.pending_events.lock().unwrap().push_back((
6311+ events::Event::SplicePending {
6312+ channel_id: *channel_id,
6313+ counterparty_node_id: *counterparty_node_id,
6314+ user_channel_id: chan.context.get_user_id(),
6315+ new_funding_txo: splice_negotiated.funding_txo,
6316+ channel_type: splice_negotiated.channel_type,
6317+ },
6318+ None,
6319+ ));
6320+ }
63056321 peer_state.pending_msg_events.push(
63066322 MessageSendEvent::SendTxSignatures {
63076323 node_id: *counterparty_node_id,
@@ -6314,7 +6330,13 @@ where
63146330 result = Err(err);
63156331 return NotifyOption::SkipPersistNoEvents;
63166332 },
6317- _ => {
6333+ Ok(FundingTxSigned {
6334+ tx_signatures: None,
6335+ funding_tx,
6336+ splice_negotiated,
6337+ }) => {
6338+ debug_assert!(funding_tx.is_none());
6339+ debug_assert!(splice_negotiated.is_none());
63186340 return NotifyOption::SkipPersistNoEvents;
63196341 },
63206342 }
@@ -9413,18 +9435,32 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
94139435 } else {
94149436 let txid = signing_session.unsigned_tx().compute_txid();
94159437 match channel.funding_transaction_signed(txid, vec![]) {
9416- Ok(( Some(tx_signatures), funding_tx_opt) ) => {
9417- if let Some(funding_tx) = funding_tx_opt {
9438+ Ok(FundingTxSigned { tx_signatures: Some(tx_signatures), funding_tx, splice_negotiated } ) => {
9439+ if let Some(funding_tx) = funding_tx {
94189440 self.broadcast_interactive_funding(channel, &funding_tx);
94199441 }
9442+
9443+ if let Some(splice_negotiated) = splice_negotiated {
9444+ self.pending_events.lock().unwrap().push_back((
9445+ events::Event::SplicePending {
9446+ channel_id: channel.context.channel_id(),
9447+ counterparty_node_id,
9448+ user_channel_id: channel.context.get_user_id(),
9449+ new_funding_txo: splice_negotiated.funding_txo,
9450+ channel_type: splice_negotiated.channel_type,
9451+ },
9452+ None,
9453+ ));
9454+ }
9455+
94209456 if channel.context.is_connected() {
94219457 pending_msg_events.push(MessageSendEvent::SendTxSignatures {
94229458 node_id: counterparty_node_id,
94239459 msg: tx_signatures,
94249460 });
94259461 }
94269462 },
9427- Ok(( None, _) ) => {
9463+ Ok(FundingTxSigned { tx_signatures: None, .. } ) => {
94289464 debug_assert!(false, "If our tx_signatures is empty, then we should send it first!");
94299465 },
94309466 Err(err) => {
@@ -10373,20 +10409,33 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1037310409 hash_map::Entry::Occupied(mut chan_entry) => {
1037410410 match chan_entry.get_mut().as_funded_mut() {
1037510411 Some(chan) => {
10376- let (tx_signatures_opt, funding_tx_opt) = try_channel_entry!(self, peer_state, chan.tx_signatures(msg), chan_entry);
10377- if let Some(tx_signatures) = tx_signatures_opt {
10412+ let FundingTxSigned { tx_signatures, funding_tx, splice_negotiated } =
10413+ try_channel_entry!(self, peer_state, chan.tx_signatures(msg), chan_entry);
10414+ if let Some(tx_signatures) = tx_signatures {
1037810415 peer_state.pending_msg_events.push(MessageSendEvent::SendTxSignatures {
1037910416 node_id: *counterparty_node_id,
1038010417 msg: tx_signatures,
1038110418 });
1038210419 }
10383- if let Some(ref funding_tx) = funding_tx_opt {
10420+ if let Some(ref funding_tx) = funding_tx {
1038410421 self.tx_broadcaster.broadcast_transactions(&[funding_tx]);
1038510422 {
1038610423 let mut pending_events = self.pending_events.lock().unwrap();
1038710424 emit_channel_pending_event!(pending_events, chan);
1038810425 }
1038910426 }
10427+ if let Some(splice_negotiated) = splice_negotiated {
10428+ self.pending_events.lock().unwrap().push_back((
10429+ events::Event::SplicePending {
10430+ channel_id: msg.channel_id,
10431+ counterparty_node_id: *counterparty_node_id,
10432+ user_channel_id: chan.context.get_user_id(),
10433+ new_funding_txo: splice_negotiated.funding_txo,
10434+ channel_type: splice_negotiated.channel_type,
10435+ },
10436+ None,
10437+ ));
10438+ }
1039010439 },
1039110440 None => {
1039210441 let msg = "Got an unexpected tx_signatures message";
@@ -11337,7 +11386,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1133711386 }
1133811387
1133911388 #[rustfmt::skip]
11340- fn internal_channel_reestablish(&self, counterparty_node_id: &PublicKey, msg: &msgs::ChannelReestablish) -> Result<NotifyOption , MsgHandleErrInternal> {
11389+ fn internal_channel_reestablish(&self, counterparty_node_id: &PublicKey, msg: &msgs::ChannelReestablish) -> Result<() , MsgHandleErrInternal> {
1134111390 let (inferred_splice_locked, need_lnd_workaround) = {
1134211391 let per_peer_state = self.per_peer_state.read().unwrap();
1134311392
@@ -11448,10 +11497,9 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1144811497
1144911498 if let Some(splice_locked) = inferred_splice_locked {
1145011499 self.internal_splice_locked(counterparty_node_id, &splice_locked)?;
11451- return Ok(NotifyOption::DoPersist);
1145211500 }
1145311501
11454- Ok(NotifyOption::SkipPersistHandleEvents )
11502+ Ok(() )
1145511503 }
1145611504
1145711505 /// Handle incoming splice request, transition channel to splice-pending (unless some check fails).
@@ -14570,16 +14618,9 @@ where
1457014618 fn handle_channel_reestablish(
1457114619 &self, counterparty_node_id: PublicKey, msg: &msgs::ChannelReestablish,
1457214620 ) {
14573- let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
14574- let res = self.internal_channel_reestablish(&counterparty_node_id, msg);
14575- let persist = match &res {
14576- Err(e) if e.closes_channel() => NotifyOption::DoPersist,
14577- Err(_) => NotifyOption::SkipPersistHandleEvents,
14578- Ok(persist) => *persist,
14579- };
14580- let _ = handle_error!(self, res, counterparty_node_id);
14581- persist
14582- });
14621+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
14622+ let res = self.internal_channel_reestablish(&counterparty_node_id, msg);
14623+ let _ = handle_error!(self, res, counterparty_node_id);
1458314624 }
1458414625
1458514626 #[rustfmt::skip]
0 commit comments