UNPKG

lightningdevkit

Version:
646 lines (645 loc) 42.5 kB
import { TxOut } from '../structs/TxOut.mjs'; import { COption_NoneZ } from '../enums/COption_NoneZ.mjs'; import { Currency } from '../enums/Currency.mjs'; import { Option_u64Z } from '../structs/Option_u64Z.mjs'; import { BlindedMessagePath } from '../structs/BlindedMessagePath.mjs'; import { Option_ThirtyTwoBytesZ } from '../structs/Option_ThirtyTwoBytesZ.mjs'; import { Result_ThirtyTwoBytesNoneZ } from '../structs/Result_ThirtyTwoBytesNoneZ.mjs'; import { OutPoint } from '../structs/OutPoint.mjs'; import { SpendableOutputDescriptor } from '../structs/SpendableOutputDescriptor.mjs'; import { Option_u32Z } from '../structs/Option_u32Z.mjs'; import { Result_C2Tuple_CVec_u8Zu64ZNoneZ } from '../structs/Result_C2Tuple_CVec_u8Zu64ZNoneZ.mjs'; import { HTLCOutputInCommitment } from '../structs/HTLCOutputInCommitment.mjs'; import { Option_u16Z } from '../structs/Option_u16Z.mjs'; import { RouteParameters } from '../structs/RouteParameters.mjs'; import { Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ } from '../structs/Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.mjs'; import { ChannelDetails } from '../structs/ChannelDetails.mjs'; import { Result_RouteLightningErrorZ } from '../structs/Result_RouteLightningErrorZ.mjs'; import { Logger } from '../structs/Logger.mjs'; import { NetworkGraph } from '../structs/NetworkGraph.mjs'; import { LSPS2OpeningFeeParams } from '../structs/LSPS2OpeningFeeParams.mjs'; import { Result_PublicKeySecp256k1ErrorZ } from '../structs/Result_PublicKeySecp256k1ErrorZ.mjs'; import { Result_COption_NetworkUpdateZDecodeErrorZ } from '../structs/Result_COption_NetworkUpdateZDecodeErrorZ.mjs'; import { Result_NoneLightningErrorZ } from '../structs/Result_NoneLightningErrorZ.mjs'; import { ChannelAnnouncement } from '../structs/ChannelAnnouncement.mjs'; import { NodeAnnouncement } from '../structs/NodeAnnouncement.mjs'; import { Result_u64ShortChannelIdErrorZ } from '../structs/Result_u64ShortChannelIdErrorZ.mjs'; import { Result_PendingHTLCInfoInboundHTLCErrZ } from '../structs/Result_PendingHTLCInfoInboundHTLCErrZ.mjs'; import { Bolt11Invoice } from '../structs/Bolt11Invoice.mjs'; import { Result_Bolt11InvoiceSignOrCreationErrorZ } from '../structs/Result_Bolt11InvoiceSignOrCreationErrorZ.mjs'; import { Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ } from '../structs/Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.mjs'; import { PhantomRouteHints } from '../structs/PhantomRouteHints.mjs'; import { ChannelMonitor } from '../structs/ChannelMonitor.mjs'; import { Watch } from '../structs/Watch.mjs'; import { BroadcasterInterface } from '../structs/BroadcasterInterface.mjs'; import { EntropySource } from '../structs/EntropySource.mjs'; import { ExpandedKey } from '../structs/ExpandedKey.mjs'; import { NodeSigner } from '../structs/NodeSigner.mjs'; import { SignerProvider } from '../structs/SignerProvider.mjs'; import { FeeEstimator } from '../structs/FeeEstimator.mjs'; import { Router } from '../structs/Router.mjs'; import { OnionMessagePath } from '../structs/OnionMessagePath.mjs'; import { MessageRouter } from '../structs/MessageRouter.mjs'; import { ChannelManager } from '../structs/ChannelManager.mjs'; import { Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ } from '../structs/Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ.mjs'; import { Result_COption_APIErrorZDecodeErrorZ } from '../structs/Result_COption_APIErrorZDecodeErrorZ.mjs'; import { Result_COption_MonitorEventZDecodeErrorZ } from '../structs/Result_COption_MonitorEventZDecodeErrorZ.mjs'; import { Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ } from '../structs/Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.mjs'; import { OnionMessageContents } from '../structs/OnionMessageContents.mjs'; import { Result_NoneIOErrorZ } from '../structs/Result_NoneIOErrorZ.mjs'; import { Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ } from '../structs/Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ.mjs'; import { Result_SocketAddressSocketAddressParseErrorZ } from '../structs/Result_SocketAddressSocketAddressParseErrorZ.mjs'; import { UpdateAddHTLC } from '../structs/UpdateAddHTLC.mjs'; import { OnionMessage } from '../structs/OnionMessage.mjs'; import { Result_COption_InboundHTLCStateDetailsZDecodeErrorZ } from '../structs/Result_COption_InboundHTLCStateDetailsZDecodeErrorZ.mjs'; import { Result_COption_OutboundHTLCStateDetailsZDecodeErrorZ } from '../structs/Result_COption_OutboundHTLCStateDetailsZDecodeErrorZ.mjs'; import { Option_HTLCClaimZ } from '../structs/Option_HTLCClaimZ.mjs'; import { TxCreationKeys } from '../structs/TxCreationKeys.mjs'; import { Result_COption_PathFailureZDecodeErrorZ } from '../structs/Result_COption_PathFailureZDecodeErrorZ.mjs'; import { Result_COption_ClosureReasonZDecodeErrorZ } from '../structs/Result_COption_ClosureReasonZDecodeErrorZ.mjs'; import { Result_COption_HTLCDestinationZDecodeErrorZ } from '../structs/Result_COption_HTLCDestinationZDecodeErrorZ.mjs'; import { Result_COption_PaymentFailureReasonZDecodeErrorZ } from '../structs/Result_COption_PaymentFailureReasonZDecodeErrorZ.mjs'; import { ChannelTypeFeatures } from '../structs/ChannelTypeFeatures.mjs'; import { Result_COption_EventZDecodeErrorZ } from '../structs/Result_COption_EventZDecodeErrorZ.mjs'; import { InitFeatures } from '../structs/InitFeatures.mjs'; import { Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ } from '../structs/Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ.mjs'; import { Result_PeeledOnionNoneZ } from '../structs/Result_PeeledOnionNoneZ.mjs'; import { Option_FilterZ } from '../structs/Option_FilterZ.mjs'; import { ChangeDestinationSource } from '../structs/ChangeDestinationSource.mjs'; import { KVStore } from '../structs/KVStore.mjs'; import { OutputSpender } from '../structs/OutputSpender.mjs'; import { Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ } from '../structs/Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ.mjs'; import { DelayedPaymentKey } from '../structs/DelayedPaymentKey.mjs'; import { RevocationKey } from '../structs/RevocationKey.mjs'; import { MigratableKVStore } from '../structs/MigratableKVStore.mjs'; import { ProbabilisticScoringFeeParameters } from '../structs/ProbabilisticScoringFeeParameters.mjs'; import { ScoreLookUp } from '../structs/ScoreLookUp.mjs'; import { UserConfig } from '../structs/UserConfig.mjs'; import { Sha256 } from '../structs/Sha256.mjs'; import { NodeIdLookUp } from '../structs/NodeIdLookUp.mjs'; import { CustomOnionMessageHandler } from '../structs/CustomOnionMessageHandler.mjs'; import { ReadOnlyNetworkGraph } from '../structs/ReadOnlyNetworkGraph.mjs'; import { CommonBase } from './CommonBase.mjs'; export declare class UtilMethods extends CommonBase { /** * Gets the 128-bit integer, as 16 little-endian bytes */ static constructor_U128_le_bytes(val: bigint): Uint8Array; /** * Constructs a new U128 from 16 little-endian bytes */ static constructor_U128_new(le_bytes: Uint8Array): bigint; /** * Constructs a new COption_NoneZ containing a */ static constructor_COption_NoneZ_some(): COption_NoneZ; /** * Constructs a new COption_NoneZ containing nothing */ static constructor_COption_NoneZ_none(): COption_NoneZ; /** * Read a APIError from a byte array, created by APIError_write */ static constructor_APIError_read(ser: Uint8Array): Result_COption_APIErrorZDecodeErrorZ; /** * Creates a digital signature of a message given a SecretKey, like the node's secret. * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller. * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted. */ static constructor_sign(msg: Uint8Array, sk: Uint8Array): string; /** * Recovers the PublicKey of the signer of the message given the message and the signature. */ static constructor_recover_pk(msg: Uint8Array, sig: string): Result_PublicKeySecp256k1ErrorZ; /** * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature, * and the PublicKey. */ static constructor_verify(msg: Uint8Array, sig: string, pk: Uint8Array): boolean; /** * Migrates all data from one store to another. * * This operation assumes that `target_store` is empty, i.e., any data present under copied keys * might get overriden. User must ensure `source_store` is not modified during operation, * otherwise no consistency guarantees can be given. * * Will abort and return an error if any IO operation fails. Note that in this case the * `target_store` might get left in an intermediate state. */ static constructor_migrate_kv_store_data(source_store: MigratableKVStore, target_store: MigratableKVStore): Result_NoneIOErrorZ; /** * Read previously persisted [`ChannelMonitor`]s from the store. */ static constructor_read_channel_monitors(kv_store: KVStore, entropy_source: EntropySource, signer_provider: SignerProvider): Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ; /** * Extracts the block height (most significant 3-bytes) from the `short_channel_id` */ static constructor_block_from_scid(short_channel_id: bigint): number; /** * Extracts the tx index (bytes [2..4]) from the `short_channel_id` */ static constructor_tx_index_from_scid(short_channel_id: bigint): number; /** * Extracts the vout (bytes [0..2]) from the `short_channel_id` */ static constructor_vout_from_scid(short_channel_id: bigint): number; /** * Constructs a `short_channel_id` using the components pieces. Results in an error * if the block height, tx index, or vout index overflow the maximum sizes. */ static constructor_scid_from_parts(block: bigint, tx_index: bigint, vout_index: bigint): Result_u64ShortChannelIdErrorZ; /** * Read a C2Tuple_BestBlockOutputSweeperZ from a byte array, created by C2Tuple_BestBlockOutputSweeperZ_write */ static constructor_C2Tuple_BestBlockOutputSweeperZ_read(ser: Uint8Array, arg_a: BroadcasterInterface, arg_b: FeeEstimator, arg_c: Option_FilterZ, arg_d: OutputSpender, arg_e: ChangeDestinationSource, arg_f: KVStore, arg_g: Logger): Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ; /** * Read a MonitorEvent from a byte array, created by MonitorEvent_write */ static constructor_MonitorEvent_read(ser: Uint8Array): Result_COption_MonitorEventZDecodeErrorZ; /** * Read a C2Tuple_ThirtyTwoBytesChannelMonitorZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelMonitorZ_write */ static constructor_C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(ser: Uint8Array, arg_a: EntropySource, arg_b: SignerProvider): Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ; /** * Peel one layer off an incoming onion, returning a [`PendingHTLCInfo`] that contains information * about the intended next-hop for the HTLC. * * This does all the relevant context-free checks that LDK requires for payment relay or * acceptance. If the payment is to be received, and the amount matches the expected amount for * a given invoice, this indicates the [`msgs::UpdateAddHTLC`], once fully committed in the * channel, will generate an [`Event::PaymentClaimable`]. * * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable */ static constructor_peel_payment_onion(msg: UpdateAddHTLC, node_signer: NodeSigner, logger: Logger, cur_height: number, allow_skimmed_fees: boolean): Result_PendingHTLCInfoInboundHTLCErrZ; /** * Fetches the set of [`InitFeatures`] flags that are provided by or required by * [`ChannelManager`]. */ static constructor_provided_init_features(config: UserConfig): InitFeatures; /** * Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write */ static constructor_C2Tuple_ThirtyTwoBytesChannelManagerZ_read(ser: Uint8Array, arg_entropy_source: EntropySource, arg_node_signer: NodeSigner, arg_signer_provider: SignerProvider, arg_fee_estimator: FeeEstimator, arg_chain_monitor: Watch, arg_tx_broadcaster: BroadcasterInterface, arg_router: Router, arg_message_router: MessageRouter, arg_logger: Logger, arg_default_config: UserConfig, arg_channel_monitors: ChannelMonitor[]): Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ; /** * Adds a tweak to a public key to derive a new public key. * * May panic if `tweak` is not the output of a SHA-256 hash. */ static constructor_add_public_key_tweak(base_point: Uint8Array, tweak: Uint8Array): Uint8Array; /** * Read a InboundHTLCStateDetails from a byte array, created by InboundHTLCStateDetails_write */ static constructor_InboundHTLCStateDetails_read(ser: Uint8Array): Result_COption_InboundHTLCStateDetailsZDecodeErrorZ; /** * Read a OutboundHTLCStateDetails from a byte array, created by OutboundHTLCStateDetails_write */ static constructor_OutboundHTLCStateDetails_read(ser: Uint8Array): Result_COption_OutboundHTLCStateDetailsZDecodeErrorZ; /** * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without * a `ChannelManager`. * * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key`]. It is recommended to * cache this value and not regenerate it for each new inbound payment. * * `current_time` is a Unix timestamp representing the current time. * * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable * on versions of LDK prior to 0.0.114. * * [phantom node payments]: crate::sign::PhantomKeysManager * [`NodeSigner::get_inbound_payment_key`]: crate::sign::NodeSigner::get_inbound_payment_key */ static constructor_create(keys: ExpandedKey, min_value_msat: Option_u64Z, invoice_expiry_delta_secs: number, entropy_source: EntropySource, current_time: bigint, min_final_cltv_expiry_delta: Option_u16Z): Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ; /** * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`], * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments] * without a `ChannelManager`. * * See [`create`] for information on the `keys` and `current_time` parameters. * * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable * on versions of LDK prior to 0.0.114. * * [phantom node payments]: crate::sign::PhantomKeysManager */ static constructor_create_from_hash(keys: ExpandedKey, min_value_msat: Option_u64Z, payment_hash: Uint8Array, invoice_expiry_delta_secs: number, current_time: bigint, min_final_cltv_expiry_delta: Option_u16Z): Result_ThirtyTwoBytesNoneZ; /** * Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`]. * * The host part must end with \".onion\". */ static constructor_parse_onion_address(host: string, port: number): Result_SocketAddressSocketAddressParseErrorZ; /** * Gets the weight for an HTLC-Success transaction. */ static constructor_htlc_success_tx_weight(channel_type_features: ChannelTypeFeatures): bigint; /** * Gets the weight for an HTLC-Timeout transaction. */ static constructor_htlc_timeout_tx_weight(channel_type_features: ChannelTypeFeatures): bigint; /** * Check if a given input witness attempts to claim a HTLC. */ static constructor_HTLCClaim_from_witness(witness: Uint8Array): Option_HTLCClaimZ; /** * Build the commitment secret from the seed and the commitment number */ static constructor_build_commitment_secret(commitment_seed: Uint8Array, idx: bigint): Uint8Array; /** * Build a closing transaction */ static constructor_build_closing_transaction(to_holder_value_sat: bigint, to_counterparty_value_sat: bigint, to_holder_script: Uint8Array, to_counterparty_script: Uint8Array, funding_outpoint: OutPoint): Uint8Array; /** * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) * from the base secret and the per_commitment_point. */ static constructor_derive_private_key(per_commitment_point: Uint8Array, base_secret: Uint8Array): Uint8Array; /** * Derives a per-commitment-transaction revocation key from its constituent parts. * * Only the cheating participant owns a valid witness to propagate a revoked * commitment transaction, thus per_commitment_secret always come from cheater * and revocation_base_secret always come from punisher, which is the broadcaster * of the transaction spending with this key knowledge. */ static constructor_derive_private_revocation_key(per_commitment_secret: Uint8Array, countersignatory_revocation_base_secret: Uint8Array): Uint8Array; /** * A script either spendable by the revocation * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. */ static constructor_get_revokeable_redeemscript(revocation_key: RevocationKey, contest_delay: number, broadcaster_delayed_payment_key: DelayedPaymentKey): Uint8Array; /** * Returns the script for the counterparty's output on a holder's commitment transaction based on * the channel type. */ static constructor_get_counterparty_payment_script(channel_type_features: ChannelTypeFeatures, payment_key: Uint8Array): Uint8Array; /** * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc * does not need to have its previous_output_index filled. */ static constructor_get_htlc_redeemscript(htlc: HTLCOutputInCommitment, channel_type_features: ChannelTypeFeatures, keys: TxCreationKeys): Uint8Array; /** * Gets the redeemscript for a funding output from the two funding public keys. * Note that the order of funding public keys does not matter. */ static constructor_make_funding_redeemscript(broadcaster: Uint8Array, countersignatory: Uint8Array): Uint8Array; /** * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the * transaction which needs signing, and can be used to construct an HTLC transaction which is * broadcastable given a counterparty HTLC signature. * * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the * commitment transaction). */ static constructor_build_htlc_transaction(commitment_txid: Uint8Array, feerate_per_kw: number, contest_delay: number, htlc: HTLCOutputInCommitment, channel_type_features: ChannelTypeFeatures, broadcaster_delayed_payment_key: DelayedPaymentKey, revocation_key: RevocationKey): Uint8Array; /** * Returns the witness required to satisfy and spend a HTLC input. */ static constructor_build_htlc_input_witness(local_sig: Uint8Array, remote_sig: Uint8Array, preimage: Option_ThirtyTwoBytesZ, redeem_script: Uint8Array, channel_type_features: ChannelTypeFeatures): Uint8Array; /** * Gets the witnessScript for the to_remote output when anchors are enabled. */ static constructor_get_to_countersignatory_with_anchors_redeemscript(payment_point: Uint8Array): Uint8Array; /** * Gets the witnessScript for an anchor output from the funding public key. * The witness in the spending input must be: * <BIP 143 funding_signature> * After 16 blocks of confirmation, an alternative satisfying witness could be: * <> * (empty vector required to satisfy compliance with MINIMALIF-standard rule) */ static constructor_get_anchor_redeemscript(funding_pubkey: Uint8Array): Uint8Array; /** * Returns the witness required to satisfy and spend an anchor input. */ static constructor_build_anchor_input_witness(funding_key: Uint8Array, funding_sig: Uint8Array): Uint8Array; /** * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a * shared secret first. This prevents on-chain observers from discovering how many commitment * transactions occurred in a channel before it was closed. * * This function gets the shared secret from relevant channel public keys and can be used to * \"decrypt\" the commitment transaction number given a commitment transaction on-chain. */ static constructor_get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint: Uint8Array, countersignatory_payment_basepoint: Uint8Array, outbound_from_broadcaster: boolean): bigint; /** * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" * See [`PhantomKeysManager`] for more information on phantom node payments. * * `phantom_route_hints` parameter: * Contains channel info for all nodes participating in the phantom invoice * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each * participating node * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is * updated when a channel becomes disabled or closes * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared * down * * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). * If `None` is provided for `payment_hash`, then one will be created. * * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for * in excess of the current time. * * `duration_since_epoch` is the current time since epoch in seconds. * * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block * confirmations during routing. * * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this * requirement). * * [`PhantomKeysManager`]: crate::sign::PhantomKeysManager * [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash * [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ static constructor_create_phantom_invoice(amt_msat: Option_u64Z, payment_hash: Option_ThirtyTwoBytesZ, description: string, invoice_expiry_delta_secs: number, phantom_route_hints: PhantomRouteHints[], entropy_source: EntropySource, node_signer: NodeSigner, logger: Logger, network: Currency, min_final_cltv_expiry_delta: Option_u16Z, duration_since_epoch: bigint): Result_Bolt11InvoiceSignOrCreationErrorZ; /** * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" * See [`PhantomKeysManager`] for more information on phantom node payments. * * `phantom_route_hints` parameter: * Contains channel info for all nodes participating in the phantom invoice * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each * participating node * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is * updated when a channel becomes disabled or closes * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as * desired, but note that some nodes will be trimmed if more than 3 nodes are provided. * * `description_hash` is a SHA-256 hash of the description text * * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). * If `None` is provided for `payment_hash`, then one will be created. * * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for * in excess of the current time. * * `duration_since_epoch` is the current time since epoch in seconds. * * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this * requirement). * * [`PhantomKeysManager`]: crate::sign::PhantomKeysManager * [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash * [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels */ static constructor_create_phantom_invoice_with_description_hash(amt_msat: Option_u64Z, payment_hash: Option_ThirtyTwoBytesZ, invoice_expiry_delta_secs: number, description_hash: Sha256, phantom_route_hints: PhantomRouteHints[], entropy_source: EntropySource, node_signer: NodeSigner, logger: Logger, network: Currency, min_final_cltv_expiry_delta: Option_u16Z, duration_since_epoch: bigint): Result_Bolt11InvoiceSignOrCreationErrorZ; /** * Utility to construct an invoice. Generally, unless you want to do something like a custom * cltv_expiry, this is what you should be using to create an invoice. The reason being, this * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify * that the payment secret is valid when the invoice is paid. * * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for * in excess of the current time. * * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block * confirmations during routing. * * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ static constructor_create_invoice_from_channelmanager(channelmanager: ChannelManager, amt_msat: Option_u64Z, description: string, invoice_expiry_delta_secs: number, min_final_cltv_expiry_delta: Option_u16Z): Result_Bolt11InvoiceSignOrCreationErrorZ; /** * Utility to construct an invoice. Generally, unless you want to do something like a custom * cltv_expiry, this is what you should be using to create an invoice. The reason being, this * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify * that the payment secret is valid when the invoice is paid. * Use this variant if you want to pass the `description_hash` to the invoice. * * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for * in excess of the current time. * * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block * confirmations during routing. * * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ static constructor_create_invoice_from_channelmanager_with_description_hash(channelmanager: ChannelManager, amt_msat: Option_u64Z, description_hash: Sha256, invoice_expiry_delta_secs: number, min_final_cltv_expiry_delta: Option_u16Z): Result_Bolt11InvoiceSignOrCreationErrorZ; /** * See [`create_invoice_from_channelmanager`]. * * This version allows for providing custom [`PaymentHash`] and description hash for the invoice. * * This may be useful if you're building an on-chain swap or involving another protocol where * the payment hash is also involved outside the scope of lightning and want to set the * description hash. */ static constructor_create_invoice_from_channelmanager_with_description_hash_and_payment_hash(channelmanager: ChannelManager, amt_msat: Option_u64Z, description_hash: Sha256, invoice_expiry_delta_secs: number, payment_hash: Uint8Array, min_final_cltv_expiry_delta: Option_u16Z): Result_Bolt11InvoiceSignOrCreationErrorZ; /** * See [`create_invoice_from_channelmanager`]. * * This version allows for providing a custom [`PaymentHash`] for the invoice. * This may be useful if you're building an on-chain swap or involving another protocol where * the payment hash is also involved outside the scope of lightning. */ static constructor_create_invoice_from_channelmanager_with_payment_hash(channelmanager: ChannelManager, amt_msat: Option_u64Z, description: string, invoice_expiry_delta_secs: number, payment_hash: Uint8Array, min_final_cltv_expiry_delta: Option_u16Z): Result_Bolt11InvoiceSignOrCreationErrorZ; /** * Builds the necessary parameters to pay or pre-flight probe the given variable-amount * (also known as 'zero-amount') [`Bolt11Invoice`] using * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. * * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the * same [`PaymentHash`] has never been paid before. * * Will always succeed unless the invoice has an amount specified, in which case * [`payment_parameters_from_invoice`] should be used. * * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment * [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes */ static constructor_payment_parameters_from_variable_amount_invoice(invoice: Bolt11Invoice, amount_msat: bigint): Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ; /** * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. * * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the * same [`PaymentHash`] has never been paid before. * * Will always succeed unless the invoice has no amount specified, in which case * [`payment_parameters_from_variable_amount_invoice`] should be used. * * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment * [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes */ static constructor_payment_parameters_from_invoice(invoice: Bolt11Invoice): Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ; /** * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write */ static constructor_NetworkUpdate_read(ser: Uint8Array): Result_COption_NetworkUpdateZDecodeErrorZ; /** * Verifies the signature of a [`NodeAnnouncement`]. * * Returns an error if it is invalid. */ static constructor_verify_node_announcement(msg: NodeAnnouncement): Result_NoneLightningErrorZ; /** * Verifies all signatures included in a [`ChannelAnnouncement`]. * * Returns an error if one of the signatures is invalid. */ static constructor_verify_channel_announcement(msg: ChannelAnnouncement): Result_NoneLightningErrorZ; /** * Finds a route from us (payer) to the given target node (payee). * * If the payee provided features in their invoice, they should be provided via the `payee` field * in the given [`RouteParameters::payment_params`]. * Without this, MPP will only be used if the payee's features are available in the network graph. * * Private routing paths between a public node and the target may be included in the `payee` field * of [`RouteParameters::payment_params`]. * * If some channels aren't announced, it may be useful to fill in `first_hops` with the results * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels * from `network_graph` will be ignored, and only those in `first_hops` will be used. * * The fees on channels from us to the next hop are ignored as they are assumed to all be equal. * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` / * `htlc_maximum_msat` *are* checked as they may change based on the receiving node. * * # Panics * * Panics if first_hops contains channels without `short_channel_id`s; * [`ChannelManager::list_usable_channels`] will never include such channels. * * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph * * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ static constructor_find_route(our_node_pubkey: Uint8Array, route_params: RouteParameters, network_graph: NetworkGraph, first_hops: ChannelDetails[] | null, logger: Logger, scorer: ScoreLookUp, score_params: ProbabilisticScoringFeeParameters, random_seed_bytes: Uint8Array): Result_RouteLightningErrorZ; /** * Construct a route from us (payer) to the target node (payee) via the given hops (which should * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path. * * Re-uses logic from `find_route`, so the restrictions described there also apply here. */ static constructor_build_route_from_hops(our_node_pubkey: Uint8Array, hops: Uint8Array[], route_params: RouteParameters, network_graph: NetworkGraph, logger: Logger, random_seed_bytes: Uint8Array): Result_RouteLightningErrorZ; /** * Creates an unsigned [`Psbt`] which spends the given descriptors to * the given outputs, plus an output to the given change destination (if sufficient * change value remains). The PSBT will have a feerate, at least, of the given value. * * The `locktime` argument is used to set the transaction's locktime. If `None`, the * transaction will have a locktime of 0. It it recommended to set this to the current block * height to avoid fee sniping, unless you have some specific reason to use a different * locktime. * * Returns the PSBT and expected max transaction weight. * * Returns `Err(())` if the output value is greater than the input value minus required fee, * if a descriptor was duplicated, or if an output descriptor `script_pubkey` * does not match the one we can spend. * * We do not enforce that outputs meet the dust limit or that any output scripts are standard. */ static constructor_SpendableOutputDescriptor_create_spendable_outputs_psbt(descriptors: SpendableOutputDescriptor[], outputs: TxOut[], change_destination_script: Uint8Array, feerate_sat_per_1000_weight: number, locktime: Option_u32Z): Result_C2Tuple_CVec_u8Zu64ZNoneZ; /** * Returns whether `tlv_type` corresponds to a TLV record for async payment messages. */ static constructor_AsyncPaymentsMessage_is_known_type(tlv_type: bigint): boolean; /** * Returns whether `tlv_type` corresponds to a TLV record for DNS Resolvers. */ static constructor_DNSResolverMessage_is_known_type(tlv_type: bigint): boolean; /** * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of * `path`, first calling [`Destination::resolve`] on `path.destination` with the given * [`ReadOnlyNetworkGraph`]. * * Returns the node id of the peer to send the message to, the message itself, and any addresses * needed to connect to the first node. * * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None */ static constructor_create_onion_message_resolving_destination(entropy_source: EntropySource, node_signer: NodeSigner, node_id_lookup: NodeIdLookUp, network_graph: ReadOnlyNetworkGraph, path: OnionMessagePath, contents: OnionMessageContents, reply_path: BlindedMessagePath | null): Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ; /** * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of * `path`. * * Returns the node id of the peer to send the message to, the message itself, and any addresses * needed to connect to the first node. * * Returns [`SendError::UnresolvedIntroductionNode`] if: * - `destination` contains a blinded path with an [`IntroductionNode::DirectedShortChannelId`], * - unless it can be resolved by [`NodeIdLookUp::next_node_id`]. * Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node * first with a [`ReadOnlyNetworkGraph`]. * * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None */ static constructor_create_onion_message(entropy_source: EntropySource, node_signer: NodeSigner, node_id_lookup: NodeIdLookUp, path: OnionMessagePath, contents: OnionMessageContents, reply_path: BlindedMessagePath | null): Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ; /** * Decode one layer of an incoming [`OnionMessage`]. * * Returns either the next layer of the onion for forwarding or the decrypted content for the * receiver. */ static constructor_peel_onion_message(msg: OnionMessage, node_signer: NodeSigner, logger: Logger, custom_handler: CustomOnionMessageHandler): Result_PeeledOnionNoneZ; /** * Returns whether `tlv_type` corresponds to a TLV record for Offers. */ static constructor_OffersMessage_is_known_type(tlv_type: bigint): boolean; /** * Read a PathFailure from a byte array, created by PathFailure_write */ static constructor_PathFailure_read(ser: Uint8Array): Result_COption_PathFailureZDecodeErrorZ; /** * Read a ClosureReason from a byte array, created by ClosureReason_write */ static constructor_ClosureReason_read(ser: Uint8Array): Result_COption_ClosureReasonZDecodeErrorZ; /** * Read a HTLCDestination from a byte array, created by HTLCDestination_write */ static constructor_HTLCDestination_read(ser: Uint8Array): Result_COption_HTLCDestinationZDecodeErrorZ; /** * Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write */ static constructor_PaymentFailureReason_read(ser: Uint8Array): Result_COption_PaymentFailureReasonZDecodeErrorZ; /** * Read a Event from a byte array, created by Event_write */ static constructor_Event_read(ser: Uint8Array): Result_COption_EventZDecodeErrorZ; /** * Determines if the given parameters are valid given the secret used to generate the promise. */ static constructor_is_valid_opening_fee_params(fee_params: LSPS2OpeningFeeParams, promise_secret: Uint8Array): boolean; /** * Determines if the given parameters are expired, or still valid. */ static constructor_is_expired_opening_fee_params(fee_params: LSPS2OpeningFeeParams): boolean; /** * Computes the opening fee given a payment size and the fee parameters. * * Returns [`Option::None`] when the computation overflows. * * See the [`specification`](https://github.com/lightning/blips/blob/master/blip-0052.md#computing-the-opening_fee) for more details. */ static constructor_compute_opening_fee(payment_size_msat: bigint, opening_fee_min_fee_msat: bigint, opening_fee_proportional: bigint): Option_u64Z; }