Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Talk to Lightning nodes from your browser.
yarn add lnmessage
npm i lnmessage
import Lnmessage from 'lnmessage'
async function connect() {
// initialise the library
const ln = new Lnmessage({
// The public key of the node you would like to connect to
remoteNodePublicKey: '02df5ffe895c778e10f7742a6c5b8a0cefbe9465df58b92fadeb883752c8107c8f',
// Optional WebSocket proxy endpoint to connect through (see WebSocket Proxy section)
wsProxy: 'wss://<WEBSOCKET_PROXY>',
// The IP address of the node
ip: '35.232.170.67',
// The port of the node, defaults to 9735
port: 9735,
// Hex encoded private key string to use for the node local secret. Use this to persist the node public key across connections
privateKey: 'd6a2eba36168cc31e97396a781a4dd46dd3648c001d3f4fde221d256e41715ea'
})
// initiate the connection to the remote node
await ln.connect()
// if you have connected to a Core Lightning node that you have a rune for....
ln.commando({
method: 'getinfo',
params: [],
rune: '<BASE64_RUNE>'
})
}
connect()
There are some limitations to connecting to Lightning nodes within a browser. Core Lightning nodes can be directly connected to if the experimental-websocket-port
option is set in the config. This will allow a direct connection to the node, but if you are running a browser app on https, then it will not allow a connection to a non SSL WebSocket endpoint, so you would need to setup SSL for your node. As far as I know LND nodes do not accept connections via WebSocket at this time.
So to simplify connecting to any Lightning node, you can go through a WebSocket proxy (see Clams and jb55's WebSocket proxy server repos). Going through a proxy like this requires no trust in the server. The WebSocket connection is initated with the proxy, which then creates a regular TCP socket connection to the node. Then all messages are fully encrypted via the noise protocol, so the server only sees encrypted binary traffic that is simply proxied between the browser and the node. Currently only clearnet is supported, but I believe that the WebSocket proxy code could be modified to create a socket connection to a TOR only node to make this work.
lnmessage
will handle matching requests with responses and in most cases this just works. For RPC calls where a large response is expected (listinvoices
, listpays
etc) it is recommended to await
these calls without making other calls simultaneously. A proxy server socket connection may split the response in to multiple parts. This leads to the messages possibly getting scrambled if multiple requests are made at the same time.Yarn - yarn
NPM - npm i
Yarn - yarn build
NPM - npm run build
FAQs
Talk to Lightning nodes from your browser
The npm package lnmessage receives a total of 13 weekly downloads. As such, lnmessage popularity was classified as not popular.
We found that lnmessage demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.