@@ -60,8 +60,8 @@ use crate::ln::chan_utils::selected_commitment_sat_per_1000_weight;
60
60
use crate::ln::channel::QuiescentAction;
61
61
use crate::ln::channel::{
62
62
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,
65
65
};
66
66
use crate::ln::channel_state::ChannelDetails;
67
67
use crate::ln::funding::SpliceContribution;
@@ -6298,10 +6298,26 @@ where
6298
6298
.filter(|witness| !witness.is_empty())
6299
6299
.collect();
6300
6300
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 {
6303
6307
self.broadcast_interactive_funding(chan, &funding_tx);
6304
6308
}
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
+ }
6305
6321
peer_state.pending_msg_events.push(
6306
6322
MessageSendEvent::SendTxSignatures {
6307
6323
node_id: *counterparty_node_id,
@@ -6314,7 +6330,13 @@ where
6314
6330
result = Err(err);
6315
6331
return NotifyOption::SkipPersistNoEvents;
6316
6332
},
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());
6318
6340
return NotifyOption::SkipPersistNoEvents;
6319
6341
},
6320
6342
}
@@ -9413,18 +9435,32 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
9413
9435
} else {
9414
9436
let txid = signing_session.unsigned_tx().compute_txid();
9415
9437
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 {
9418
9440
self.broadcast_interactive_funding(channel, &funding_tx);
9419
9441
}
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
+
9420
9456
if channel.context.is_connected() {
9421
9457
pending_msg_events.push(MessageSendEvent::SendTxSignatures {
9422
9458
node_id: counterparty_node_id,
9423
9459
msg: tx_signatures,
9424
9460
});
9425
9461
}
9426
9462
},
9427
- Ok(( None, _) ) => {
9463
+ Ok(FundingTxSigned { tx_signatures: None, .. } ) => {
9428
9464
debug_assert!(false, "If our tx_signatures is empty, then we should send it first!");
9429
9465
},
9430
9466
Err(err) => {
@@ -10373,20 +10409,33 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10373
10409
hash_map::Entry::Occupied(mut chan_entry) => {
10374
10410
match chan_entry.get_mut().as_funded_mut() {
10375
10411
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 {
10378
10415
peer_state.pending_msg_events.push(MessageSendEvent::SendTxSignatures {
10379
10416
node_id: *counterparty_node_id,
10380
10417
msg: tx_signatures,
10381
10418
});
10382
10419
}
10383
- if let Some(ref funding_tx) = funding_tx_opt {
10420
+ if let Some(ref funding_tx) = funding_tx {
10384
10421
self.tx_broadcaster.broadcast_transactions(&[funding_tx]);
10385
10422
{
10386
10423
let mut pending_events = self.pending_events.lock().unwrap();
10387
10424
emit_channel_pending_event!(pending_events, chan);
10388
10425
}
10389
10426
}
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
+ }
10390
10439
},
10391
10440
None => {
10392
10441
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/
11337
11386
}
11338
11387
11339
11388
#[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> {
11341
11390
let (inferred_splice_locked, need_lnd_workaround) = {
11342
11391
let per_peer_state = self.per_peer_state.read().unwrap();
11343
11392
@@ -11448,10 +11497,9 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
11448
11497
11449
11498
if let Some(splice_locked) = inferred_splice_locked {
11450
11499
self.internal_splice_locked(counterparty_node_id, &splice_locked)?;
11451
- return Ok(NotifyOption::DoPersist);
11452
11500
}
11453
11501
11454
- Ok(NotifyOption::SkipPersistHandleEvents )
11502
+ Ok(() )
11455
11503
}
11456
11504
11457
11505
/// Handle incoming splice request, transition channel to splice-pending (unless some check fails).
@@ -14563,16 +14611,9 @@ where
14563
14611
fn handle_channel_reestablish(
14564
14612
&self, counterparty_node_id: PublicKey, msg: &msgs::ChannelReestablish,
14565
14613
) {
14566
- let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
14567
- let res = self.internal_channel_reestablish(&counterparty_node_id, msg);
14568
- let persist = match &res {
14569
- Err(e) if e.closes_channel() => NotifyOption::DoPersist,
14570
- Err(_) => NotifyOption::SkipPersistHandleEvents,
14571
- Ok(persist) => *persist,
14572
- };
14573
- let _ = handle_error!(self, res, counterparty_node_id);
14574
- persist
14575
- });
14614
+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
14615
+ let res = self.internal_channel_reestablish(&counterparty_node_id, msg);
14616
+ let _ = handle_error!(self, res, counterparty_node_id);
14576
14617
}
14577
14618
14578
14619
#[rustfmt::skip]
0 commit comments