![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@jamaljsr/lnrpc
Advanced tools
A Typescript gRPC client for LND with support for all LND sub-servers
A Typescript gRPC client for LND with support for all LND sub-servers. Originally forked from Matt-Jensen/lnrpc. Forked again from RadarTech/lnrpc to migrate from the soon to be deprecated grpc
package to grpc-js
.
npm install @jamaljsr/lnrpc
# OR
yarn add @jamaljsr/lnrpc
Notes:
--no-macaroons
, unless you provide macaroon authentication to your lnrpc instance when created.npm rebuild
:
Error: Failed to load gRPC binary module because it was not installed for the current system
This package exports a create function for the main gRPC server as well as each sub-server:
import {
createAutopilotRpc,
createChainRpc,
createInvoicesRpc,
createLnRpc,
createRouterRpc,
createSignRpc,
createWalletRpc,
createWatchtowerRpc,
createWtClientRpc,
} from '@radar/lnrpc';
You can also import the create function for the main gRPC server using the default import:
import createLnRpc from '@radar/lnrpc';
If you want to interact with all servers, wrap the functions in a class or object for easy initialization:
import createLnRpc, {
AutopilotRpc,
ChainRpc,
createAutopilotRpc,
createChainRpc,
createInvoicesRpc,
createRouterRpc,
createSignRpc,
createWalletRpc,
createWatchtowerRpc,
createWtClientRpc,
InvoicesRpc,
LnRpc,
RouterRpc,
RpcClientConfig,
SignRpc,
WalletRpc,
WatchtowerRpc,
WtClientRpc,
} from '@radar/lnrpc';
export class Lightning {
public static lnrpc: LnRpc;
public static autopilotrpc: AutopilotRpc;
public static chainrpc: ChainRpc;
public static invoicesrpc: InvoicesRpc;
public static routerrpc: RouterRpc;
public static signrpc: SignRpc;
public static walletrpc: WalletRpc;
public static watchtowerrpc: WatchtowerRpc;
public static wtclientrpc: WtClientRpc;
/**
* Initialize gRPC clients for the main server and all sub-servers
* @param config The RPC client connection configuration
*/
public static async init(config: RpcClientConfig): Promise<void> {
this.lnrpc = await createLnRpc(config);
this.autopilotrpc = await createAutopilotRpc(config);
this.chainrpc = await createChainRpc(config);
this.invoicesrpc = await createInvoicesRpc(config);
this.routerrpc = await createRouterRpc(config);
this.signrpc = await createSignRpc(config);
this.walletrpc = await createWalletRpc(config);
this.watchtowerrpc = await createWatchtowerRpc(config);
this.wtclientrpc = await createWtClientRpc(config);
}
}
Connecting to an lnd instance at localhost:10001
.
import createLnRpc from '@radar/lnrpc';
(async () => {
const lnRpcClient = await createLnRpc(config);
// All requests are promisified and typed
const { confirmedBalance } = await lnRpcClient.walletBalance();
// ...and you're off!
console.log(confirmedBalance);
// subscribe to LND server events
const subscriber = await lnRpcClient.subscribeInvoices();
subscriber.on('data', invoice => {
console.log(invoice); // do something with invoice event
});
})();
import createLnRpc from '@radar/lnrpc';
(async () => {
const lnRpcClient = await createLnRpc({
/*
* By default lnrpc connects to `localhost:10001`,
* however we can point to any host.
*/
server: '173.239.209.2:3001',
/*
* By default lnrpc looks for your tls certificate at:
* `~/.lnd/tls.cert`, unless it detects you're using macOS and
* defaults to `~/Library/Application\ Support/Lnd/tls.cert`
* however you can configure your own SSL certificate path like:
*/
tls: './path/to/tls.cert',
/*
* You can also provide a TLS certificate directly as a string
* (Just make sure you don't commit this to git).
* Overwrites: `tls`
*/
cert: process.env.MY_SSL_CERT,
/*
* Optional path to configure macaroon authentication
* from LND generated macaroon file.
*/
macaroonPath: './path/to/data/admin.macaroon',
/*
* Optional way to configure macaroon authentication by
* passing a hex encoded string of your macaroon file.
* Encoding: `xxd -ps -u -c 1000 ./path/to/data/admin.macaroon`
* Details: https://github.com/lightningnetwork/lnd/blob/dc3db4b/docs/macaroons.md#using-macaroons-with-grpc-clients
*/
macaroon: process.env.MY_MACAROON_HEX,
});
try {
const getInfoResponse = await lnRpcClient.getInfo();
console.log(getInfoResponse);
} catch (error) {
console.error(error);
}
})();
All main server (lnrpc) methods documentation can be found here.
By default lnrpc assumes SSl certificate pinning.
In order to use lnrpc with a service (like BTCPayServer) which manages your certification,
you'll have to opt to disable certificate pinning by passing { tls: false }
within your lnrpc configuration.
git clone git@github.com:RadarTech/lnrpc.git && cd $_
npm install
# OR
yarn
To change the gRPC definitions used for all auto-generated types and RPC methods edit the config.lnd_release_tag
value in package.json
to the desired LND release tag and run the following:
npm run update-protos
# OR
yarn update-protos
# AND
npm run generate
# OR
yarn generate
Newly generated type definitions will be available in ./generated
.
You can now delete the old proto file inside the lnd directory.
Use the generated type definitions to update the types in src/types/rpc
.
Any added streaming methods must be included in the subscriptionMethods
array that's into the createServiceClient
function.
This prevents streaming methods from being promisified.
This project is licensed under the MIT License.
FAQs
A Typescript gRPC client for LND with support for all LND sub-servers
The npm package @jamaljsr/lnrpc receives a total of 2 weekly downloads. As such, @jamaljsr/lnrpc popularity was classified as not popular.
We found that @jamaljsr/lnrpc demonstrated a not healthy version release cadence and project activity because the last version was released 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.