Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
alby-tools
Advanced tools
Collection of helpful building blocks and tools to develop Bitcoin Lightning web apps
An npm package that provides useful and common tools and helpers to build lightning web applications.
npm install alby-tools
or
yarn add alby-tools
The LightningAddress
class provides helpers to work with lightning addresses
const { LightningAddress } = require("alby-tools");
const ln = new LightningAddress("satoshi@getalby.com");
// fetch the LNURL data
await ln.fetch();
// get the LNURL-pay data:
console.log(ln.lnurlpData); // returns a [LNURLPayPesponse](https://github.com/getAlby/alby-tools/blob/master/src/types.ts#L1-L15)
// get the keysend data:
console.log(ln.keysendData);
const { LightningAddress } = require("alby-tools");
const ln = new LightningAddress("satoshi@getalby.com");
await ln.fetch();
// request an invoice for 1000 satoshis
// this returns a new `Invoice` class that can also be used to validate the payment
const invoice = await ln.requestInvoice({satoshi: 1000});
console.log(invoice.paymentRequest); // print the payment request
console.log(invoice.paymentHash); // print the payment hash
const { LightningAddress } = require("alby-tools");
const ln = new LightningAddress("satoshi@getalby.com");
await ln.fetch();
const invoice = await ln.requestInvoice({satoshi: 1000});
// if the LNURL providers supports LNURL-verify:
const paid = await invoice.verifyPayment(); // returns true of false
if (paid) {
console.log(invoice.preimage);
}
// if you have the preimage for example in a WebLN context
await window.webln.enable();
const response = await window.webln.sendPayment(invoice.paymentRequest);
const paid = invoice.validatePreimage(response.preimage); // returns true or false
if (paid) {
console.log('paid');
}
// or use the convenenice method:
await invoice.isPaid();
It is also possible to manually initialize the Invoice
const { Invoice } = require("alby-tools");
const invoice = new Invoice({paymentRequest: pr, preimage: preimage});
await invoice.isPaid();
Nostr is a simple, open protocol that enables truly censorship-resistant and global value-for-value publishing on the web. Nostr integrates deeply with Lightning. more info
alby-tools provides helpers to create zaps
const { LightningAddress } = require("alby-tools");
const ln = new LightningAddress("satoshi@getalby.com");
await ln.fetch();
const zapArgs = {
satoshi: 1000,
comment: "Awesome post",
relays: ["wss://relay.damus.io"],
p: "32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245",
e: "44e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"
}
const invoice = await ln.zap(zapArgs); // generates a zap invoice
console.log(invoice.paymentRequest); // print the payment request
await invoice.isPaid(); // check the payment status as descibed above
Helpers to convert sats values to fiat and fiat values to sats.
Returns the fiat value for a specified currrency of a satoshi amount
Returns the satoshi value for a specified amount (in the smallest denomination) and currency
Like getFiatValue
but returns a formatted string for a given locale using JavaScript's toLocaleString
await getFiatValue(satoshi: 2100, currency: 'eur');
await getSatoshiValue(amount: 100, currency: 'eur'); // for 1 EUR
await getFormattedFiatValue(stoshi: 2100, currency: 'usd', locale: 'en')
yarn install
yarn run build
FAQs
Collection of helpful building blocks and tools to develop Bitcoin Lightning web apps
The npm package alby-tools receives a total of 15 weekly downloads. As such, alby-tools popularity was classified as not popular.
We found that alby-tools 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.