@@ -70,7 +70,6 @@ pub fn cert_path_for_storage_dir(storage_dir: &str) -> PathBuf {
7070
7171/// Top-level structure of the `ldk-server` configuration TOML file.
7272#[ derive( Debug , Deserialize ) ]
73- #[ serde( deny_unknown_fields) ]
7473pub struct Config {
7574 /// Node-level configuration.
7675 pub node : NodeConfig ,
@@ -82,15 +81,13 @@ pub struct Config {
8281
8382/// `[tls]` section of the configuration file.
8483#[ derive( Debug , Deserialize , Serialize ) ]
85- #[ serde( deny_unknown_fields) ]
8684pub struct TlsConfig {
8785 /// Path to the server's TLS certificate in PEM format.
8886 pub cert_path : Option < String > ,
8987}
9088
9189/// `[node]` section of the configuration file.
9290#[ derive( Debug , Deserialize ) ]
93- #[ serde( deny_unknown_fields) ]
9491pub struct NodeConfig {
9592 /// Address of the `ldk-server` gRPC service.
9693 #[ serde( default = "default_grpc_service_address" ) ]
@@ -100,15 +97,13 @@ pub struct NodeConfig {
10097
10198/// `[storage]` section of the configuration file.
10299#[ derive( Debug , Deserialize ) ]
103- #[ serde( deny_unknown_fields) ]
104100pub struct StorageConfig {
105101 /// On-disk storage configuration.
106102 pub disk : Option < DiskConfig > ,
107103}
108104
109105/// `[storage.disk]` section of the configuration file.
110106#[ derive( Debug , Deserialize ) ]
111- #[ serde( deny_unknown_fields) ]
112107pub struct DiskConfig {
113108 /// Directory used by the server to store its persistent data.
114109 pub dir_path : Option < String > ,
@@ -208,28 +203,62 @@ mod tests {
208203 }
209204
210205 #[ test]
211- fn config_rejects_unknown_fields ( ) {
212- let top_level_err = toml:: from_str :: < Config > (
206+ fn config_allows_server_config_fields ( ) {
207+ let config = toml:: from_str :: < Config > (
213208 r#"
214209 [node]
215210 network = "regtest"
216-
217- [unknown]
218- option = true
211+ listening_addresses = ["localhost:3001"]
212+ announcement_addresses = ["54.3.7.81:3001"]
213+ grpc_service_address = "127.0.0.1:3002"
214+ alias = "LDK Server"
215+ rgs_server_url = "https://rapidsync.lightningdevkit.org/snapshot/v2/"
216+ async_payments_role = "client"
217+
218+ [tls]
219+ cert_path = "/path/to/tls.crt"
220+ key_path = "/path/to/tls.key"
221+ hosts = ["example.com", "ldk-server.local"]
222+
223+ [storage.disk]
224+ dir_path = "/tmp"
225+
226+ [log]
227+ level = "Trace"
228+ file = "/var/log/ldk-server.log"
229+
230+ [bitcoind]
231+ rpc_address = "127.0.0.1:8332"
232+ rpc_user = "bitcoind-testuser"
233+ rpc_password = "bitcoind-testpassword"
234+
235+ [liquidity.lsps2_client]
236+ node_pubkey = "0217890e3aad8d35bc054f43acc00084b25229ecff0ab68debd82883ad65ee8266"
237+ address = "127.0.0.1:39735"
238+ token = "lsps2-token"
239+
240+ [liquidity.lsps2_service]
241+ advertise_service = false
242+ channel_opening_fee_ppm = 1000
243+ channel_over_provisioning_ppm = 500000
244+ min_channel_opening_fee_msat = 10000000
245+ min_channel_lifetime = 4320
246+ max_client_to_self_delay = 1440
247+ min_payment_size_msat = 10000000
248+ max_payment_size_msat = 25000000000
249+ client_trusts_lsp = true
250+ disable_client_reserve = false
251+
252+ [tor]
253+ proxy_address = "127.0.0.1:9050"
219254 "# ,
220255 )
221- . unwrap_err ( ) ;
222- assert ! ( top_level_err. to_string( ) . contains( "unknown field `unknown`" ) ) ;
256+ . unwrap ( ) ;
223257
224- let node_err = toml:: from_str :: < Config > (
225- r#"
226- [node]
227- network = "regtest"
228- unknown = true
229- "# ,
230- )
231- . unwrap_err ( ) ;
232- assert ! ( node_err. to_string( ) . contains( "unknown field `unknown`" ) ) ;
258+ assert_eq ! ( config. network( ) . unwrap( ) , "regtest" ) ;
259+ assert_eq ! ( config. node. grpc_service_address, "127.0.0.1:3002" ) ;
260+ assert_eq ! ( config. tls. unwrap( ) . cert_path. unwrap( ) , "/path/to/tls.crt" ) ;
261+ assert_eq ! ( config. storage. unwrap( ) . disk. unwrap( ) . dir_path. unwrap( ) , "/tmp" ) ;
233262 }
234263
235264 #[ test]
0 commit comments