RGB LSPS1 APIs
API
The RGB LSPS1 APIs enable management of channels and liquidity services following the Lightning Service Provider Specification (LSPS1). This section provides details on available endpoints and their usage.
1 Get Info
Request No parameters needed. Response
max_channel_expiry_blocks <uint32>
The maximum number of blocks a channel will remain open.MUST be 1 or greater.
This value determines how long the channel will be kept open, approximately 13,140 blocks correspond to 3 months.
min_initial_lsp_balance_sat
Minimum number of satoshis the LSP will provide to the channel.MUST be 0 or greater.
This sets the minimum liquidity the LSP offers when opening a channel.
max_initial_lsp_balance_sat <sat>
Maximum number of satoshis the LSP will provide to the channel.MUST be 0 or greater.
This is the upper limit of liquidity the LSP can offer, in this case, 1 BTC (100,000,000 sats).
min_channel_balance_sat <sat>
Minimum allowable size for the channel balance.MUST be 0 or greater.
Defines the smallest possible channel that can be opened, typically around 100,000 sats.
max_channel_balance_sat <sat>
Maximum allowable size for the channel balance.MUST be 0 or greater.
Defines the largest possible channel size, set to 100,000 sats in this case.
lsp_assets <array>
A list of supported assets for the LSP.MAY be empty if no specific assets are defined.
This array allows support for various cryptocurrencies or tokenized assets.
uris <array>
URIs of the LSP nodes used for clients to connect.This contains the node's public key, domain name or IP address, and the port number.
Client MUST connect to one of these URIs.
Every min/max
options pair MUST ensure that min <= max
.
2 Create Order
Request Fields
lsp_balance_sat <sat>
The size of the channel requested by the client in satoshis.Required
MUST be equal to or greater than
min_initial_lsp_balance_sat
and less than or equal to the amount available (max_channel_balance_sat
).MUST be 100,000 sats or greater (as recommended).
Example:
100000
(for a channel of 100,000 sats).
public_key <string>
The public key of the client's node. This public key will be used by the LSP to open the channel to the node.Required
The client must already be connected to the LSP node before sending the request.
Example:
"030e5245c3d4ad7a6ed15da5994ee436ebc42fc7114854fa722e737f9b8f23f832"
channel_expiry_blocks <uint32>
The number of blocks for which the channel will remain open.Required
MUST be less than or equal to
max_channel_expiry_blocks
from the/get_info
response.Example:
12960
(for a channel open for 90 days).
asset_amount <sat>
The amount of a specific asset (if applicable) requested for the channel.Optional
If provided,
asset_id
is also required.Example:
50000
(for an asset amount of 50,000 satoshis).
asset_id <string>
The ID of the asset being used for the channel.Optional
Required if
asset_amount
is provided.Example:
"rgb:25w4w77-sk7mfxMJC-cqiZmmZrx-hzrvcADto-R3z6em592-88fsXVV"
refund_on_chain_address <string>
The on-chain Bitcoin address where refunds will be sent if the channel opening fails.Optional if the client intends to pay with an on-chain Bitcoin payment.
Example:
"bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"
Response
Description
When an order is created, the client must already be connected to the LSP. The response contains the parameters provided by the client, which are necessary to open a channel. In the payment
field, two payment methods are available:
ln
– an invoice for payment in satoshis.btc_onchain – an onchain invoice for payment in satoshis.
To complete the order and create a channel, the client must connect to the node and pay the invoice. Once the invoice is paid, the channel with the requested liquidity will be created.
The channel: null
field indicates that the channel has not yet been created.
Order Statuses
An order can have the following statuses:
Channel Statuses
Pending: Order has been created but not yet completed.
Succeeded: Invoice has been paid, and the channel is created.
Failed: Channel creation or payment failed.
Expired: The order or invoice has expired.
3 Get Order
The get_order
endpoint returns the current status of an order.
Response
Channel Creation Workflow
If the user pays one of the invoices (either ln
or ln_asset
), a channel will be created by the LSP. There are several conditions required for a successful order completion:
Payment Success: Once the payment is successfully made, the LSP initiates the channel creation process.
Channel Initialization: The LSP generates a
temporary_channel_id
and gathers the parameters sent by the client. These parameters are used to call the/openchannel
API of the LSP node.Database Update: The response from the
/openchannel
API is recorded in the database, linking theorder_id
andtemporary_channel_id
. The channel is then marked with the statusPendingOpen
.Error Handling: In the event of an error during the channel creation process, the channel status is set to
FailedOpen
.
Re-checking Order Status via get_order
get_order
When the get_order
is called again, the following steps occur:
Order Retrieval: The order details are fetched from the database. The system checks the current status of the order.
PendingOpen Status: If the channel status is
PendingOpen
, the/getchannelid
API is called on the LSP node using thetemporary_channel_id
. This retrieves thechannel_id
.Channel Verification: The
/listchannels
API is then called to check whether the created channel exists in the array of open channels using thechannel_id
.Channel Found:
If the channel is found, the status of the channel is updated to
Open
, and the order status is updated toSuccess
.The order information, including the channel details, is returned to the user in the
channel
field.
Channel Not Found or Errors:
If the channel is not found or an error occurs, the order status is set to
Failed
, and the channel status is set toFailedOpen
.
Order Already Completed
If the channel has already been successfully created at the time of the get_order
call, the order information along with the channel details is returned in the response.
Channel Statuses
PendingOpen: The channel is being created but is not yet open.
Open: The channel has been successfully created.
FailedOpen: An error occurred during channel creation.
Success: The order and channel creation process was successful.
Failed: The order or channel creation failed.
Last updated