@@ -356,6 +356,7 @@ def update(self, txid_hex: str, policy: dict, capacity: int, max_tries=2) -> dic
356
356
self .log .warning ("Channel Policy Updates not supported by CLN yet!" )
357
357
return None
358
358
359
+
359
360
class ECLAIR (LNNode ):
360
361
def __init__ (self , pod_name , ip_address ):
361
362
super ().__init__ (pod_name , ip_address )
@@ -365,9 +366,7 @@ def __init__(self, pod_name, ip_address):
365
366
self .reset_connection ()
366
367
367
368
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 )
371
370
372
371
def get (self , uri ):
373
372
attempt = 0
@@ -433,7 +432,7 @@ def newaddress(self, max_tries=10):
433
432
if not response :
434
433
sleep (5 )
435
434
continue
436
- return True , response .strip (" \" " )
435
+ return True , response .strip ('"' )
437
436
return False , ""
438
437
439
438
def uri (self ):
@@ -449,7 +448,7 @@ def walletbalance(self, max_tries=2) -> int:
449
448
sleep (2 )
450
449
continue
451
450
res = json .loads (response )
452
- return int (res ["total" ] * 100000000 ) # convert to sats
451
+ return int (res ["total" ] * 100000000 ) # convert to sats
453
452
return 0
454
453
455
454
def channelbalance (self , max_tries = 2 ) -> int :
@@ -478,14 +477,17 @@ def connect(self, target_uri, max_tries=5) -> dict:
478
477
479
478
def channel (self , pk , capacity , push_amt , fee_rate , max_tries = 10 ) -> dict :
480
479
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
482
484
data = {
483
485
"fundingSatoshis" : capacity ,
484
486
"pushMsat" : push_amt ,
485
487
"nodeId" : pk ,
486
488
"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?
489
491
attempt = 0
490
492
while attempt < max_tries :
491
493
attempt += 1
@@ -494,9 +496,13 @@ def channel(self, pk, capacity, push_amt, fee_rate, max_tries=10) -> dict:
494
496
if response :
495
497
if "created channel" in response :
496
498
# 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
+ }
500
506
else :
501
507
self .log .warning (f"unable to open channel: { response } , wait and retry..." )
502
508
sleep (1 )
@@ -508,8 +514,9 @@ def channel(self, pk, capacity, push_amt, fee_rate, max_tries=10) -> dict:
508
514
def createinvoice (self , sats , label , description = "new invoice" ) -> str :
509
515
b64_desc = base64 .b64encode (description .encode ("utf-8" ))
510
516
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
513
520
if response :
514
521
res = json .loads (response )
515
522
return res
@@ -526,7 +533,7 @@ def graph(self, max_tries=5) -> dict:
526
533
attempt = 0
527
534
while attempt < max_tries :
528
535
attempt += 1
529
- response = self .post ("/allupdates" ) # https://acinq.github.io/eclair/#allupdates
536
+ response = self .post ("/allupdates" ) # https://acinq.github.io/eclair/#allupdates
530
537
if response :
531
538
res = json .loads (response )
532
539
if len (res ) > 0 :
@@ -543,6 +550,7 @@ def update(self, txid_hex: str, policy: dict, capacity: int, max_tries=2) -> dic
543
550
self .log .warning ("Channel Policy Updates not supported by ECLAIR yet!" )
544
551
return None
545
552
553
+
546
554
class LND (LNNode ):
547
555
def __init__ (self , pod_name , ip_address ):
548
556
super ().__init__ (pod_name , ip_address )
0 commit comments