RGB Lightning SDK

Setup

import { RgbSdk } from "@utexo/rgb-sdk";

const sdk = new RgbSdk({
  // internally holds xpub-van / xpub-col / master-fingerprint
  // and knows the configured bitcoin node endpoints
});

Lightning invoices (receive)

sdk.createInvoice(...)

Creates a Lightning invoice for receiving BTC or an RGB asset.

const req = await sdk.createInvoice({
  amount_sats?: number,         // BTC amount (optional)
  asset?: { asset_id: string, amount: number }, // asset invoice (optional)
  expiry_seconds?: number       // optional invoice expiry
});

Returns (LightningReceiveRequest):

{
  id: string,
  invoice: string,
  status: "OPEN",
  payment_type: "BTC",
  amount_sats?: number,
  asset?: { asset_id: string, amount: number },
  created_at: string
}

sdk.getReceiveRequestStatus(request_id)

Get invoice status by request id.

Returns: same LightningReceiveRequest shape as above.


Lightning payments (send)

sdk.payInvoiceBegin(...)

Begins paying a Lightning invoice.

Returns: string (SDK returns exactly what the API returns — a string payload, typically the thing you sign next).

sdk.payInvoiceEnd(...)

Completes the payment using a signed PSBT

Returns (LightningSendRequest):

sdk.getSendRequestStatus(request_id)

Get payment status by request id.

Returns: same LightningSendRequest shape as above.

sdk.feeEstimate(...)

Estimates routing fee to pay an invoice (optionally with asset context).

Returns: number

sdk.listPayments()

Lists Lightning payments (inbound/outbound).

Returns:


On-chain receive (for assets)

sdk.onchainReceive()

Returns a BTC address + an RGB invoice for receiving assets on-chain

Returns:


Balance + settle

sdk.getBalance()

Wallet balance (BTC + assets).

Returns:

On-chain send (from UTEXO)

sdk.onchainSendBegin(...)

Begins an on-chain send using address or RGB invoice.

Returns: string (the payload to sign psbt constracted client-side).

sdk.onchainSendEnd(...)

Completes on-chain send using signed PSBT.

Returns:

sdk.getOnchainSendStatus(send_id)

Status by send_id.

Returns:


Transfers (RGB on-chain history)

sdk.listTransfers(asset_id)

Lists on-chain transfers for a specific asset.

Returns: array of RgbTransfer objects

Last updated