Skip to content

Commit dcc712a

Browse files
committed
Implement ZeroConf channel type.
1 parent ce7b0b4 commit dcc712a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lightning/src/ln/channelmanager.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -4200,7 +4200,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
42004200
if *counterparty_node_id != channel.get().get_counterparty_node_id() {
42014201
return Err(APIError::APIMisuseError { err: "The passed counterparty_node_id doesn't match the channel's counterparty node_id".to_owned() });
42024202
}
4203-
if accept_0conf { channel.get_mut().set_0conf(); }
4203+
if accept_0conf {
4204+
channel.get_mut().set_0conf();
4205+
} else if channel.get().get_channel_type().requires_zero_conf() {
4206+
return Err(APIError::APIMisuseError { err: "This channel requires 0conf. Please use accept_inbound_channel_from_trusted_peer_0conf to accept.".to_owned() });
4207+
}
42044208
channel_state.pending_msg_events.push(events::MessageSendEvent::SendAcceptChannel {
42054209
node_id: channel.get().get_counterparty_node_id(),
42064210
msg: channel.get_mut().accept_inbound_channel(user_channel_id),
@@ -4242,6 +4246,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
42424246
},
42434247
hash_map::Entry::Vacant(entry) => {
42444248
if !self.default_configuration.manually_accept_inbound_channels {
4249+
if channel.get_channel_type().requires_zero_conf() {
4250+
return Err(MsgHandleErrInternal::send_err_msg_no_close("No zero confirmation channels accepted".to_owned(), msg.temporary_channel_id.clone()));
4251+
}
42454252
channel_state.pending_msg_events.push(events::MessageSendEvent::SendAcceptChannel {
42464253
node_id: counterparty_node_id.clone(),
42474254
msg: channel.accept_inbound_channel(0),

lightning/src/ln/features.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ mod sealed {
217217
// Byte 4
218218
,
219219
// Byte 5
220-
SCIDPrivacy,
220+
SCIDPrivacy | ZeroConf,
221221
],
222222
optional_features: [
223223
// Byte 0
@@ -402,7 +402,9 @@ mod sealed {
402402
define_feature!(47, SCIDPrivacy, [InitContext, NodeContext, ChannelTypeContext],
403403
"Feature flags for only forwarding with SCID aliasing. Called `option_scid_alias` in the BOLTs",
404404
set_scid_privacy_optional, set_scid_privacy_required, supports_scid_privacy, requires_scid_privacy);
405-
405+
define_feature!(51, ZeroConf, [ChannelTypeContext],
406+
"Feature flags for accepting channels with zero confirmations. Called `option_zeroconf` in the BOLTs",
407+
set_zero_conf_optional, set_zero_conf_required, supports_zero_conf, requires_zero_conf);
406408
define_feature!(55, Keysend, [NodeContext],
407409
"Feature flags for keysend payments.", set_keysend_optional, set_keysend_required,
408410
supports_keysend, requires_keysend);

0 commit comments

Comments
 (0)