🆕webln.request()

A generic API to leverage the full potential of your connected node. Use any API node provides.

âžĄī¸ This API is part of the upcoming WebBTC spec.

Method

async function request(method: string, params: Object): RequestResponse;

Response

See the API docs of the connector that is currently in use. (e.g. the LND API or the CLN API)

Code Example (using LND)

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})

Demos

Supported connectors

Connector
🐝 Alby

✅

Last updated