Integration Guide
Receive Lightning Invoice Payment Flow
This guide shows how to create a Lightning invoice (BTC or RGB asset), pay it (via UTEXO API), and verify the updated balance using rgb-sdk.
Prerequisites
RGB SDK repository: https://github.com/RGB-OS/rgb-sdk/tree/alpha
UTEXO API endpoint: https://rgb-node-demo.test.thunderstack.org
Install SDK (alpha tag):
npm install rgb-sdk@alphaTest Keys
Use these keys for testing purposes:
const keys = {
mnemonic: "split capable text loop dream live outside suspect eight carry fine relax",
account_xpub_vanilla:
"tpubDCRtZV7Pyz1HCM2wkthBybjx3VQyz1sBdjQNZtCSh8yc1zhDWpUDBiLzsGsLMNPh48YSmWiEoXLF9tzQAyVkuKBoPngTEU83yM1xuG3gKdM",
account_xpub_colored:
"tpubDDgW33tfESzvQd2wtZeqTGqcmtUVSCBNGMUTMTFkUTNTnq65TZigYuCptsePDgvzSqAHfA7D1MnPLkBHYQ11VQV25H9faFxHGC25Pzrb7xB",
master_fingerprint: "1f5bd7df",
};Test Asset Id
Step 1. Initialize and Register Wallet
Important: Wallet must be uninitialized before first use, then registered.
Step 2. Get On-chain Receive Address and Invoice
Use onchainReceive() to get a BTC address and asset invoice for on-chain deposits.
Example response:
Step 3. Check Balances (Optional)
getBalance() returns BTC and asset balances.
BTC Lightning receive updates:
balance.offchain_balance.total
Asset Lightning receive updates:
asset_balances[].balance.offchain_outbound
Example response:
Step 4. Create a Lightning Invoice
Create a BTC Lightning invoice
Create an Asset Lightning invoice
Example response:
Step 5. Pay the Invoice (Test via cURL)
Replace <invoice> with the invoice string returned above.
Step 6. Check Invoice Status
Use the invoice request id from Step 3.
Example response:
Step 7. Confirm Balance Updated
After the invoice is settled, BTC Lightning balance should be updated.
Example:
Step 8. List Lightning Payments
Use listLightningPayments() to retrieve all Lightning payments (both inbound and outbound).
Example response:
Payment fields:
amt_msat: Amount in millisatoshisasset_amount: Asset amount (if asset payment)asset_id: Asset ID (if asset payment)payment_hash: Payment hash identifierinbound:truefor received payments,falsefor sent paymentsstatus: Payment status (Pending,Succeeded,Failed)created_at: Timestamp when payment was createdupdated_at: Timestamp when payment was last updatedpayee_pubkey: Public key of the payee (recipient)
Notes
For BTC Lightning receive, check
balance.offchain_balance.total.For Asset Lightning receive, check
asset_balances[].balance.offchain_outbound.getLightningReceiveRequest(id)is the source of truth for invoice status:OPEN,SETTLED,EXPIRED,FAILED.
Pay Lightning Invoice Flow
This guide shows how to pay a Lightning invoice (BTC or RGB asset) using rgb-sdk.
Prerequisites
Create a test invoice (BTC)
Create a test invoice (asset)
Note: Test liquidity for asset Lightning payments is limited. For testing, use amounts below 80.
Example response:
Step 1. Pay Lightning Invoice
This flow uses:
payLightningInvoiceBeginβ returns a PSBTsignPsbtβ sign PSBT using user private keyspayLightningInvoiceEndβ broadcast the payment
Two reference implementations of signPsbt:
Example response:
Step 2. Check Send Request Status
Use the send request id returned in Step 1.
Example response:
Step 3. Send On-chain from UTEXO
This flow uses:
onchainSendBeginβ returns a PSBTsignPsbtβ sign PSBT using user private keysonchainSendEndβ broadcast the on-chain send
Two reference implementations of signPsbt:
https://github.com/RGB-OS/rgb-sdk-rn/blob/main/src/crypto/signer.ts#L195
https://github.com/RGB-OS/rgb-sdk/blob/main/src/crypto/signer.ts#L357
Example response:
Send Asset on-chain:
Step 4. Check On-chain Send Status
Use the send ID returned in Step 3.
Example response:
Step 5. List On-chain Transfers
Use listOnchainTransfers() to retrieve all on-chain transfers for a specific asset.
Example response:
Transfer fields:
idx: Transfer indexbatch_transfer_idx: Batch transfer indexcreated_at: Timestamp when transfer was createdupdated_at: Timestamp when transfer was last updatedstatus: Transfer statusamount: Transfer amountkind: Transfer kind/typetxid: Transaction IDrecipient_id: Recipient identifierreceive_utxo: Receive UTXO details (txid, vout)change_utxo: Change UTXO details (if any)expiration: Expiration timestamptransport_endpoints: Transport endpoints array
Notes
payLightningInvoiceBegin()returns a base64 PSBT that must be signed by the user.getLightningSendRequest(id)is the source of truth for payment status.
Alternative: Use UTEXO API Directly (Without RGB-SDK)
This page shows how to interact with UTEXO directly over HTTP, without using rgb-sdk.
API References
Base URL:
http://api.utexo.com
Common Headers
All endpoints below require the following auth headers:
xpub-van(string, required)xpub-col(string, required)master-fingerprint(string, required)
Tip: Keep these headers consistent across requests. They identify the wallet context.
GET /lightning/balance
Overview
Get lightning balance including BTC balance and asset balances.
Method
GET
Endpoint
/lightning/balance
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)
Example Request
Example Response
POST /lightning/create-invoice
Overview
Creates a Lightning invoice for receiving BTC or asset payments over the Lightning Network.
Method
POST
Endpoint
/lightning/create-invoice
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)Content-Type: application/json
Example Request (BTC)
Example Request (Asset)
Example Response
GET /lightning/receive-request/{request_id}
Overview
Returns the status of a Lightning invoice created with create-invoice. Supports both BTC and asset invoices.
Method
GET
Endpoint
/lightning/receive-request/{request_id}
Path Parameters
request_id(string, required) β The request ID of the Lightning invoice
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)
Example Request
Example Response
GET /lightning/send-request/{request_id}
Overview
Returns the current status of a Lightning payment initiated with the pay-invoice flow. Works for both BTC and asset payments.
Method
GET
Endpoint
/lightning/send-request/{request_id}
Path Parameters
request_id(string, required) β The request ID of the Lightning send request
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)
Example Request
Example Response
POST /lightning/fee-estimate
Overview
Estimates the routing fee required to pay a Lightning invoice. For asset payments, the returned fee is always denominated in satoshis.
Method
POST
Endpoint
/lightning/fee-estimate
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)Content-Type: application/json
Example Request (BTC)
Example Request (Asset)
Example Response
POST /lightning/pay-invoice-begin
Overview
Begins a Lightning invoice payment process. Returns the PSBT (should be signed by user).
Method
POST
Endpoint
/lightning/pay-invoice-begin
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)Content-Type: application/json
Example Request
Example Response
POST /lightning/pay-invoice-end
Overview
Completes a Lightning invoice payment using signed PSBT. Works the same as pay-invoice but uses signed_psbt instead of invoice.
Method
POST
Endpoint
/lightning/pay-invoice-end
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)Content-Type: application/json
Example Request
Example Response
GET /lightning/listpayments
Overview
Lists Lightning payments.
Method
GET
Endpoint
/lightning/listpayments
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)
Example Request
Example Response
GET /lightning/onchain-receive
Overview
Get an on-chain receive address for receiving assets. Returns a BTC address and asset invoice that can be used for on-chain deposits.
Method
GET
Endpoint
/lightning/onchain-receive
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)
Example Request
Example Response
GET /lightning/balance
Overview
Get wallet balance including BTC balance and asset balances.
Method
GET
Endpoint
/lightning/balance
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)
Example Request
Example Response
POST /lightning/settle
Overview
Settle balances in the wallet.
Method
POST
Endpoint
/lightning/settle
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)
Example Request
Example Response
POST /lightning/onchain-send-begin
Overview
Begins an on-chain send process from UTEXO. Returns the request encoded as base64 (mock PSBT). Later this should construct and return a real base64 PSBT.
Method
POST
Endpoint
/lightning/onchain-send-begin
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)Content-Type: application/json
Example Request (BTC)
Example Request (Asset)
Example Response
POST /lightning/onchain-send-end
Overview
Completes an on-chain send from UTEXO using signed PSBT.
Method
POST
Endpoint
/lightning/onchain-send-end
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)Content-Type: application/json
Example Request
Example Response
GET /onchain-send/{send_id}
Overview
Gets the status of an on-chain send by send ID.
Method
GET
Endpoint
/onchain-send/{send_id}
Path Parameters
send_id(string, required) β The on-chain send ID
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)
Example Request
Example Response
POST /lightning/listtransfers
Overview
Lists on-chain transfers for a specific asset.
Method
POST
Endpoint
/lightning/listtransfers
Headers
xpub-van(required)xpub-col(required)master-fingerprint(required)Content-Type: application/json
Example Request
Example Response
Notes
pay-invoice-beginreturns a PSBT that must be signed client-side.Use
pay-invoice-endto submit the signed PSBT and initiate/broadcast the payment.Use
GET /lightning/send-request/{request_id}as the source of truth for payment status.Use
GET /lightning/receive-request/{request_id}as the source of truth for invoice status.
Last updated