update cln holdinvoice plugin

DecodeBolt11 was removed in:
d51fd03390
This commit is contained in:
jerryfletcher21
2024-06-15 15:34:32 +02:00
parent daf9ce4d3f
commit 485961ee05

View File

@ -90,9 +90,9 @@ class CLNNode:
@classmethod @classmethod
def decode_payreq(cls, invoice): def decode_payreq(cls, invoice):
"""Decodes a lightning payment request (invoice)""" """Decodes a lightning payment request (invoice)"""
request = hold_pb2.DecodeBolt11Request(bolt11=invoice) nodestub = node_pb2_grpc.NodeStub(cls.node_channel)
holdstub = hold_pb2_grpc.HoldStub(cls.hold_channel) request = node_pb2.DecodeRequest(string=invoice)
response = holdstub.DecodeBolt11(request) response = nodestub.Decode(request)
return response return response
@classmethod @classmethod
@ -286,7 +286,7 @@ class CLNNode:
hold_payment["preimage"] = preimage.hex() hold_payment["preimage"] = preimage.hex()
hold_payment["payment_hash"] = response.payment_hash.hex() hold_payment["payment_hash"] = response.payment_hash.hex()
hold_payment["created_at"] = timezone.make_aware( 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( hold_payment["expires_at"] = timezone.make_aware(
datetime.fromtimestamp(response.expires_at) 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 # 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. # 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 # Max amount RoboSats will pay for routing
if routing_budget_ppm == 0: if routing_budget_ppm == 0:
@ -438,8 +438,8 @@ class CLNNode:
route_cost = 0 route_cost = 0
# ...add up the cost of every hinted hop... # ...add up the cost of every hinted hop...
for hop_hint in hinted_route.hops: for hop_hint in hinted_route.hops:
route_cost += hop_hint.feebase.msat / 1_000 route_cost += hop_hint.fee_base_msat.msat / 1_000
route_cost += hop_hint.feeprop * num_satoshis / 1_000_000 route_cost += hop_hint.fee_proportional_millionths * num_satoshis / 1_000_000
# ...and store the cost of the route to the array # ...and store the cost of the route to the array
routes_cost.append(route_cost) routes_cost.append(route_cost)
@ -466,7 +466,7 @@ class CLNNode:
return payout return payout
payout["created_at"] = timezone.make_aware( payout["created_at"] = timezone.make_aware(
datetime.fromtimestamp(payreq_decoded.timestamp) datetime.fromtimestamp(payreq_decoded.created_at)
) )
payout["expires_at"] = payout["created_at"] + timedelta( payout["expires_at"] = payout["created_at"] + timedelta(
seconds=payreq_decoded.expiry seconds=payreq_decoded.expiry