mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-07 18:04:07 +00:00
@ -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
|
||||||
|
Reference in New Issue
Block a user