Skip to content

Commit

Permalink
Lnd gRPC
Browse files Browse the repository at this point in the history
  • Loading branch information
lollerfirst committed Jan 9, 2025
1 parent 84680da commit 3f12b64
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions cashu/lightning/lnd_grpc/lnd_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,21 +245,26 @@ async def pay_partial_invoice(
)
"""
# modify the mpp_record in the last hop
route_nr = 0
r.routes[route_nr].hops[-1].mpp_record.payment_addr = bytes.fromhex( # type: ignore
payer_addr
)
r.routes[route_nr].hops[ # type: ignore
-1
].mpp_record.total_amt_msat = total_amount_msat

# Send to route request
r = await router_stub.SendToRouteV2(
routerrpc.SendToRouteRequest(
payment_hash=bytes.fromhex(invoice.payment_hash),
route=r.routes[route_nr], # type: ignore
for route_nr in range(len(r.routes)):
r.routes[route_nr].hops[-1].mpp_record.payment_addr = bytes.fromhex( # type: ignore
payer_addr
)
)
r.routes[route_nr].hops[ # type: ignore
-1
].mpp_record.total_amt_msat = total_amount_msat

# Send to route request
r = await router_stub.SendToRouteV2(
routerrpc.SendToRouteRequest(
payment_hash=bytes.fromhex(invoice.payment_hash),
route=r.routes[route_nr], # type: ignore
)
)
if r.status == lnrpc.HTLCAttempt.HTLCStatus.FAILED:
if r.failure.code == lnrpc.Failure.FailureCode.TEMPORARY_CHANNEL_FAILURE:
# Try a different route
continue
break
except AioRpcError as e:
logger.error(f"QueryRoute or SendToRouteV2 failed: {e}")
return PaymentResponse(
Expand Down

0 comments on commit 3f12b64

Please sign in to comment.