@@ -265,6 +265,33 @@ def parse_command_line_arguments(self):
265
265
action = "store_true" ,
266
266
help = "Preserve lndbtc lnd.conf file during updates"
267
267
)
268
+ group .add_argument (
269
+ "--lndbtc.mode" ,
270
+ metavar = "<mode>" ,
271
+ choices = ["native" , "external" ],
272
+ help = "Lndbtc service mode"
273
+ )
274
+ group .add_argument (
275
+ "--lndbtc.rpc-host" ,
276
+ metavar = "<hostname>" ,
277
+ help = "External lndbtc RPC hostname"
278
+ )
279
+ group .add_argument (
280
+ "--lndbtc.rpc-port" ,
281
+ type = int ,
282
+ metavar = "<port>" ,
283
+ help = "External lndbtc RPC port"
284
+ )
285
+ group .add_argument (
286
+ "--lndbtc.certpath" ,
287
+ metavar = "<hostname>" ,
288
+ help = "External lndbtc TLS certificate file"
289
+ )
290
+ group .add_argument (
291
+ "--lndbtc.macaroonpath" ,
292
+ metavar = "<hostname>" ,
293
+ help = "External lndbtc admin.macaroon path"
294
+ )
268
295
269
296
group = parser .add_argument_group ("lndltc" )
270
297
group .add_argument (
@@ -277,6 +304,33 @@ def parse_command_line_arguments(self):
277
304
action = "store_true" ,
278
305
help = "Preserve lndltc lnd.conf file during updates"
279
306
)
307
+ group .add_argument (
308
+ "--lndltc.mode" ,
309
+ metavar = "<mode>" ,
310
+ choices = ["native" , "external" ],
311
+ help = "Lndltc service mode"
312
+ )
313
+ group .add_argument (
314
+ "--lndltc.rpc-host" ,
315
+ metavar = "<hostname>" ,
316
+ help = "External lndltc RPC hostname"
317
+ )
318
+ group .add_argument (
319
+ "--lndltc.rpc-port" ,
320
+ type = int ,
321
+ metavar = "<port>" ,
322
+ help = "External lndltc RPC port"
323
+ )
324
+ group .add_argument (
325
+ "--lndltc.certpath" ,
326
+ metavar = "<hostname>" ,
327
+ help = "External lndltc TLS certificate file"
328
+ )
329
+ group .add_argument (
330
+ "--lndltc.macaroonpath" ,
331
+ metavar = "<hostname>" ,
332
+ help = "External lndltc admin.macaroon path"
333
+ )
280
334
281
335
group = parser .add_argument_group ("connext" )
282
336
group .add_argument (
@@ -665,20 +719,72 @@ def update_geth(self, parsed):
665
719
value = getattr (self .args , opt )
666
720
node ["cache" ] = value
667
721
722
+ def _get_value (self , key , node , parsed , validator = None , converter = None , default = None ):
723
+ result = None
724
+
725
+ node_name = node ["name" ]
726
+
727
+ def process (value , hint ):
728
+ if converter :
729
+ try :
730
+ value = converter (value )
731
+ except Exception as e :
732
+ raise ValueError ("({}) Invalid value: {}" .format (hint , value )) from e
733
+
734
+ if validator and not validator (value ):
735
+ raise ValueError (value )
736
+
737
+ return value
738
+
739
+ if key in parsed :
740
+ value = parsed [key ]
741
+ value = process (value , "{}.conf > {} > {}" .format (self .network , node_name , key ))
742
+ result = value
743
+
744
+ opt = "{}.{}" .format (node_name , key .replace ("-" , "_" ))
745
+
746
+ if hasattr (self .args , opt ):
747
+ value = getattr (self .args , opt )
748
+ value = process (value , "--{}" .format (opt .replace ("_" , "-" )))
749
+ result = value
750
+
751
+ if not result :
752
+ if default :
753
+ return default
754
+ msg = "configuration \" {}.{}\" missing (please specify command-line option \" --{}\" or add \" {}\" in your {}.conf \" {}\" section)" .format (
755
+ node_name , key , opt .replace ("_" , "-" ), key , self .network , node_name )
756
+ raise ValueError (msg )
757
+
758
+ return result
759
+
668
760
def update_lndbtc (self , parsed ):
669
761
"""Update lndbtc related configurations from parsed TOML lndbtc section
670
762
:param parsed: Parsed lndbtc TOML section
671
763
"""
672
764
node = self .nodes ["lndbtc" ]
673
765
self .update_ports (node , parsed )
674
766
767
+ node ["mode" ] = self ._get_value ("mode" , node , parsed , validator = lambda v : v in ["native" , "external" ], default = "native" )
768
+ if node ["mode" ] == "external" :
769
+ node ["rpc_host" ] = self ._get_value ("rpc_host" , node , parsed )
770
+ node ["rpc_port" ] = self ._get_value ("rpc_port" , node , parsed , converter = lambda v : int (v ))
771
+ node ["certpath" ] = self ._get_value ("certpath" , node , parsed )
772
+ node ["macaroonpath" ] = self ._get_value ("macaroonpath" , node , parsed )
773
+
675
774
def update_lndltc (self , parsed ):
676
775
"""Update lndltc related configurations from parsed TOML lndltc section
677
776
:param parsed: Parsed lndltc TOML section
678
777
"""
679
778
node = self .nodes ["lndltc" ]
680
779
self .update_ports (node , parsed )
681
780
781
+ node ["mode" ] = self ._get_value ("mode" , node , parsed , validator = lambda v : v in ["native" , "external" ], default = "native" )
782
+ if node ["mode" ] == "external" :
783
+ node ["rpc_host" ] = self ._get_value ("rpc_host" , node , parsed )
784
+ node ["rpc_port" ] = self ._get_value ("rpc_port" , node , parsed , converter = lambda v : int (v ))
785
+ node ["certpath" ] = self ._get_value ("certpath" , node , parsed )
786
+ node ["macaroonpath" ] = self ._get_value ("macaroonpath" , node , parsed )
787
+
682
788
def update_connext (self , parsed ):
683
789
"""Update Connext related configurations from parsed TOML connext section
684
790
:param parsed: Parsed connext TOML section
@@ -975,6 +1081,7 @@ def dump_attr(attr: str) -> None:
975
1081
if isinstance (value , bool ):
976
1082
value = str (value ).lower ()
977
1083
print ("{}=\" {}\" " .format (key , value ), file = f )
1084
+
978
1085
dump_attr ("branch" )
979
1086
dump_attr ("disable_update" )
980
1087
dump_attr ("external_ip" )
@@ -1024,16 +1131,21 @@ def dump_node_attr(node: str, attr: str) -> None:
1024
1131
if node in ["bitcoind" , "litecoind" ]:
1025
1132
dump_node_attr (node , "external_rpc_host" )
1026
1133
dump_node_attr (node , "external_rpc_port" )
1027
- #dump_node_attr(node, "external_rpc_user")
1028
- #dump_node_attr(node, "external_rpc_password")
1134
+ # dump_node_attr(node, "external_rpc_user")
1135
+ # dump_node_attr(node, "external_rpc_password")
1029
1136
dump_node_attr (node , "external_zmqpubrawblock" )
1030
1137
dump_node_attr (node , "external_zmqpubrawtx" )
1031
1138
elif node == "geth" :
1032
1139
dump_node_attr (node , "external_rpc_host" )
1033
1140
dump_node_attr (node , "external_rpc_port" )
1034
- #dump_node_attr(node, "infura_project_id")
1035
- #dump_node_attr(node, "infura_project_secret")
1141
+ # dump_node_attr(node, "infura_project_id")
1142
+ # dump_node_attr(node, "infura_project_secret")
1036
1143
dump_node_attr (node , "cache" )
1144
+ elif node in ["lndbtc" , "lndltc" ]:
1145
+ dump_node_attr (node , "rpc_host" )
1146
+ dump_node_attr (node , "rpc_port" )
1147
+ dump_node_attr (node , "certpath" )
1148
+ dump_node_attr (node , "macaroonpath" )
1037
1149
elif node == "arby" :
1038
1150
dump_node_attr (node , "test_centralized_baseasset_balance" )
1039
1151
dump_node_attr (node , "test_centralized_quoteasset_balance" )
@@ -1044,6 +1156,6 @@ def dump_node_attr(node: str, attr: str) -> None:
1044
1156
dump_node_attr (node , "live_cex" )
1045
1157
dump_node_attr (node , "test_mode" )
1046
1158
dump_node_attr (node , "cex" )
1047
- #dump_node_attr(node, "cex_api_key")
1048
- #dump_node_attr(node, "cex_api_secret")
1159
+ # dump_node_attr(node, "cex_api_key")
1160
+ # dump_node_attr(node, "cex_api_secret")
1049
1161
dump_node_attr (node , "margin" )
0 commit comments