Fix tor proxy for c-lightning and fix bytes to hex for pay req fields

This commit is contained in:
yzernik 2022-05-05 01:35:21 -07:00
parent de58e9e824
commit 4fd61971c5
No known key found for this signature in database
GPG key ID: D761F27D9B20BA52
2 changed files with 8 additions and 5 deletions

View file

@ -30,6 +30,7 @@ services:
- --log-level=debug
- --rpc-file=/root/.lightning/lightning-rpc
- --rpc-file-mode=0777
- --proxy=tor-node:9050
volumes:
# shared volume is needed for sharing the btcd certificate

View file

@ -52,18 +52,20 @@ class CLightningClient(LightningClient):
def pay_invoice(self, payment_request: str) -> Payment:
pay_req = self.decode_pay_req(payment_request)
logger.info('decoded pay_req: {}'.format(pay_req))
route = self.lrpc.getroute(pay_req.destination, 100, 1)
logger.info('pay_req.destination: {}'.format(pay_req.destination))
route = self.lrpc.getroute(pay_req.destination, pay_req.num_msat, 1)
logger.info('route: {}'.format(route))
payment = self.lrpc.sendpay(
route['route'],
pay_req.payment_hash,
pay_req.payment_hash.hex(),
)
logger.info('payment: {}'.format(payment))
completed_payment = self.lrpc.waitsendpay(
route['route'],
pay_req.payment_hash,
pay_req.payment_hash.hex(),
)
if completed_payment['status'] == 'complete':
return Payment(
payment_preimage=payment['payment_preimage'],
payment_preimage=bytes.fromhex(payment['payment_preimage']),
payment_error='',
)
else: