UNPKG

lightningdevkit

Version:
84 lines (83 loc) 4.52 kB
import { ChannelId } from '../structs/ChannelId.mjs'; import { LSPSRequestId } from '../structs/LSPSRequestId.mjs'; import { Result_NoneAPIErrorZ } from '../structs/Result_NoneAPIErrorZ.mjs'; import { LSPS2RawOpeningFeeParams } from '../structs/LSPS2RawOpeningFeeParams.mjs'; import { HTLCDestination } from '../structs/HTLCDestination.mjs'; import { CommonBase } from './CommonBase.mjs'; /** * The main object allowing to send and receive bLIP-52 / LSPS2 messages. */ export declare class LSPS2ServiceHandler extends CommonBase { /** * Used by LSP to inform a client requesting a JIT Channel the token they used is invalid. * * Should be called in response to receiving a [`LSPS2ServiceEvent::GetInfo`] event. * * [`LSPS2ServiceEvent::GetInfo`]: crate::lsps2::event::LSPS2ServiceEvent::GetInfo */ invalid_token_provided(counterparty_node_id: Uint8Array, request_id: LSPSRequestId): Result_NoneAPIErrorZ; /** * Used by LSP to provide fee parameters to a client requesting a JIT Channel. * * Should be called in response to receiving a [`LSPS2ServiceEvent::GetInfo`] event. * * [`LSPS2ServiceEvent::GetInfo`]: crate::lsps2::event::LSPS2ServiceEvent::GetInfo */ opening_fee_params_generated(counterparty_node_id: Uint8Array, request_id: LSPSRequestId, opening_fee_params_menu: LSPS2RawOpeningFeeParams[]): Result_NoneAPIErrorZ; /** * Used by LSP to provide client with the intercept scid and cltv_expiry_delta to use in their invoice. * * Should be called in response to receiving a [`LSPS2ServiceEvent::BuyRequest`] event. * * [`LSPS2ServiceEvent::BuyRequest`]: crate::lsps2::event::LSPS2ServiceEvent::BuyRequest */ invoice_parameters_generated(counterparty_node_id: Uint8Array, request_id: LSPSRequestId, intercept_scid: bigint, cltv_expiry_delta: number, client_trusts_lsp: boolean, user_channel_id: bigint): Result_NoneAPIErrorZ; /** * Forward [`Event::HTLCIntercepted`] event parameters into this function. * * Will fail the intercepted HTLC if the intercept scid matches a payment we are expecting * but the payment amount is incorrect or the expiry has passed. * * Will generate a [`LSPS2ServiceEvent::OpenChannel`] event if the intercept scid matches a payment we are expected * and the payment amount is correct and the offer has not expired. * * Will do nothing if the intercept scid does not match any of the ones we gave out. * * [`Event::HTLCIntercepted`]: lightning::events::Event::HTLCIntercepted * [`LSPS2ServiceEvent::OpenChannel`]: crate::lsps2::event::LSPS2ServiceEvent::OpenChannel */ htlc_intercepted(intercept_scid: bigint, intercept_id: Uint8Array, expected_outbound_amount_msat: bigint, payment_hash: Uint8Array): Result_NoneAPIErrorZ; /** * Forward [`Event::HTLCHandlingFailed`] event parameter into this function. * * Will attempt to forward the next payment in the queue if one is present. * Will do nothing if the intercept scid does not match any of the ones we gave out * or if the payment queue is empty * * [`Event::HTLCHandlingFailed`]: lightning::events::Event::HTLCHandlingFailed */ htlc_handling_failed(failed_next_destination: HTLCDestination): Result_NoneAPIErrorZ; /** * Forward [`Event::PaymentForwarded`] event parameter into this function. * * Will register the forwarded payment as having paid the JIT channel fee, and forward any held * and future HTLCs for the SCID of the initial invoice. In the future, this will verify the * `skimmed_fee_msat` in [`Event::PaymentForwarded`]. * * Note that `next_channel_id` is required to be provided. Therefore, the corresponding * [`Event::PaymentForwarded`] events need to be generated and serialized by LDK versions * greater or equal to 0.0.107. * * [`Event::PaymentForwarded`]: lightning::events::Event::PaymentForwarded */ payment_forwarded(next_channel_id: ChannelId): Result_NoneAPIErrorZ; /** * Forward [`Event::ChannelReady`] event parameters into this function. * * Will forward the intercepted HTLC if it matches a channel * we need to forward a payment over otherwise it will be ignored. * * [`Event::ChannelReady`]: lightning::events::Event::ChannelReady */ channel_ready(user_channel_id: bigint, channel_id: ChannelId, counterparty_node_id: Uint8Array): Result_NoneAPIErrorZ; }