Skip to content

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

Open
@ConorOkus

Description

@ConorOkus
  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions