npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lnbits-ts

v0.0.3

Published

NPM Package for LNBits.com API.

Downloads

648

Readme

LNBits JS API

npm version License: MIT


Easy way to add LNBits API to your JS application.


References


Donate

Help me to stack sats! :blush:

donate via Lightning Network!


Features


Installation

Using npm:

$ npm install lnbits-ts

Using yarn:

$ yarn add lnbits-ts

Usage

Initial Configuration

const LNBits = require("lnbits-ts").default; // using require

import LNBits from "lnbits-ts"; // using import

const { wallet, userManager, paywall, withdraw, paylink, tpos } = LNBits({
  adminKey: "d00265e7de5f44f59b2408d9f0564181",
  invoiceReadKey: "23e34be59d57408688a74500a3f24f03",
  endpoint: "https://lnbits.com", //default
});

Wallet

Wallet Details

[ Example ] [ top ]

const walletDetails = await wallet.walletDetails();
console.log(walletDetails);

Create Invoice

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {number} params.amount
  • {string} params.memo
  • {boolean} params.out
const newInvoice = await wallet.createInvoice({
  amount: 10,
  memo: "test",
  out: false,
});
console.log(newInvoice);

Pay Invoice

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.bolt11
  • {boolean} params.out
const newPayInvoice = await wallet.payInvoice({
  bolt11: "",
  out: true,
});
console.log(newPayInvoice);

Check Invoice

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.payment_hash
const checkinvoice = await wallet.checkInvoice({
  payment_hash: "...",
});
console.log(checkinvoice);

User Manager

Get Users

[ Example ] [ top ]

const users = await userManager.getUsers();
console.log(users);

Get Wallets

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.user_id
const wallets = await userManager.getWallets({
  user_id: "355c5110bed24744bebb12aecf8fad14",
});
console.log(wallets);

Get Transactions

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.wallet_id
const tx = await userManager.getTransactions({
  wallet_id: "4a18ae4b204044069bd349a37ba0be1d",
});
console.log(tx);

Create User

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.admin_id
  • {string} params.user_name
  • {string} params.wallet_name
const user = await userManager.createUser({
  admin_id: "355c5110bed24744bebb12aecf8fad14",
  user_name: "user",
  wallet_name: "wallet",
});
console.log(user);

Delete User

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.user_id
const userDeleted = await userManager.deleteUser({
  user_id: "b7cab6e3744347f2b6516510f5d40e9d",
});
console.log(userDeleted);

Delete Wallet

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.wallet_id
const walletDeleted = await userManager.deleteWallet({
  wallet_id: "0d52c8a832f84f9b86bd993b985e6f10",
});
console.log(walletDeleted);

Active Extension

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.userid
  • {string} params.extension
  • {boolean} params.active
const extension = await userManager.activeExtension({
  userid: "355c5110bed24744bebb12aecf8fad14",
  extension: "usermanager",
  active: true,
});
console.log(extension);

Paywall

Get Paywalls

[ Example ] [ top ]

const paywalls = await paywall.getPaywalls();
console.log(paywalls);

Create Paywall

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {number} params.amount
  • {string} params.description
  • {string} params.memo
  • {boolean} params.remembers
  • {string} params.url
const paywallNew = await paywall.createPaywall({
  amount: 10,
  description: "teste",
  memo: "teste memo",
  remembers: false,
  url: "https://teste.com",
});
console.log(paywallNew);

Create Invoice

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {number} params.amount
  • {string} params.paywall_id
const invoice = await paywall.createInvoice({
  amount: 10,
  paywall_id: "3UWoiHV7SYCytUjMfG8ySq",
});
console.log(invoice);

Check Invoice

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.paywall_id
  • {string} params.payment_hash
const invoiceCheck = await paywall.checkInvoice({
  paywall_id: "3UWoiHV7SYCytUjMfG8ySq",
  payment_hash:
    "e73dc54e857823b7c0bdd3faf6c0f6e8af2b07556fdc304cc8fe7c692a2562e8",
});
console.log(invoiceCheck);

Delete Paywall

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.paywall_id
const paywallDeleted = await paywall.deletePaywall({
  paywall_id: "3UWoiHV7SYCytUjMfG8ySq",
});
console.log(paywallDeleted);

Withdraw

Get Links

[ Example ] [ top ]

const withdrawLinks = await withdraw.getLinks({
  withdraw_id: "5o57EM9Qty5CLQB2QNjQ2p",
});
console.log(withdrawLinks);

Create Link

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.title
  • {number} params.min_withdrawable
  • {number} params.max_withdrawable
  • {number} params.uses
  • {number} params.wait_time
  • {boolean} params.is_unique
const link = await withdraw.createLink({
  title: "title",
  min_withdrawable: 10,
  max_withdrawable: 20,
  uses: 10,
  wait_time: 3600,
  is_unique: false,
});
console.log(link);

Update Link

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.withdraw_id
  • {string} params.title
  • {number} params.min_withdrawable
  • {number} params.max_withdrawable
  • {number} params.uses
  • {number} params.wait_time
  • {boolean} params.is_unique
const linkUpdated = await withdraw.updateLink({
  withdraw_id: "aaWVY3cu655xHxJpYLJhcA",
  title: "title",
  min_withdrawable: 10,
  max_withdrawable: 20,
  uses: 10,
  wait_time: 3600,
  is_unique: false,
});
console.log(linkUpdated);

Delete Link

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.withdraw_id
const linkDeleted = await withdraw.deleteLink({
  withdraw_id: "aaWVY3cu655xHxJpYLJhcA",
});
console.log(linkDeleted);

TPoS

Get TPoS

[ Example ] [ top ]

const tposs = await tpos.getTPoS();
console.log(tposs);

Create TPoS

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.currency
  • {string} params.name
const tposNew = await tpos.createTPoS({
  currency: "usd",
  name: "teste tpos",
});
console.log(tposNew);

Delete TPoS

[ Example ] [ top ]

Parameters:

  • {Object} params - Params object.
  • {string} params.tpos_id
const tposDeleted = await tpos.deleteTPoS({
  tpos_id: "PCXNcLsoLSaBhUybxHfoCN",
});
console.log(tposDeleted);

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.


License MIT