From 485961ee05e9053a91f8c825cd34ce50b8514f96 Mon Sep 17 00:00:00 2001 From: jerryfletcher21 Date: Sat, 15 Jun 2024 15:34:32 +0200 Subject: [PATCH] update cln holdinvoice plugin DecodeBolt11 was removed in: https://github.com/daywalker90/holdinvoice/commit/d51fd0339030c4a4f97dc92ab148b37340ae6370 --- api/lightning/cln.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/lightning/cln.py b/api/lightning/cln.py index 590ac721..a9726e70 100755 --- a/api/lightning/cln.py +++ b/api/lightning/cln.py @@ -90,9 +90,9 @@ class CLNNode: @classmethod def decode_payreq(cls, invoice): """Decodes a lightning payment request (invoice)""" - request = hold_pb2.DecodeBolt11Request(bolt11=invoice) - holdstub = hold_pb2_grpc.HoldStub(cls.hold_channel) - response = holdstub.DecodeBolt11(request) + nodestub = node_pb2_grpc.NodeStub(cls.node_channel) + request = node_pb2.DecodeRequest(string=invoice) + response = nodestub.Decode(request) return response @classmethod @@ -286,7 +286,7 @@ class CLNNode: hold_payment["preimage"] = preimage.hex() hold_payment["payment_hash"] = response.payment_hash.hex() hold_payment["created_at"] = timezone.make_aware( - datetime.fromtimestamp(payreq_decoded.timestamp) + datetime.fromtimestamp(payreq_decoded.created_at) ) hold_payment["expires_at"] = timezone.make_aware( datetime.fromtimestamp(response.expires_at) @@ -418,7 +418,7 @@ class CLNNode: # Some wallet providers (e.g. Muun) force routing through a private channel with high fees >1500ppm # These payments will fail. So it is best to let the user know in advance this invoice is not valid. - route_hints = payreq_decoded.route_hints.hints + route_hints = payreq_decoded.routes.hints # Max amount RoboSats will pay for routing if routing_budget_ppm == 0: @@ -438,8 +438,8 @@ class CLNNode: route_cost = 0 # ...add up the cost of every hinted hop... for hop_hint in hinted_route.hops: - route_cost += hop_hint.feebase.msat / 1_000 - route_cost += hop_hint.feeprop * num_satoshis / 1_000_000 + route_cost += hop_hint.fee_base_msat.msat / 1_000 + route_cost += hop_hint.fee_proportional_millionths * num_satoshis / 1_000_000 # ...and store the cost of the route to the array routes_cost.append(route_cost) @@ -466,7 +466,7 @@ class CLNNode: return payout payout["created_at"] = timezone.make_aware( - datetime.fromtimestamp(payreq_decoded.timestamp) + datetime.fromtimestamp(payreq_decoded.created_at) ) payout["expires_at"] = payout["created_at"] + timedelta( seconds=payreq_decoded.expiry