File size: 10,919 Bytes
4a30181 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | # rgb-lightning-node (RLN) — Developer Reference
> **Source:** https://github.com/RGB-Tools/rgb-lightning-node
> **OpenAPI / Swagger UI:** https://rgb-tools.github.io/rgb-lightning-node
> **Part of:** github.com/RGB-Tools — official higher-level projects for RGB Protocol on Bitcoin v0.11.1
RLN is an RGB-enabled Lightning node based on LDK (Lightning Development Kit). It allows opening Lightning channels that carry both satoshis and RGB assets. Each Lightning commitment transaction includes an additional output anchoring the RGB state transition, so asset state changes follow the same security model as standard Lightning payments.
**Projects using RLN:** KaleidoSwap, ThunderStack, LNFI, Iris Wallet desktop, Spectrum, Tiramisu Wallet
---
## How RGB works on Lightning
- Channels are funded with both satoshis and RGB assets
- Each channel update (HTLC) includes a new RGB state transition committed in the output
- HTLCs carry both satoshi and RGB asset allocations
- Every RGB Lightning payment also transfers satoshis (required to keep outputs above the dust limit)
- If an output falls below the dust limit, the UTXO cannot be spent and the RGB allocation becomes inaccessible — always keep allocations above dust
For technical details: https://docs.rgb.info/lightning-network-compatibility
---
## Requirements
Each RLN node requires:
1. A bitcoind node
2. An indexer (Electrum or Esplora)
3. An `rgb-proxy-server` instance
---
## Install
```sh
git clone https://github.com/RGB-Tools/rgb-lightning-node --recurse-submodules --shallow-submodules
cargo install --locked --path .
# or build Docker image
docker build -t rgb-lightning-node .
```
---
## Run
### Regtest (with Docker services)
```sh
# Start bitcoind + electrs + rgb-proxy-server in Docker
./regtest.sh start
# Start three nodes (each in a separate terminal)
rgb-lightning-node dataldk0/ \
--daemon-listening-port 3001 \
--ldk-peer-listening-port 9735 \
--network regtest \
--disable-authentication
rgb-lightning-node dataldk1/ \
--daemon-listening-port 3002 \
--ldk-peer-listening-port 9736 \
--network regtest \
--disable-authentication
rgb-lightning-node dataldk2/ \
--daemon-listening-port 3003 \
--ldk-peer-listening-port 9737 \
--network regtest \
--disable-authentication
# Utility commands
./regtest.sh sendtoaddress <address> <amount>
./regtest.sh mine <blocks>
./regtest.sh stop
```
Regtest services for `/unlock`:
```json
{
"bitcoind_rpc_username": "user",
"bitcoind_rpc_password": "password",
"bitcoind_rpc_host": "localhost",
"bitcoind_rpc_port": 18433,
"indexer_url": "127.0.0.1:50001",
"proxy_endpoint": "rpc://127.0.0.1:3000/json-rpc"
}
```
### Regtest (Docker container)
```sh
docker run --rm -it \
-p 3001:3001 \
-v RLNdata1:/RLNdata \
--network rgb-lightning-node_default \
rgb-lightning-node \
--daemon-listening-port 3001 \
--ldk-peer-listening-port 9735 \
--network regtest \
--disable-authentication \
RLNdata
# remove data: docker volume rm RLNdata1
```
### Testnet3
```sh
rgb-lightning-node dataldk0/ \
--daemon-listening-port 3001 \
--ldk-peer-listening-port 9735 \
--network testnet \
--disable-authentication
```
Testnet3 public services for `/unlock`:
```json
{
"bitcoind_rpc_username": "user",
"bitcoind_rpc_password": "password",
"bitcoind_rpc_host": "electrum.iriswallet.com",
"bitcoind_rpc_port": 18332,
"indexer_url": "ssl://electrum.iriswallet.com:50013",
"proxy_endpoint": "rpcs://proxy.iriswallet.com/0.2/json-rpc"
}
```
### Testnet4
Same as testnet3 except:
- CLI flag: `--network testnet4`
- `bitcoind_rpc_port`: 18443
- `indexer_url`: `ssl://electrum.iriswallet.com:50053`
---
## Authentication (Biscuit tokens)
By default authentication is enabled. For regtest/dev use `--disable-authentication`.
For production:
```sh
# Install biscuit CLI
cargo install biscuit-cli
# Generate root keypair (save private key securely)
biscuit keypair
# or: biscuit keypair --only-private-key > private-key-file
# Mint tokens
echo 'role("admin");' \
| biscuit generate --private-key-file private-key-file - # full access
echo 'role("read-only");' \
| biscuit generate --private-key-file private-key-file - # read-only
# Token with expiry
echo 'role("admin");
check if time($t), $t <= 2025-12-31T00:00:00Z;' \
| biscuit generate --private-key-file private-key-file -
# Custom permissions
echo 'role("custom");
right("api", "/nodeinfo");
right("api", "/networkinfo");' \
| biscuit generate --private-key-file private-key-file -
```
Start node with authentication:
```sh
rgb-lightning-node dataldk0/ \
--daemon-listening-port 3001 \
--ldk-peer-listening-port 9735 \
--network regtest \
--root-public-key <public_key>
```
Use token in requests:
```sh
curl -H "Authorization: Bearer <token>" http://localhost:3001/nodeinfo
```
---
## REST API reference
All endpoints are POST unless noted otherwise. Base URL: `http://localhost:<daemon-port>`.
Full OpenAPI spec: https://rgb-tools.github.io/rgb-lightning-node
### Node lifecycle
| Endpoint | Method | Description |
|---|---|---|
| `/init` | POST | Initialize node: set passwords, connect indexer, proxy |
| `/unlock` | POST | Unlock node (provide bitcoind/indexer/proxy credentials) |
| `/lock` | POST | Lock node |
| `/shutdown` | POST | Stop the node daemon |
| `/nodeinfo` | GET | Node public key, alias, peers, channels |
| `/networkinfo` | GET | Bitcoin network info |
| `/sync` | POST | Sync wallet state with the indexer |
### Bitcoin wallet
| Endpoint | Method | Description |
|---|---|---|
| `/address` | POST | Get a Bitcoin address |
| `/btcbalance` | POST | Bitcoin balance (settled + pending) |
| `/createutxos` | POST | Create UTXOs for RGB allocations |
| `/sendbtc` | POST | Send Bitcoin to an address |
| `/estimatefee` | POST | Estimate fee for a transaction |
| `/listtransactions` | POST | List Bitcoin transactions |
| `/listunspents` | POST | List UTXOs with RGB allocations |
| `/backup` | POST | Backup wallet |
| `/restore` | POST | Restore wallet from backup |
| `/changepassword` | POST | Change unlock password |
| `/checkindexerurl` | POST | Validate indexer URL |
| `/checkproxyendpoint` | POST | Validate proxy endpoint URL |
### RGB asset issuance
| Endpoint | Method | Description |
|---|---|---|
| `/issueassetnia` | POST | Issue NIA (fixed-supply fungible) |
| `/issueassetifa` | POST | Issue IFA (inflatable fungible) |
| `/issueassetcfa` | POST | Issue CFA (collectible fungible) |
| `/issueassetuda` | POST | Issue UDA (non-fungible / NFT) |
| `/inflate` | POST | Inflate supply (IFA only) |
### RGB asset management
| Endpoint | Method | Description |
|---|---|---|
| `/listassets` | POST | List all known RGB assets |
| `/assetbalance` | POST | Balance for a specific asset |
| `/assetmetadata` | POST | Metadata for a specific asset |
| `/getassetmedia` | POST | Retrieve media file for a UDA |
| `/postassetmedia` | POST | Upload media file for a UDA |
| `/listtransfers` | POST | List RGB transfer history |
| `/refreshtransfers` | POST | Refresh transfer statuses |
| `/failtransfers` | POST | Mark stale transfers as failed |
### Lightning channels
| Endpoint | Method | Description |
|---|---|---|
| `/openchannel` | POST | Open a Lightning channel (with optional RGB asset funding) |
| `/closechannel` | POST | Close a channel |
| `/listchannels` | GET | List open channels |
| `/getchannelid` | POST | Get channel ID for a peer/channel pair |
### Lightning payments
| Endpoint | Method | Description |
|---|---|---|
| `/lninvoice` | POST | Create a standard Lightning invoice |
| `/decodelninvoice` | POST | Decode a Lightning invoice |
| `/rgbinvoice` | POST | Create an RGB Lightning invoice |
| `/decodergbinvoice` | POST | Decode an RGB Lightning invoice |
| `/sendpayment` | POST | Send a Lightning payment |
| `/sendrgb` | POST | Send RGB assets via Lightning |
| `/keysend` | POST | Keysend payment (no invoice needed) |
| `/getpayment` | POST | Get details for a specific payment |
| `/listpayments` | GET | List all payments |
| `/invoicestatus` | POST | Check status of an invoice |
### Peers
| Endpoint | Method | Description |
|---|---|---|
| `/connectpeer` | POST | Connect to a Lightning peer |
| `/disconnectpeer` | POST | Disconnect a peer |
| `/listpeers` | GET | List connected peers |
| `/sendonionmessage` | POST | Send an onion message |
### Atomic swaps (RGB asset exchange)
| Endpoint | Method | Description |
|---|---|---|
| `/makerinit` | POST | Maker: initialize atomic swap offer |
| `/makerexecute` | POST | Maker: execute atomic swap |
| `/taker` | POST | Taker: accept atomic swap |
| `/getswap` | POST | Get details for a specific swap |
| `/listswaps` | GET | List all swaps |
### Other
| Endpoint | Method | Description |
|---|---|---|
| `/signmessage` | POST | Sign a message with node key |
| `/revoketoken` | POST | Revoke an authentication token |
---
## Example workflow
```sh
BASE=http://localhost:3001
# 1. Initialize and unlock
curl -X POST -H "Content-type: application/json" \
-d '{"password":"secret","bitcoind_rpc_username":"user","bitcoind_rpc_password":"password","bitcoind_rpc_host":"localhost","bitcoind_rpc_port":18433,"indexer_url":"127.0.0.1:50001","proxy_endpoint":"rpc://127.0.0.1:3000/json-rpc"}' \
$BASE/init
# 2. Get a Bitcoin address and fund the wallet
curl -X POST $BASE/address
# 3. Create UTXOs for RGB
curl -X POST -H "Content-type: application/json" \
-d '{"fee_rate":1.5}' $BASE/createutxos
# 4. Issue a NIA asset
curl -X POST -H "Content-type: application/json" \
-d '{"ticker":"DEMO","name":"Demo Token","amounts":[1000000],"precision":0}' \
$BASE/issueassetnia
# 5. Open a channel to node 2 (with RGB asset)
curl -X POST -H "Content-type: application/json" \
-d '{"peer_pubkey_and_opt_addr":"<node2_pubkey>@localhost:9736","capacity_sat":100000,"push_msat":50000,"asset_amount":500000,"asset_id":"<asset_id>","fee_rate":1.5,"public":true}' \
$BASE/openchannel
# 6. Create RGB invoice on node 2
curl -X POST -H "Content-type: application/json" \
-d '{"asset_id":"<asset_id>","amount":100,"expiry_sec":3600}' \
http://localhost:3002/rgbinvoice
# 7. Send RGB assets from node 1
curl -X POST -H "Content-type: application/json" \
-d '{"invoice":"<rgb_invoice>","amount":100,"asset_id":"<asset_id>","fee_msat":1000}' \
$BASE/sendrgb
```
---
## Canonical sources
- https://github.com/RGB-Tools/rgb-lightning-node — repository
- https://rgb-tools.github.io/rgb-lightning-node — OpenAPI spec / Swagger UI
- https://docs.rgb.info/lightning-network-compatibility — RGB on Lightning technical docs
- https://github.com/RGB-Tools/rgb-proxy-server — required proxy server
- https://github.com/RGB-Tools/rgb-lib — wallet library used by applications
|