-
Notifications
You must be signed in to change notification settings - Fork 130
Enable 0conf and 0reserve on channels with trusted peers #853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
663864a
d44c10e
2502910
27bc80c
e0146c3
9125870
aa005f4
c1e1b51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,7 +123,7 @@ pub(crate) const LNURL_AUTH_TIMEOUT_SECS: u64 = 15; | |
| /// | `listening_addresses` | None | | ||
| /// | `announcement_addresses` | None | | ||
| /// | `node_alias` | None | | ||
| /// | `trusted_peers_0conf` | [] | | ||
| /// | `trusted_peers_0conf_0reserve` | [] | | ||
| /// | `probing_liquidity_limit_multiplier` | 3 | | ||
| /// | `anchor_channels_config` | Some(..) | | ||
| /// | `route_parameters` | None | | ||
|
|
@@ -156,12 +156,19 @@ pub struct Config { | |
| /// **Note**: We will only allow opening and accepting public channels if the `node_alias` and the | ||
| /// `listening_addresses` are set. | ||
| pub node_alias: Option<NodeAlias>, | ||
| /// A list of peers that we allow to establish zero confirmation channels to us. | ||
| /// | ||
| /// **Note:** Allowing payments via zero-confirmation channels is potentially insecure if the | ||
| /// funding transaction ends up never being confirmed on-chain. Zero-confirmation channels | ||
| /// should therefore only be accepted from trusted peers. | ||
| pub trusted_peers_0conf: Vec<PublicKey>, | ||
| /// A list of peers that we trust. If a peer on this list opens a channel to us, we will | ||
tnull marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// forward their HTLCs before any confirmations of the funding transaction (zero-conf), and | ||
| /// allow them to spend their entire balance (zero-reserve). If we open a channel to a peer | ||
| /// on this list, we will allow them to spend their entire channel balance (note that for | ||
| /// channels *we* open, the decision of whether to accept HTLC forwards with no | ||
| /// confirmations of the funding transaction is *the peer's* decision). | ||
|
||
| /// | ||
| /// **Note:** Allowing payments via zero-confirmation channels is potentially insecure if | ||
| /// the funding transaction never gets confirmed on-chain. Zero-reserve channels | ||
| /// allow the counterparty to make cheating attempts with no financial penalty. | ||
tnull marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// Zero-confirmation, and zero-reserve channels should therefore only be accepted from and | ||
| /// opened to trusted peers. | ||
| pub trusted_peers_0conf_0reserve: Vec<PublicKey>, | ||
|
||
| /// The liquidity factor by which we filter the outgoing channels used for sending probes. | ||
| /// | ||
| /// Channels with available liquidity less than the required amount times this value won't be | ||
|
|
@@ -208,7 +215,7 @@ impl Default for Config { | |
| network: DEFAULT_NETWORK, | ||
| listening_addresses: None, | ||
| announcement_addresses: None, | ||
| trusted_peers_0conf: Vec::new(), | ||
| trusted_peers_0conf_0reserve: Vec::new(), | ||
| probing_liquidity_limit_multiplier: DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER, | ||
| anchor_channels_config: Some(AnchorChannelsConfig::default()), | ||
| tor_config: None, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1196,27 +1196,57 @@ impl Node { | |
| self.keys_manager.get_secure_random_bytes()[..16].try_into().unwrap(), | ||
| ); | ||
|
|
||
| match self.channel_manager.create_channel( | ||
| peer_info.node_id, | ||
| channel_amount_sats, | ||
| push_msat, | ||
| user_channel_id, | ||
| None, | ||
| Some(user_config), | ||
| ) { | ||
| Ok(_) => { | ||
| log_info!( | ||
| self.logger, | ||
| "Initiated channel creation with peer {}. ", | ||
| peer_info.node_id | ||
| ); | ||
| self.peer_store.add_peer(peer_info)?; | ||
| Ok(UserChannelId(user_channel_id)) | ||
| }, | ||
| Err(e) => { | ||
| log_error!(self.logger, "Failed to initiate channel creation: {:?}", e); | ||
| Err(Error::ChannelCreationFailed) | ||
| }, | ||
| let is_trusted_peer = self.config.trusted_peers_0conf_0reserve.contains(&node_id); | ||
| if is_trusted_peer { | ||
| match self.channel_manager.create_channel_to_trusted_peer_0reserve( | ||
|
||
| peer_info.node_id, | ||
| channel_amount_sats, | ||
| push_msat, | ||
| user_channel_id, | ||
| None, | ||
| Some(user_config), | ||
| ) { | ||
| Ok(_) => { | ||
| log_info!( | ||
| self.logger, | ||
| "Initiated 0reserve channel creation with peer {}. ", | ||
| peer_info.node_id | ||
| ); | ||
| self.peer_store.add_peer(peer_info)?; | ||
| Ok(UserChannelId(user_channel_id)) | ||
| }, | ||
| Err(e) => { | ||
| log_error!( | ||
| self.logger, | ||
| "Failed to initiate 0reserve channel creation: {:?}", | ||
| e | ||
| ); | ||
| Err(Error::ChannelCreationFailed) | ||
| }, | ||
| } | ||
| } else { | ||
| match self.channel_manager.create_channel( | ||
| peer_info.node_id, | ||
| channel_amount_sats, | ||
| push_msat, | ||
| user_channel_id, | ||
| None, | ||
| Some(user_config), | ||
| ) { | ||
| Ok(_) => { | ||
| log_info!( | ||
| self.logger, | ||
| "Initiated channel creation with peer {}. ", | ||
| peer_info.node_id | ||
| ); | ||
| self.peer_store.add_peer(peer_info)?; | ||
| Ok(UserChannelId(user_channel_id)) | ||
| }, | ||
| Err(e) => { | ||
| log_error!(self.logger, "Failed to initiate channel creation: {:?}", e); | ||
| Err(Error::ChannelCreationFailed) | ||
| }, | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use
revhere? Seems otherwise the revision could move if the branch is updated.