lightningnetwork / lnd

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

Paying invoices via REST API not possible #5434

Closed peername closed 3 years ago

peername commented 3 years ago

Background

I have a node with a few channels opened. I am trying to send payments to other nodes via REST API. I am using:

https://api.lightning.community/#v1-channels-transactions

with a "payment_request" parameter. I tried with three different remote nodes and I receive the same error message: "No Root". One of the nodes receiving the payment is directly connected with my node. I tried many times, only on of ~20 attempts was successful.

When I try to settle the same invoices via LNCLI everything works. Every time it works with LNCLI.

Your environment

Steps to reproduce

Just try to settle an invoice via REST API.

Expected behaviour

REST API should work the same way as LNCLI or gRPC.

Actual behaviour

Most of the time it is not possible to settle an invoice via REST API. I get error message "No Root" or "Payment in Transit".

Roasbeef commented 3 years ago

Do you have any logs of a failed attempt? I think it might be the case that you aren't specifying the complete set of params when you go to send the payment?

Here's me paying an invoice on the command line using cURL and the REST interface:

curl --insecure --header "Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 /beef/.lnd/data/chain/bitcoin/testnet/admin.macaroon)"  --data '{"payment_request": "lntb10u1psdhgvfpp5ekrerrcx9euc7nyrnvwusr2gux9x9q8cn5es4q0m9rtq4kt4cgyqdqqcqzpgxqyz5vqsp5kzjpljz9cf0zur0wr83gasfu73sp7x4uzq9925qdw2l5kc693vys9qyyssqyctrk67z9tecl6kap8z06nzvhnkm27lg9gt4zhqfz44ms0sfcfsxq5jrclckhdjgvermn8yxrdq9u80jzylk3zwzv0hy2e5upy662vsqxuenpc"}' https://localhost:8080/v1/channels/transactions

The response:

{"payment_error":"","payment_preimage":"qgUDzVkWrJR9BaNKmuqYHJYj+ZWmVYEODDX4X3H1ZFU=","payment_route":{"total_time_lock":2006928,"total_fees":"0","total_amt":"1000","hops":[{"chan_id":"2172512930695872515","chan_capacity":"49200000","amt_to_forward":"1000","fee":"0","expiry":2006928,"amt_to_forward_msat":"1000000","fee_msat":"0","pub_key":"030f375d8aecdddc852309c15c3b67c2934de0de4d31e1e04a03d656ca0a78d008","tlv_payload":true,"mpp_record":{"payment_addr":"sKQfyEXCXi4N7hnijsE89GAfGrwQClVQDXK/S2NFiwk=","total_amt_msat":"1000000"},"amp_record":null,"custom_records":{}}],"total_fees_msat":"0","total_amt_msat":"1000000"},"payment_hash":"zYeRjwYueY9Mg5sdyA1I4YpigPidMwqB+yjWCtl1wgg="}

So things certainly work, either you're running into some other issue, or you aren't formatting things correctly.

Closing this for now, please re-open if you verify that you aren't affected by what was fixed in https://github.com/lightningnetwork/lnd/pull/5404 or something else.