lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.67k stars 2.07k forks source link

/v1/peers POST not working (syntax error) #6643

Closed lightningorb closed 2 years ago

lightningorb commented 2 years ago

Background

When i try making a POST to /v1/peers to connect, it returns a syntax error.

Your environment

Steps to reproduce

import base64, codecs, json, requests

url = "https://<NODE_IP>:8080/v1/peers"
cert_path = "tls.cert"
macaroon = codecs.encode(open("admin.macaroon", "rb").read(), "hex")
headers = {"Grpc-Metadata-macaroon": macaroon}
data = {
    "addr": "0342a8a3ede9568778ea80a369901b680103e7ce06c0773696bf6fcbb805476aa1@217.173.236.78:17735",
    "perm": False,
    "timeout": "30",
}
# don't use cert for voltage node
r = requests.post(url, headers=headers, data=json.dumps(data))  # verify=cert_path
print(r.json())

Expected behaviour

Connects to the node.

Actual behaviour

{'code': 3, 'message': 'proto: syntax error (line 1:10): unexpected token "0342a8a3ede9568778ea80a369901b680103e7ce06c0773696bf6fcbb805476aa1"', 'details': []}
guggero commented 2 years ago

That's because addr needs to be an object too, not a string: https://api.lightning.community/#lnrpclightningaddress

lightningorb commented 2 years ago

Fair, however this is misleading:

Lightning address of the peer, in the format <pubkey>@host
guggero commented 2 years ago

Didn't see that comment, fixed in https://github.com/lightningnetwork/lnd/pull/6644.

lightningorb commented 2 years ago

Super thanks.