#asknostr I signed up for #Bitrefill and I would like to send the account some funds from my CLN node. They offer me an lnurl (so the same thing used for zaps). How do I pay that using the lightning-cli (CLN)? I haven't figured out how to disable clnrest.py to actually use Zeus again - so the CLI is all I got. Thanks!

Reply to this note

Please Login to reply.

Discussion

I think you need to get a bolt11 invoice from the lnurl address or request. I have not personally dealt with this problem but this site looks promising. https://www.lnurlpay.com/

1. Decode the lnurl: The provided lnurl is usually encoded. Decode it to extract the actual URL for further details. In Python, you can use the bech32 library to decode it.

```

import bech32

hrp, data = bech32.decode(lnurl)

decoded_lnurl = bech32.convertbits(data, 5, 8, False)

```

2. Fetch lnurl Details: Perform an HTTP GET request to the decoded lnurl to obtain the invoice parameters.

```

import requests

response = requests.get(decoded_lnurl)

lnurl_data = response.json()

```

3. Construct Payment Parameters: Extract necessary parameters like callback URL, min amount, and max amount from lnurl_data.

```

callback_url = lnurl_data['callback']

min_amount = lnurl_data['min']

max_amount = lnurl_data['max']

```

4. Invoke lightning-cli to Prepare Invoice: Use the lightning-cli to generate an invoice on your node.

```

lightning-cli invoice [msatoshi] [label] [description]

```

5. Notify Service of Prepared Invoice: Typically, you need to notify the service that you have generated an invoice and are prepared to pay. This usually involves sending an HTTP GET or POST request to the callback_url.

```

callback_response = requests.get(f"{callback_url}?amount={min_amount}")

```

6. Perform the Payment: Use lightning-cli to execute the payment.

```

lightning-cli pay [bolt11]

```

7. Verify Payment: Verify that the payment was successful.

```

lightning-cli listpays [bolt11]

```

Replace placeholders like [msatoshi], [label], [description], and [bolt11] with actual values.