Skip to content

Commit 6fef493

Browse files
authored
Merge pull request #242 from tnull/2024-02-expose-default-config
Introduce `default_config` top-level function
2 parents e335f0b + 99b31ae commit 6fef493

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

bindings/kotlin/ldk-node-android/lib/src/androidTest/kotlin/org/lightningdevkit/ldknode/AndroidLibTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class AndroidLibTest {
2424
val listenAddress1 = "127.0.0.1:2323"
2525
val listenAddress2 = "127.0.0.1:2324"
2626

27-
val config1 = Config()
27+
val config1 = defaultConfig()
2828
config1.storageDirPath = tmpDir1
2929
config1.listeningAddresses = listOf(listenAddress1)
3030
config1.network = Network.REGTEST
3131
config1.logLevel = LogLevel.TRACE
3232

33-
val config2 = Config()
33+
val config2 = defaultConfig()
3434
config2.storageDirPath = tmpDir2
3535
config2.listeningAddresses = listOf(listenAddress2)
3636
config2.network = Network.REGTEST

bindings/kotlin/ldk-node-jvm/lib/src/test/kotlin/org/lightningdevkit/ldknode/LibraryTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ class LibraryTest {
114114
val listenAddress1 = "127.0.0.1:2323"
115115
val listenAddress2 = "127.0.0.1:2324"
116116

117-
val config1 = Config()
117+
val config1 = defaultConfig()
118118
config1.storageDirPath = tmpDir1
119119
config1.listeningAddresses = listOf(listenAddress1)
120120
config1.network = Network.REGTEST
121121
config1.logLevel = LogLevel.TRACE
122122

123123
println("Config 1: $config1")
124124

125-
val config2 = Config()
125+
val config2 = defaultConfig()
126126
config2.storageDirPath = tmpDir2
127127
config2.listeningAddresses = listOf(listenAddress2)
128128
config2.network = Network.REGTEST

bindings/ldk_node.udl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
namespace ldk_node {
22
Mnemonic generate_entropy_mnemonic();
3+
Config default_config();
34
};
45

56
dictionary Config {
6-
string storage_dir_path = "/tmp/ldk_node/";
7-
string? log_dir_path = null;
8-
Network network = "Bitcoin";
9-
sequence<SocketAddress>? listening_addresses = null;
10-
u32 default_cltv_expiry_delta = 144;
11-
u64 onchain_wallet_sync_interval_secs = 80;
12-
u64 wallet_sync_interval_secs = 30;
13-
u64 fee_rate_cache_update_interval_secs = 600;
14-
sequence<PublicKey> trusted_peers_0conf = [];
15-
u64 probing_liquidity_limit_multiplier = 3;
16-
LogLevel log_level = "Debug";
7+
string storage_dir_path;
8+
string? log_dir_path;
9+
Network network;
10+
sequence<SocketAddress>? listening_addresses;
11+
u32 default_cltv_expiry_delta;
12+
u64 onchain_wallet_sync_interval_secs;
13+
u64 wallet_sync_interval_secs;
14+
u64 fee_rate_cache_update_interval_secs;
15+
sequence<PublicKey> trusted_peers_0conf;
16+
u64 probing_liquidity_limit_multiplier;
17+
LogLevel log_level;
1718
};
1819

1920
interface Builder {

bindings/python/src/ldk_node/test_ldk_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def send_to_address(address, amount_sats):
8181

8282

8383
def setup_node(tmp_dir, esplora_endpoint, listening_addresses):
84-
config = Config()
84+
config = default_config()
8585
builder = Builder.from_config(config)
8686
builder.set_storage_dir_path(tmp_dir)
8787
builder.set_esplora_server(esplora_endpoint)

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,16 @@ impl Default for Config {
278278
}
279279
}
280280

281+
/// Returns a [`Config`] object populated with default values.
282+
///
283+
/// See the documentation of [`Config`] for more information on the used defaults.
284+
///
285+
/// This is mostly meant for use in bindings, in Rust this is synonymous with
286+
/// [`Config::default()`].
287+
pub fn default_config() -> Config {
288+
Config::default()
289+
}
290+
281291
/// The main interface object of LDK Node, wrapping the necessary LDK and BDK functionalities.
282292
///
283293
/// Needs to be initialized and instantiated through [`Builder::build`].

0 commit comments

Comments
 (0)