lightninglabs / lightning-terminal

Lightning Terminal: Your Home for Lightning Liquidity
MIT License
488 stars 82 forks source link

API SendPaymentV2 'failure_reason': 'FAILURE_REASON_NO_ROUTE' #714

Closed weltitob closed 5 months ago

weltitob commented 5 months ago

Hi when paying an invoice with the SendPaymentV2 I get the error 'failure_reason': 'FAILURE_REASON_NO_ROUTE' but when attempting to pay up exactly the same invoice with the v1/channels/transactions REST API endpoint (the deprecated version) instead it works completly fine..

import base64, codecs, json, requests

REST_HOST = 'mybitnet.com:8443'
MACAROON_PATH = './pythonfunctions/keys/lnd_admin.macaroon'
TLS_PATH = './pythonfunctions/fullchain.pem'

#url = f'https://{REST_HOST}/v1/channels/transactions' # DEPRECATED SOON!
url = f'https://{REST_HOST}/v2/router/send'
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
headers = {'Grpc-Metadata-macaroon': macaroon}

invoice_string  = '...'
#https://www.bolt11.org/
#Data either filles with dest, amt and payment_hash or with payment_request
data = {
  'timeout_seconds': 60,
  'payment_request': invoice_string, 
}

r = requests.post(url, headers=headers, stream=True, data=json.dumps(data), verify=False)
for raw_response in r.iter_lines():
  json_response = json.loads(raw_response)
  print(json_response)
guggero commented 5 months ago

You need to set a fee limit, otherwise it will only try to look for routes with zero fee.

weltitob commented 5 months ago

You need to set a fee limit, otherwise it will only try to look for routes with zero fee.

Thanks will try it out.