lightninglabs / lightning-terminal

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

API Call Lightning Terminal not working #707

Closed weltitob closed 5 months ago

weltitob commented 5 months ago

My Code:


import base64, codecs, json, requests
import sys

REST_HOST = 'localhost:8443' #8443
MACAROON_PATH = './pythonfunctions/admin.macaroon'
TLS_PATH = './pythonfunctions/taproot_tls.cert'

url = f'https://{REST_HOST}/v1/taproot-assets/getinfo'
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
headers = {'Grpc-Metadata-macaroon': macaroon}
response = requests.get(url, headers=headers, verify=TLS_PATH)

if response.status_code == 200:
    try:
        data = response.json()
        print(data)  # Print the parsed JSON data
        # process data
    except json.JSONDecodeError:
        # Handle JSON decode error
        print("Response is not in JSON format:", response.text)
else:
    # Handle HTTP error
    print("Error:", response.status_code, response.text)

My Error message: Response is not in JSON format: <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/icons/favicon-32x32.png"/><meta name="theme-color" content="#000000"/><link rel="apple-touch-icon" sizes="48x48" href="/icons/icon-48x48.png"/><link rel="apple-touch-icon" sizes="72x72" href="/icons/icon-72x72.png"/><link rel="apple-touch-icon" sizes="96x96" href="/icons/icon-96x96.png"/><link rel="apple-touch-icon" sizes="144x144" href="/icons/icon-144x144.png"/><link rel="apple-touch-icon" sizes="192x192" href="/icons/icon-192x192.png"/><link rel="apple-touch-icon" sizes="256x256" href="/icons/icon-256x256.png"/><link rel="apple-touch-icon" sizes="384x384" href="/icons/icon-384x384.png"/><link rel="apple-touch-icon" sizes="512x512" href="/icons/icon-512x512.png"/><link rel="manifest" href="/manifest.json"/><title>Lightning Terminal</title><script defer="defer" src="/static/js/main.49cc9a87.js"></script><link href="/static/css/main.488ab95f.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

I dont know how to activate Javascript, am I doing something wrong, do I need to include soem sort of other information on API request or what am I missing?

ViktorTigerstrom commented 5 months ago

Hi @weltitob! I'll move this comment over to #706, and close this issue so that we can keep the conversation under the same issue.

weltitob commented 5 months ago

Hi @weltitob! I'll move this comment over to #706, and close this issue so that we can keep the conversation under the same issue.

Please leave the issues separated. Even I envounter Kind of a Seminar issue its completly unrelated. One node is running on a Ubuntu System where the terminal ui works just fine its only the docker instances where the terminal ui doesnt work.

I seperated the issues because it gets confusing if we put these issues in one place. They do end up with a similar message at one point but one instance is running in the docker Container and the other one (the api error) is running on a local Ubuntu Installation.

As for the api call issue: The Browser I use for the api calls would be Firefox and Javascript seems ro be enabled for it.

I tried tricking the System by provoding some wrong Browser data in the request but this didnt Effect the error.