🆕
webln.request()
A generic API to leverage the full potential of your connected node. Use any API node provides.
The available APIs heavily depend on the connector (LND, CLN, etc) that is used. You can use
webln.getInfo
to check for supported methods. (methods
) async function request(method: string, params: Object): RequestResponse;
await webln.enable();
// check if the connected node supports the required methods
const info = await webln.getInfo();
if (!info.methods.includes("listpeers")) {
alert('Invalid node connection. Please use LND');
}
// list all connected peers
await webln.request("listpeers");
// response:
{ peers: [
address: "85.128.153.40:9735",
bytes_recv: "23275891"
bytes_sent: "519238"
... see LND API: https://api.lightning.community/#lnrpc-peer
]}
// connect to a new peer
const pubkey = "02af02be7c7e5cf...";
const host = "152.82.72.42:9735";
await webln.request('connectpeer', { addr: {host, pubkey }, perm: true})
Connector | 🐝 Alby |
---|---|
✅ | |
✅ |
Last modified 4mo ago