@@ -556,6 +556,7 @@ def __init__(self, lightning_dir, bitcoindproxy, port=9735, random_hsm=False, no
556
556
self .cmd_prefix = []
557
557
self .disconnect_file = None
558
558
self .lightning_dir = lightning_dir
559
+ self .use_rsignerd = False ;
559
560
self .rsignerd_dir = os .path .join (lightning_dir , "remotesigner" )
560
561
561
562
self .rpcproxy = bitcoindproxy
@@ -577,15 +578,18 @@ def __init__(self, lightning_dir, bitcoindproxy, port=9735, random_hsm=False, no
577
578
578
579
if SUBDAEMON :
579
580
opts ['subdaemon' ] = SUBDAEMON
580
-
581
+ if SUBDAEMON == 'hsmd:remote_hsmd' :
582
+ self .use_rsignerd = True
583
+
581
584
for k , v in opts .items ():
582
585
self .opts [k ] = v
583
586
584
587
if not os .path .exists (os .path .join (lightning_dir , TEST_NETWORK )):
585
588
os .makedirs (os .path .join (lightning_dir , TEST_NETWORK ))
586
589
587
- if not os .path .exists (self .rsignerd_dir ):
588
- os .makedirs (self .rsignerd_dir )
590
+ if self .use_rsignerd :
591
+ if not os .path .exists (self .rsignerd_dir ):
592
+ os .makedirs (self .rsignerd_dir )
589
593
590
594
# Last 32-bytes of final part of dir -> seed.
591
595
seed = (bytes (re .search ('([^/]+)/*$' , lightning_dir ).group (1 ), encoding = 'utf-8' ) + bytes (32 ))[:32 ]
@@ -598,8 +602,11 @@ def __init__(self, lightning_dir, bitcoindproxy, port=9735, random_hsm=False, no
598
602
self .prefix = 'lightningd-%d' % (node_id )
599
603
600
604
def cleanup (self ):
601
- # Make sure the remotesigner is shutdown
602
- self .rsignerd .stop ()
605
+ if self .use_rsignerd :
606
+ if self .use_rsignerd :
607
+ # Make sure the remotesigner is shutdown
608
+ self .rsignerd .stop ()
609
+
603
610
# To force blackhole to exit, disconnect file must be truncated!
604
611
if self .disconnect_file :
605
612
with open (self .disconnect_file , "w" ) as f :
@@ -623,32 +630,36 @@ def cmd_line(self):
623
630
def start (self , stdin = None , stdout = None , stderr = None ,
624
631
wait_for_initialized = True ):
625
632
try :
626
- # Start the remote signer first
627
- rsignerd_port = reserve ()
628
- self .rsignerd = RemoteSignerD (self .rsignerd_dir , rsignerd_port )
629
- self .rsignerd .start (stdin , stdout , stderr , wait_for_initialized )
633
+ if self .use_rsignerd :
634
+ # Start the remote signer first
635
+ rsignerd_port = reserve ()
636
+ self .rsignerd = RemoteSignerD (self .rsignerd_dir , rsignerd_port )
637
+ self .rsignerd .start (stdin , stdout , stderr , wait_for_initialized )
630
638
631
- # We can't do this in the constructor because we need a new port on each restart.
632
- self .env ['REMOTE_HSMD_ENDPOINT' ] = 'localhost:{}' .format (rsignerd_port )
639
+ # We can't do this in the constructor because we need a new port on each restart.
640
+ self .env ['REMOTE_HSMD_ENDPOINT' ] = 'localhost:{}' .format (rsignerd_port )
633
641
634
642
self .opts ['bitcoin-rpcport' ] = self .rpcproxy .rpcport
635
643
TailableProc .start (self , stdin , stdout , stderr )
636
644
if wait_for_initialized :
637
645
self .wait_for_log ("Server started with public key" )
638
646
logging .info ("LightningD started" )
639
647
except Exception :
640
- # LightningD didn't start, stop the remotesigner
641
- self .rsignerd .stop ()
648
+ if self .use_rsignerd :
649
+ # LightningD didn't start, stop the remotesigner
650
+ self .rsignerd .stop ()
642
651
raise
643
652
644
653
def stop (self , timeout = 10 ):
645
- # Stop the remote signer first
646
- self .rsignerd .stop (timeout )
654
+ if self .use_rsignerd :
655
+ # Stop the remote signer first
656
+ self .rsignerd .stop (timeout )
647
657
return TailableProc .stop (self , timeout )
648
658
649
659
def kill (self ):
650
- # Kill the remote signer first
651
- self .rsignerd .kill ()
660
+ if self .use_rsignerd :
661
+ # Kill the remote signer first
662
+ self .rsignerd .kill ()
652
663
TailableProc .kill (self )
653
664
654
665
def wait (self , timeout = 10 ):
0 commit comments