getAlby / lightning-browser-extension

The Bitcoin Lightning Browser Extension that brings deep Lightning & Nostr integration to the web. Wallet interface to multiple lightning nodes and key signer for Nostr, Liquid and onchain use.
https://getalby.com/#extension
MIT License
540 stars 194 forks source link

CLN Support for BTCPay option #2203

Open pavlenex opened 1 year ago

pavlenex commented 1 year ago

As agreed on Telegram, opening this issue as a reminder to add ability for BTCPay Server's using CLN as their LN implementation to connect to Alby.

reneaaron commented 1 year ago

Hey @pavlenex! Thanks for reporting this issue, I just looked into it:

Currently it just assume it's a LND connection but since BTCPay Server supports different Lightning Node implementations we need to add support for exchanging other node backend credentials via the config URL.

https://github.com/getAlby/lightning-browser-extension/blob/master/src/app/screens/connectors/ConnectBtcpay/index.tsx#L42-L44

I currently don't have access to a BTCPay Server running on CLN, could you maybe provide the response of this config requests on your CLN setup? (just open the URL it in your browser and post the redacted JSON here)

stackingsaunter commented 1 year ago

@pavlenex I want to prepare design for this, but what should be the form in that connector? Standard CLN form or a config data analogous to LND? I'd need a copy for updated instruction and link for CLN config then

Screenshot 2023-03-20 at 13 10 10 Screenshot 2023-03-20 at 13 12 12
pavlenex commented 1 year ago

@stackingsaunter we expose it same way we do the LND. I think it would make sense to have it same way you do for LND.

stackingsaunter commented 1 year ago

@pavlenex great, can you just give me specific copy in exchange of "LND Rest - See information" and an example link (the current one has lnd within). A screenshot will sufice!

pavlenex commented 1 year ago

@stackingsaunter Sure, here you go. Bear in mind, for c-lightning we call it lnd.config for some reason cc @kukks Screenshot 2023-03-21 at 11 39 48 AM Screenshot 2023-03-21 at 11 39 41 AM

Screenshot 2023-03-21 at 11 39 15 AM

stackingsaunter commented 1 year ago

Okay, so it should look like this with updated layout from https://github.com/getAlby/lightning-browser-extension/issues/2250 or the same as BTCPay LND with updated copy in the current layout

Screenshot 2023-03-23 at 01 00 32
lujakob commented 1 year ago

You could assign it to me as I am working on #2254 where it will be used.

reneaaron commented 1 year ago

After trying to debug this issue I found out that BTCPay Server doesn't ship core-lightning plugins (or connection credentials related to them). That means we would have to re-implement a core-lightning connector using the REST APIs provided through BTCPay Server instead of using the current implementation that is using commando to communicate with the node.

For future reference, the config URL returns this JSON for core-lightning nodes:

{
    "configurations": [
        {
            "uri": "https://btcpayserver.example.com/clightning-rest/btc",
            "chainType": "Mainnet",
            "type": "clightning-rest",
            "cryptoCode": "BTC",
            "certificationThumbprint": null,
            "macaroon": "0201010b...",
            "adminMacaroon": null,
            "readonlyMacaroon": null,
            "invoiceMacaroon": null
        }
    ]
}

Let's discuss that in tomorrows community call maybe @lujakob.

lujakob commented 1 year ago

@reneaaron yes I could need a little bit more information here. Let's discuss these days.

lujakob commented 1 year ago

@reneaaron could you please comment our conclusion please.

reneaaron commented 1 year ago

I found out that BTCPay Server doesn't ship core-lightning plugins (or connection credentials related to them). That means we would have to re-implement a core-lightning connector using the REST APIs provided through BTCPay Server instead of using the current implementation that is using commando to communicate with the node.

The config API from BTCPay Server returns the following object for a core-lightning node:

{
    "configurations": [
        {
            "uri": "https://btcpayserver.example.com/clightning-rest/btc",
            "chainType": "Mainnet",
            "type": "clightning-rest",
            "cryptoCode": "BTC",
            "certificationThumbprint": null,
            "macaroon": "0201010b...",
            "adminMacaroon": null,
            "readonlyMacaroon": null,
            "invoiceMacaroon": null
        }
    ]
}

TODO

I don't think it would be very complicated to do that (the LND connector very much works the same way) but currently not the highest priority.

If anyone is interested in implementing this please reach out (you will need a running instance of BTCPay Server & Core-Lightning to tackle this issue). I think it would be great to support multiple node backends for BTCPay Server.