bitvora
v0.1.1
Published
A Node.js SDK for Bitvora
Downloads
14
Readme
Bitvora SDK
A Node.js SDK written in Typescript for the Bitvora API and Webhooks.
Installation
npm install bitvora
Usage
Sending Bitcoin (withdrawal)
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function sendBitcoin(): Promise<Withdrawal> {
const withdrawal = await bitvora.withdraw(
"[email protected]", // accepts on-chain, lightning invoice (payment request), lightning address, lnurl
10.0, // amount in your desired currency
Currency.USD // currency code
);
await withdrawal.isSettled(); // wait until the payment succeeds or fails, optional
return withdrawal;
}
Creating a Lightning Address
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function createLightningAddress(): Promise<CreateLightningAddressResponse> {
let metadata = {
userID: "your-internal-user-id",
email: "[email protected]",
}; // optional metadata object to attach, accepts any valid key-value object
return bitvora.createLightningAddress(metadata); // also accepts null
}
Create a Lightning Invoice
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function createLightningInvoice(): Promise<LightningInvoice> {
let metadata = {
userID: "your-internal-user-id",
email: "[email protected]",
}; // optional metadata object to attach, accepts any valid key-value object
const invoice = await bitvora.createLightningInvoice(
50,
Currency.SATS,
"this is from the sdk",
3600,
metadata
);
await invoice.isSettled();
return invoice;
}
Get Balance
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function getBalance(): Promise<number> {
return bitvora.getBalance();
}
Get Transactions
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function getTransactions(): Promise<GetTransactionsResponse> {
return bitvora.getTransactions();
}
Get Deposit
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function getDeposit(): Promise<BitcoinDepositResponse> {
return bitvora.getDeposit("UUID-HERE");
}
Get Withdrawal
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function getWithdrawal(): Promise<BitcoinWithdrawalResponse> {
return bitvora.getWithdrawal("UUID-HERE");
}