Skip to content

Commit

Permalink
Allow to specify a ChannelConfig upon opening
Browse files Browse the repository at this point in the history
This is useful/necessary to set forwarding fee rates, as well as
allowing for overriding the dust HTLC exposure limit.
  • Loading branch information
tnull committed Jun 15, 2023
1 parent dd4eea9 commit 831a330
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class LibraryTest {
assertEquals(100000u, totalBalance1)
assertEquals(100000u, totalBalance2)

node1.connectOpenChannel(nodeId2, listenAddress2, 50000u, null, true)
node1.connectOpenChannel(nodeId2, listenAddress2, 50000u, null, null, true)

val channelPendingEvent1 = node1.waitNextEvent()
println("Got event: $channelPendingEvent1")
Expand Down
2 changes: 1 addition & 1 deletion bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface LDKNode {
[Throws=NodeError]
void disconnect(PublicKey node_id);
[Throws=NodeError]
void connect_open_channel(PublicKey node_id, NetAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, boolean announce_channel);
void connect_open_channel(PublicKey node_id, NetAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, ChannelConfig? channel_config, boolean announce_channel);
[Throws=NodeError]
void close_channel([ByRef]ChannelId channel_id, PublicKey counterparty_node_id);
[Throws=NodeError]
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
//!
//! let node_id = PublicKey::from_str("NODE_ID").unwrap();
//! let node_addr = NetAddress::from_str("IP_ADDR:PORT").unwrap();
//! node.connect_open_channel(node_id, node_addr, 10000, None, false).unwrap();
//! node.connect_open_channel(node_id, node_addr, 10000, None, None, false).unwrap();
//!
//! let event = node.wait_next_event();
//! println!("EVENT: {:?}", event);
Expand Down Expand Up @@ -1369,7 +1369,8 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
/// Returns a temporary channel id.
pub fn connect_open_channel(
&self, node_id: PublicKey, address: NetAddress, channel_amount_sats: u64,
push_to_counterparty_msat: Option<u64>, announce_channel: bool,
push_to_counterparty_msat: Option<u64>, channel_config: Option<ChannelConfig>,
announce_channel: bool,
) -> Result<(), Error> {
let rt_lock = self.runtime.read().unwrap();
if rt_lock.is_none() {
Expand Down Expand Up @@ -1404,6 +1405,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
announced_channel: announce_channel,
..Default::default()
},
channel_config: channel_config.unwrap_or_default(),
..Default::default()
};

Expand Down
4 changes: 3 additions & 1 deletion src/test/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fn do_channel_full_cycle<K: KVStore + Sync + Send>(
node_b.listening_address().unwrap().into(),
funding_amount_sat,
Some(push_msat),
None,
true,
)
.unwrap();
Expand Down Expand Up @@ -311,7 +312,8 @@ fn channel_open_fails_when_funds_insufficient() {
node_b.listening_address().unwrap().into(),
120000,
None,
true,
None,
true
)
);
}
Expand Down

0 comments on commit 831a330

Please sign in to comment.