Skip to content

Commit 9125870

Browse files
committed
Add Node::{open_0reserve_channel, open_0reserve_channel_with_all}
1 parent e0146c3 commit 9125870

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

src/lib.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,82 @@ impl Node {
14231423
)
14241424
}
14251425

1426+
/// Connect to a node and open a new unannounced, zero-reserve channel.
1427+
///
1428+
/// Zero-reserve channels allow the channel counterparty to try to steal your funds with
1429+
/// no financial penalty, so zero-reserve channels should only be opened to parties you
1430+
/// trust.
1431+
///
1432+
/// Note that this only allows *the counterparty* to spend *their* entire balance in the
1433+
/// the channel; whether *you* are allowed to spend your own full balance is the
1434+
/// counterparty's decision. See [`Config::trusted_peers_0conf_0reserve`] if the
1435+
/// counterparty would like to set zero-reserve on your own balance as well.
1436+
///
1437+
/// Disconnects and reconnects are handled automatically.
1438+
///
1439+
/// If `push_to_counterparty_msat` is set, the given value will be pushed (read: sent) to the
1440+
/// channel counterparty on channel open. This can be useful to start out with the balance not
1441+
/// entirely shifted to one side, therefore allowing to receive payments from the getgo.
1442+
///
1443+
/// If Anchor channels are enabled, this will ensure the configured
1444+
/// [`AnchorChannelsConfig::per_channel_reserve_sats`] is available and will be retained before
1445+
/// opening the channel.
1446+
///
1447+
/// Returns a [`UserChannelId`] allowing to locally keep track of the channel.
1448+
///
1449+
/// [`Config::trusted_peers_0conf_0reserve`]: crate::config::Config::trusted_peers_0conf_0reserve
1450+
/// [`AnchorChannelsConfig::per_channel_reserve_sats`]: crate::config::AnchorChannelsConfig::per_channel_reserve_sats
1451+
pub fn open_0reserve_channel(
1452+
&self, node_id: PublicKey, address: SocketAddress, channel_amount_sats: u64,
1453+
push_to_counterparty_msat: Option<u64>, channel_config: Option<ChannelConfig>,
1454+
) -> Result<UserChannelId, Error> {
1455+
self.open_channel_inner(
1456+
node_id,
1457+
address,
1458+
FundingAmount::Exact { amount_sats: channel_amount_sats },
1459+
push_to_counterparty_msat,
1460+
channel_config,
1461+
false,
1462+
true,
1463+
)
1464+
}
1465+
1466+
/// Connect to a node and open a new unannounced, zero-reserve channel, using all available
1467+
/// on-chain funds minus fees and anchor reserves.
1468+
///
1469+
/// Zero-reserve channels allow the channel counterparty to try to steal your funds with
1470+
/// no financial penalty, so zero-reserve channels should only be opened to parties you
1471+
/// trust.
1472+
///
1473+
/// Note that this only allows *the counterparty* to spend *their* entire balance in the
1474+
/// the channel; whether *you* are allowed to spend your own full balance is the
1475+
/// counterparty's decision. See [`Config::trusted_peers_0conf_0reserve`] if the
1476+
/// counterparty would like to set zero-reserve on your own balance as well.
1477+
///
1478+
/// Disconnects and reconnects are handled automatically.
1479+
///
1480+
/// If `push_to_counterparty_msat` is set, the given value will be pushed (read: sent) to the
1481+
/// channel counterparty on channel open. This can be useful to start out with the balance not
1482+
/// entirely shifted to one side, therefore allowing to receive payments from the getgo.
1483+
///
1484+
/// Returns a [`UserChannelId`] allowing to locally keep track of the channel.
1485+
///
1486+
/// [`Config::trusted_peers_0conf_0reserve`]: crate::config::Config::trusted_peers_0conf_0reserve
1487+
pub fn open_0reserve_channel_with_all(
1488+
&self, node_id: PublicKey, address: SocketAddress, push_to_counterparty_msat: Option<u64>,
1489+
channel_config: Option<ChannelConfig>,
1490+
) -> Result<UserChannelId, Error> {
1491+
self.open_channel_inner(
1492+
node_id,
1493+
address,
1494+
FundingAmount::Max,
1495+
push_to_counterparty_msat,
1496+
channel_config,
1497+
false,
1498+
true,
1499+
)
1500+
}
1501+
14261502
fn splice_in_inner(
14271503
&self, user_channel_id: &UserChannelId, counterparty_node_id: PublicKey,
14281504
splice_amount_sats: FundingAmount,

0 commit comments

Comments
 (0)