Skip to content

Commit 8e62b20

Browse files
committed
Add SplicePending event
Once a splice has been negotiated and its funding transaction has been broadcast, it is considered pending until both parties have seen enough confirmations to consider the funding locked. Add an event used to indicate this.
1 parent 3ce8204 commit 8e62b20

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

lightning/src/events/mod.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,37 @@ pub enum Event {
15021502
/// [`ChainMonitor::get_claimable_balances`]: crate::chain::chainmonitor::ChainMonitor::get_claimable_balances
15031503
last_local_balance_msat: Option<u64>,
15041504
},
1505+
/// Used to indicate that a splice for the given `channel_id` has been negotiated and its
1506+
/// funding transaction has been broadcast.
1507+
///
1508+
/// The splice is then considered pending until both parties have seen enough confirmations to
1509+
/// consider the funding locked. Once this occurs, an [`Event::ChannelReady`] will be emitted.
1510+
///
1511+
/// Any UTXOs spent by the splice cannot be reused except by an RBF attempt for the same channel.
1512+
///
1513+
/// # Failure Behavior and Persistence
1514+
/// This event will eventually be replayed after failures-to-handle (i.e., the event handler
1515+
/// returning `Err(ReplayEvent ())`) and will be persisted across restarts.
1516+
SplicePending {
1517+
/// The `channel_id` of the channel that has a pending splice funding transaction.
1518+
channel_id: ChannelId,
1519+
/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1520+
/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1521+
/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1522+
/// `user_channel_id` will be randomized for an inbound channel.
1523+
///
1524+
/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1525+
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1526+
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1527+
user_channel_id: u128,
1528+
/// The `node_id` of the channel counterparty.
1529+
counterparty_node_id: PublicKey,
1530+
/// The outpoint of the channel's splice funding transaction.
1531+
new_funding_txo: OutPoint,
1532+
/// The features that this channel will operate with. Currently, these will be the same
1533+
/// features that the channel was opened with, but in the future splices may change them.
1534+
channel_type: ChannelTypeFeatures,
1535+
},
15051536
/// Used to indicate to the user that they can abandon the funding transaction and recycle the
15061537
/// inputs for another purpose.
15071538
///
@@ -2228,6 +2259,22 @@ impl Writeable for Event {
22282259
// We never write out FundingTransactionReadyForSigning events as they will be regenerated when
22292260
// necessary.
22302261
},
2262+
&Event::SplicePending {
2263+
ref channel_id,
2264+
ref user_channel_id,
2265+
ref counterparty_node_id,
2266+
ref new_funding_txo,
2267+
ref channel_type,
2268+
} => {
2269+
50u8.write(writer)?;
2270+
write_tlv_fields!(writer, {
2271+
(1, channel_id, required),
2272+
(3, channel_type, required),
2273+
(5, user_channel_id, required),
2274+
(7, counterparty_node_id, required),
2275+
(9, new_funding_txo, required),
2276+
});
2277+
},
22312278
// Note that, going forward, all new events must only write data inside of
22322279
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
22332280
// data via `write_tlv_fields`.
@@ -2810,6 +2857,26 @@ impl MaybeReadable for Event {
28102857
47u8 => Ok(None),
28112858
// Note that we do not write a length-prefixed TLV for FundingTransactionReadyForSigning events.
28122859
49u8 => Ok(None),
2860+
50u8 => {
2861+
let mut f = || {
2862+
_init_and_read_len_prefixed_tlv_fields!(reader, {
2863+
(1, channel_id, required),
2864+
(3, channel_type, required),
2865+
(5, user_channel_id, required),
2866+
(7, counterparty_node_id, required),
2867+
(9, new_funding_txo, required),
2868+
});
2869+
2870+
Ok(Some(Event::SplicePending {
2871+
channel_id: channel_id.0.unwrap(),
2872+
user_channel_id: user_channel_id.0.unwrap(),
2873+
counterparty_node_id: counterparty_node_id.0.unwrap(),
2874+
new_funding_txo: new_funding_txo.0.unwrap(),
2875+
channel_type: channel_type.0.unwrap(),
2876+
}))
2877+
};
2878+
f()
2879+
},
28132880
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
28142881
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
28152882
// reads.

0 commit comments

Comments
 (0)