Skip to content

Add instructions on how to use lightning-liquidity crate #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ConorOkus opened this issue Apr 7, 2025 · 1 comment
Open

Add instructions on how to use lightning-liquidity crate #301

ConorOkus opened this issue Apr 7, 2025 · 1 comment

Comments

@ConorOkus
Copy link
Contributor

ConorOkus commented Apr 7, 2025

  1. To allow 0-conf channels, set UserConfig::manually_accept_inbound_channel and start handling OpenChannelRequest events via the ChannelManager::accept_inbound_channel_from_trusted_peer_0conf call
  2. Configure LiquidityManager by setting the LSPS2ClientConfig and set it as your CustomMessageHandler in MessagHandler that you give to PeerManager
  3. Set ChannelConfig:: accept_underpaying_htlcs to true and ChannelHandshakeConfig::max_inbound_value_in_flight_percent_of_channel to 100.
  4. Start handling LiquidityManager events (returned via next_event, next_event_async, or wait_next_event)
  5. Connect to the LSP
  6. Call LiquidityManager::lsps2_client_handler to get an LSPS2ClientHandler
  7. Call LSPS2ClientHandler::request_opening_params, you'll get an OpeningParametersReady event when the LSP responds
  8. Pick one of the opening parameters and remember them (to later check if the LSP just takes the fee you agreed on)
  9. Call LSPS2ClientHandler::select_opening_parameters, you'll get an InvoiceParametersReady event when the LSP responds
  10. Create a JIT invoice with the information given in said InvoiceParametersReady event
  11. Hand out that invoice, once it's paid, the LSP will open a channel to you and forward the HTLC
  12. In your event handling logic for the PaymentClaimable event, check that the LSP only withheld what you agreed upon above (you can use the compute_opening_fee util for that)
  13. Claim the payment if the LSP didn't cheat you

Note: This is for LSPS2

@tnull
Copy link
Contributor

tnull commented Apr 7, 2025

For LSPS1 the steps are roughly:

  1. Configure LiquidityManager by setting the LSPS1ClientConfig and set it as your CustomMessageHandler in MessagHandler that you give to PeerManager
  2. Start handling LiquidityManager events (returned via next_event, next_event_async, or wait_next_event)
  3. Connect to the LSP
  4. Call LiquidityManager::lsps1_client_handler to get an LSPS1ClientHandler
  5. Call LSPS1ClientHandler::request_supported_options, you'll get a SupportedOptionsReady event
  6. Check params for your order against the LSPS1Options limits returned by the LSP
  7. If all is clear, call LSPS1ClientHandler::create_order, you'll get a OrderCreated event in response
  8. Choose one of the payment methods as given in OrderCreated::payment, pay for the channel open
  9. The LSP will open the channel to you
  10. (Optionally) Check order status inbetween via LSPS1ClientHandler::check_order_status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants