Skip to content

Commit 88016a5

Browse files
authored
Merge pull request #274 from Camillarhi/expose-multi-lsp-support
Configure multiple LSPs as liquidity sources
2 parents f9bf766 + 0702f16 commit 88016a5

6 files changed

Lines changed: 288 additions & 44 deletions

File tree

contrib/ldk-server-config.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,19 @@ server_url = "ssl://electrum.blockstream.info:50002" # Electrum endpoint
6666
[esplora]
6767
server_url = "https://mempool.space/api" # Esplora endpoint
6868

69-
# LSPS2 Client Support
70-
[liquidity.lsps2_client]
71-
# The public key of the LSPS2 LSP we source just-in-time liquidity from.
69+
# LSPS Client Support
70+
# Repeat this section to register several LSPs. Supported protocols are discovered per
71+
# LSP via bLIP-50 / LSPS0 on startup. Only LSPS2 is supported at present.
72+
[[liquidity.lsps_client]]
73+
# The public key of the LSP we source inbound liquidity from.
7274
node_pubkey = "<lsp node pubkey>"
73-
# Address to connect to the LSPS2 LSP (IPv4:port, IPv6:port, OnionV3:port, or hostname:port).
75+
# Address to connect to the LSP (IPv4:port, IPv6:port, OnionV3:port, or hostname:port).
7476
address = "<lsp ip address>:9735"
7577
# Optional token for authenticating to the LSP.
7678
# token = ""
79+
# Accept 0-confirmation channels opened by this LSP. Required for JIT channels to be
80+
# usable before the funding transaction confirms.
81+
trust_peer_0conf = true
7782

7883
# Experimental LSPS2 Service Support
7984
# CAUTION: LSPS2 support is highly experimental and for testing purposes only.

docs/api-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ These RPCs support a manual claim/fail workflow for held payments. See
118118

119119
### BOLT11 JIT Channels (LSPS2)
120120

121-
Requires an `[liquidity.lsps2_client]` configuration. The LSP opens a channel just-in-time
122-
when the invoice is paid.
121+
Requires at least one `[[liquidity.lsps_client]]` entry for an LSPS2-capable LSP. The LSP opens
122+
a channel just-in-time when the invoice is paid.
123123

124124
| RPC | Description |
125125
|--------------------------------------------|-----------------------------------------------------------|

docs/configuration.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,22 @@ You must configure **exactly one** of the following sections:
147147
> against the blockchain. This means a malicious peer could flood your node with fake channel
148148
> announcements, consuming memory and disk. If your node is publicly reachable, use bitcoind.
149149
150-
### `[liquidity.lsps2_client]`
151-
152-
Connects to an [LSPS2](https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md)
153-
Liquidity Service Provider for just-in-time (JIT) inbound channel opening. When configured,
154-
the `Bolt11ReceiveViaJitChannel` and `Bolt11ReceiveVariableAmountViaJitChannel` RPCs become
155-
available, the LSP will open a channel on the fly when the generated invoice is paid.
156-
157-
Requires the LSP's public key and address. Some LSPs also require an authentication token.
150+
### `[[liquidity.lsps_client]]`
151+
152+
Registers a Liquidity Service Provider to source inbound liquidity from. Repeat the section
153+
to register several LSPs. Each LSP's supported protocols are discovered on startup via
154+
[bLIP-50 / LSPS0](https://github.com/lightning/blips/blob/master/blip-0050.md). LDK Server
155+
currently supports LSPS2 only, so an LSP that does not advertise it is registered but unused.
156+
157+
When at least one LSPS2-capable LSP is configured, the `Bolt11ReceiveViaJitChannel` and
158+
`Bolt11ReceiveVariableAmountViaJitChannel` RPCs become available, and the cheapest fee offer
159+
across all LSPS2-capable LSPs is selected per invoice.
160+
161+
Requires each LSP's public key and address. Some LSPs also require an authentication token.
162+
`trust_peer_0conf` is required and controls whether 0-confirmation channels from that LSP are
163+
accepted. Setting it to `true` is generally necessary for JIT channels to be usable before
164+
the funding transaction confirms. Each entry must name a distinct `node_pubkey` as duplicates
165+
are rejected at startup.
158166

159167
### `[liquidity.lsps2_service]`
160168

ldk-server-client/src/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,11 @@ mod tests {
294294
rpc_user = "bitcoind-testuser"
295295
rpc_password = "bitcoind-testpassword"
296296
297-
[liquidity.lsps2_client]
297+
[[liquidity.lsps_client]]
298298
node_pubkey = "0217890e3aad8d35bc054f43acc00084b25229ecff0ab68debd82883ad65ee8266"
299299
address = "127.0.0.1:39735"
300300
token = "lsps2-token"
301+
trust_peer_0conf = true
301302
302303
[liquidity.lsps2_service]
303304
advertise_service = false

ldk-server/src/main.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,15 @@ fn main() {
223223
std::process::exit(-1);
224224
}
225225

226-
if let Some(lsps2_client_config) = config_file.lsps2_client_config {
227-
builder.add_liquidity_source(
228-
lsps2_client_config.node_id,
229-
lsps2_client_config.address,
230-
lsps2_client_config.token,
231-
false,
232-
);
226+
if let Some(lsps_client_configs) = config_file.lsps_client_config {
227+
for lsps_client_config in lsps_client_configs {
228+
builder.add_liquidity_source(
229+
lsps_client_config.node_id,
230+
lsps_client_config.address,
231+
lsps_client_config.token,
232+
lsps_client_config.trust_peer_0conf,
233+
);
234+
}
233235
}
234236

235237
if let Some(tor_config) = config_file.tor_config {

0 commit comments

Comments
 (0)