Skip to content

Commit d44c10e

Browse files
committed
f: the trusted peers 0 reserve list now only applies to accepted channels
1 parent 663864a commit d44c10e

File tree

2 files changed

+32
-63
lines changed

2 files changed

+32
-63
lines changed

src/config.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,17 @@ pub struct Config {
156156
/// **Note**: We will only allow opening and accepting public channels if the `node_alias` and the
157157
/// `listening_addresses` are set.
158158
pub node_alias: Option<NodeAlias>,
159-
/// A list of peers that we trust. If a peer on this list opens a channel to us, we will
160-
/// forward their HTLCs before any confirmations of the funding transaction (zero-conf), and
161-
/// allow them to spend their entire balance (zero-reserve). If we open a channel to a peer
162-
/// on this list, we will allow them to spend their entire channel balance (note that for
163-
/// channels *we* open, the decision of whether to accept HTLC forwards with no
164-
/// confirmations of the funding transaction is *the peer's* decision).
165-
///
166-
/// **Note:** Allowing payments via zero-confirmation channels is potentially insecure if
167-
/// the funding transaction never gets confirmed on-chain. Zero-reserve channels
168-
/// allow the counterparty to make cheating attempts with no financial penalty.
169-
/// Zero-confirmation, and zero-reserve channels should therefore only be accepted from and
170-
/// opened to trusted peers.
159+
/// A list of peers that we trust; these are peers that you've had some interaction with
160+
/// out-of-band before clearing them to be on this list.
161+
///
162+
/// If a trusted peer opens a channel to us, we will forward their HTLCs before any
163+
/// confirmations of the funding transaction (zero-conf), and allow them to spend their
164+
/// entire balance (zero-reserve).
165+
///
166+
/// **Note:** Allowing payments via zero-confirmation channels is insecure if the funding
167+
/// transaction never gets confirmed on-chain. Zero-reserve channels allow the peer to try
168+
/// to steal your funds with no financial penalty. Zero-confirmation, and zero-reserve
169+
/// channels should therefore only be accepted from trusted peers.
171170
pub trusted_peers_0conf_0reserve: Vec<PublicKey>,
172171
/// The liquidity factor by which we filter the outgoing channels used for sending probes.
173172
///

src/lib.rs

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,57 +1196,27 @@ impl Node {
11961196
self.keys_manager.get_secure_random_bytes()[..16].try_into().unwrap(),
11971197
);
11981198

1199-
let is_trusted_peer = self.config.trusted_peers_0conf_0reserve.contains(&node_id);
1200-
if is_trusted_peer {
1201-
match self.channel_manager.create_channel_to_trusted_peer_0reserve(
1202-
peer_info.node_id,
1203-
channel_amount_sats,
1204-
push_msat,
1205-
user_channel_id,
1206-
None,
1207-
Some(user_config),
1208-
) {
1209-
Ok(_) => {
1210-
log_info!(
1211-
self.logger,
1212-
"Initiated 0reserve channel creation with peer {}. ",
1213-
peer_info.node_id
1214-
);
1215-
self.peer_store.add_peer(peer_info)?;
1216-
Ok(UserChannelId(user_channel_id))
1217-
},
1218-
Err(e) => {
1219-
log_error!(
1220-
self.logger,
1221-
"Failed to initiate 0reserve channel creation: {:?}",
1222-
e
1223-
);
1224-
Err(Error::ChannelCreationFailed)
1225-
},
1226-
}
1227-
} else {
1228-
match self.channel_manager.create_channel(
1229-
peer_info.node_id,
1230-
channel_amount_sats,
1231-
push_msat,
1232-
user_channel_id,
1233-
None,
1234-
Some(user_config),
1235-
) {
1236-
Ok(_) => {
1237-
log_info!(
1238-
self.logger,
1239-
"Initiated channel creation with peer {}. ",
1240-
peer_info.node_id
1241-
);
1242-
self.peer_store.add_peer(peer_info)?;
1243-
Ok(UserChannelId(user_channel_id))
1244-
},
1245-
Err(e) => {
1246-
log_error!(self.logger, "Failed to initiate channel creation: {:?}", e);
1247-
Err(Error::ChannelCreationFailed)
1248-
},
1249-
}
1199+
match self.channel_manager.create_channel(
1200+
peer_info.node_id,
1201+
channel_amount_sats,
1202+
push_msat,
1203+
user_channel_id,
1204+
None,
1205+
Some(user_config),
1206+
) {
1207+
Ok(_) => {
1208+
log_info!(
1209+
self.logger,
1210+
"Initiated channel creation with peer {}. ",
1211+
peer_info.node_id
1212+
);
1213+
self.peer_store.add_peer(peer_info)?;
1214+
Ok(UserChannelId(user_channel_id))
1215+
},
1216+
Err(e) => {
1217+
log_error!(self.logger, "Failed to initiate channel creation: {:?}", e);
1218+
Err(Error::ChannelCreationFailed)
1219+
},
12501220
}
12511221
}
12521222

0 commit comments

Comments
 (0)