@@ -356,6 +356,7 @@ def update(self, txid_hex: str, policy: dict, capacity: int, max_tries=2) -> dic
356356 self .log .warning ("Channel Policy Updates not supported by CLN yet!" )
357357 return None
358358
359+
359360class ECLAIR (LNNode ):
360361 def __init__ (self , pod_name , ip_address ):
361362 super ().__init__ (pod_name , ip_address )
@@ -365,9 +366,7 @@ def __init__(self, pod_name, ip_address):
365366 self .reset_connection ()
366367
367368 def reset_connection (self ):
368- self .conn = http .client .HTTPConnection (
369- host = self .name , port = 8080 , timeout = 5
370- )
369+ self .conn = http .client .HTTPConnection (host = self .name , port = 8080 , timeout = 5 )
371370
372371 def get (self , uri ):
373372 attempt = 0
@@ -433,7 +432,7 @@ def newaddress(self, max_tries=10):
433432 if not response :
434433 sleep (5 )
435434 continue
436- return True , response .strip (" \" " )
435+ return True , response .strip ('"' )
437436 return False , ""
438437
439438 def uri (self ):
@@ -449,7 +448,7 @@ def walletbalance(self, max_tries=2) -> int:
449448 sleep (2 )
450449 continue
451450 res = json .loads (response )
452- return int (res ["total" ] * 100000000 ) # convert to sats
451+ return int (res ["total" ] * 100000000 ) # convert to sats
453452 return 0
454453
455454 def channelbalance (self , max_tries = 2 ) -> int :
@@ -478,14 +477,17 @@ def connect(self, target_uri, max_tries=5) -> dict:
478477
479478 def channel (self , pk , capacity , push_amt , fee_rate , max_tries = 10 ) -> dict :
480479 import math
481- fee_rate_factor = math .ceil (fee_rate / 170 ) #FIXME: reduce fee rate by factor to get close to original value
480+
481+ fee_rate_factor = math .ceil (
482+ fee_rate / 170
483+ ) # FIXME: reduce fee rate by factor to get close to original value
482484 data = {
483485 "fundingSatoshis" : capacity ,
484486 "pushMsat" : push_amt ,
485487 "nodeId" : pk ,
486488 "fundingFeerateSatByte" : fee_rate_factor ,
487- "fundingFeeBudgetSatoshis" : fee_rate
488- } # FIXME: https://acinq.github.io/eclair/#open-2 what parameters should be sent?
489+ "fundingFeeBudgetSatoshis" : fee_rate ,
490+ } # FIXME: https://acinq.github.io/eclair/#open-2 what parameters should be sent?
489491 attempt = 0
490492 while attempt < max_tries :
491493 attempt += 1
@@ -494,9 +496,13 @@ def channel(self, pk, capacity, push_amt, fee_rate, max_tries=10) -> dict:
494496 if response :
495497 if "created channel" in response :
496498 # created channel e872f515dc5d8a3d61ccbd2127f33141eaa115807271dcc5c5c727f3eca914d3 with fundingTxId=bc2b8db55b9588d3a18bd06bd0e284f63ee8cc149c63138d51ac8ef81a72fc6f and fees=720 sat
497- channel_id = re .search (r'channel ([0-9a-f]+)' , response ).group (1 )
498- funding_tx_id = re .search (r'fundingTxId=([0-9a-f]+)' , response ).group (1 )
499- return {"txid" : funding_tx_id , "outpoint" : f"{ funding_tx_id } :N/A" , "channel" : channel_id }
499+ channel_id = re .search (r"channel ([0-9a-f]+)" , response ).group (1 )
500+ funding_tx_id = re .search (r"fundingTxId=([0-9a-f]+)" , response ).group (1 )
501+ return {
502+ "txid" : funding_tx_id ,
503+ "outpoint" : f"{ funding_tx_id } :N/A" ,
504+ "channel" : channel_id ,
505+ }
500506 else :
501507 self .log .warning (f"unable to open channel: { response } , wait and retry..." )
502508 sleep (1 )
@@ -508,8 +514,9 @@ def channel(self, pk, capacity, push_amt, fee_rate, max_tries=10) -> dict:
508514 def createinvoice (self , sats , label , description = "new invoice" ) -> str :
509515 b64_desc = base64 .b64encode (description .encode ("utf-8" ))
510516 response = self .post (
511- "/createinvoice" , {"amountMsat" : sats * 1000 , "description" : label , "description" : b64_desc }
512- ) # https://acinq.github.io/eclair/#createinvoice
517+ "/createinvoice" ,
518+ {"amountMsat" : sats * 1000 , "description" : label , "descriptionHash" : b64_desc },
519+ ) # https://acinq.github.io/eclair/#createinvoice
513520 if response :
514521 res = json .loads (response )
515522 return res
@@ -526,7 +533,7 @@ def graph(self, max_tries=5) -> dict:
526533 attempt = 0
527534 while attempt < max_tries :
528535 attempt += 1
529- response = self .post ("/allupdates" ) # https://acinq.github.io/eclair/#allupdates
536+ response = self .post ("/allupdates" ) # https://acinq.github.io/eclair/#allupdates
530537 if response :
531538 res = json .loads (response )
532539 if len (res ) > 0 :
@@ -543,6 +550,7 @@ def update(self, txid_hex: str, policy: dict, capacity: int, max_tries=2) -> dic
543550 self .log .warning ("Channel Policy Updates not supported by ECLAIR yet!" )
544551 return None
545552
553+
546554class LND (LNNode ):
547555 def __init__ (self , pod_name , ip_address ):
548556 super ().__init__ (pod_name , ip_address )
0 commit comments