lightningdevkit
Version:
Lightning Development Kit
181 lines (180 loc) • 10.3 kB
text/typescript
import { Result_PublicKeyNoneZ } from '../structs/Result_PublicKeyNoneZ.mjs';
import { Result__u832NoneZ } from '../structs/Result__u832NoneZ.mjs';
import { Result_NoneNoneZ } from '../structs/Result_NoneNoneZ.mjs';
import { HolderCommitmentTransaction } from '../structs/HolderCommitmentTransaction.mjs';
import { ChannelPublicKeys } from '../structs/ChannelPublicKeys.mjs';
import { ChannelTransactionParameters } from '../structs/ChannelTransactionParameters.mjs';
import { CommonBase } from './CommonBase.mjs';
/** An implementation of ChannelSigner */
export interface ChannelSignerInterface {
/**Gets the per-commitment point for a specific commitment number
*
* Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
*
* This method is *not* asynchronous. This method is expected to always return `Ok`
* immediately after we reconnect to peers, and returning an `Err` may lead to an immediate
* `panic`. This method will be made asynchronous in a future release.
*/
get_per_commitment_point(idx: bigint): Result_PublicKeyNoneZ;
/**Gets the commitment secret for a specific commitment number as part of the revocation process
*
* An external signer implementation should error here if the commitment was already signed
* and should refuse to sign it in the future.
*
* May be called more than once for the same index.
*
* Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
*
* An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
* signature and should be retried later. Once the signer is ready to provide a signature after
* previously returning an `Err`, [`ChannelManager::signer_unblocked`] must be called.
*
* [`ChannelManager::signer_unblocked`]: crate::ln::channelmanager::ChannelManager::signer_unblocked
*/
release_commitment_secret(idx: bigint): Result__u832NoneZ;
/**Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
*
* This is required in order for the signer to make sure that releasing a commitment
* secret won't leave us without a broadcastable holder transaction.
* Policy checks should be implemented in this function, including checking the amount
* sent to us and checking the HTLCs.
*
* The preimages of outbound HTLCs that were fulfilled since the last commitment are provided.
* A validating signer should ensure that an HTLC output is removed only when the matching
* preimage is provided, or when the value to holder is restored.
*
* Note that all the relevant preimages will be provided, but there may also be additional
* irrelevant or duplicate preimages.
*
* This method is *not* asynchronous. If an `Err` is returned, the channel will be immediately
* closed. If you wish to make this operation asynchronous, you should instead return `Ok(())`
* and pause future signing operations until this validation completes.
*/
validate_holder_commitment(holder_tx: HolderCommitmentTransaction, outbound_htlc_preimages: Uint8Array[]): Result_NoneNoneZ;
/**Validate the counterparty's revocation.
*
* This is required in order for the signer to make sure that the state has moved
* forward and it is safe to sign the next counterparty commitment.
*
* This method is *not* asynchronous. If an `Err` is returned, the channel will be immediately
* closed. If you wish to make this operation asynchronous, you should instead return `Ok(())`
* and pause future signing operations until this validation completes.
*/
validate_counterparty_revocation(idx: bigint, secret: Uint8Array): Result_NoneNoneZ;
/**Returns an arbitrary identifier describing the set of keys which are provided back to you in
* some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
* [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys.
*
* This method is *not* asynchronous. Instead, the value must be cached locally.
*/
channel_keys_id(): Uint8Array;
/**Set the counterparty static channel data, including basepoints,
* `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint.
*
* This data is static, and will never change for a channel once set. For a given [`ChannelSigner`]
* instance, LDK will call this method exactly once - either immediately after construction
* (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding
* information has been generated.
*
* channel_parameters.is_populated() MUST be true.
*/
provide_channel_parameters(channel_parameters: ChannelTransactionParameters): void;
}
/**
* A trait to handle Lightning channel key material without concretizing the channel type or
* the signature mechanism.
*
* Several methods allow errors to be returned to support async signing. In such cases, the
* signing operation can be replayed by calling [`ChannelManager::signer_unblocked`] once the
* result is ready, at which point the channel operation will resume. Methods which allow for
* async results are explicitly documented as such
*
* [`ChannelManager::signer_unblocked`]: crate::ln::channelmanager::ChannelManager::signer_unblocked
*/
export declare class ChannelSigner extends CommonBase {
/** Creates a new instance of ChannelSigner from a given implementation */
static new_impl(arg: ChannelSignerInterface, pubkeys: ChannelPublicKeys): ChannelSigner;
/**
* Gets the per-commitment point for a specific commitment number
*
* Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
*
* This method is *not* asynchronous. This method is expected to always return `Ok`
* immediately after we reconnect to peers, and returning an `Err` may lead to an immediate
* `panic`. This method will be made asynchronous in a future release.
*/
get_per_commitment_point(idx: bigint): Result_PublicKeyNoneZ;
/**
* Gets the commitment secret for a specific commitment number as part of the revocation process
*
* An external signer implementation should error here if the commitment was already signed
* and should refuse to sign it in the future.
*
* May be called more than once for the same index.
*
* Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
*
* An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
* signature and should be retried later. Once the signer is ready to provide a signature after
* previously returning an `Err`, [`ChannelManager::signer_unblocked`] must be called.
*
* [`ChannelManager::signer_unblocked`]: crate::ln::channelmanager::ChannelManager::signer_unblocked
*/
release_commitment_secret(idx: bigint): Result__u832NoneZ;
/**
* Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
*
* This is required in order for the signer to make sure that releasing a commitment
* secret won't leave us without a broadcastable holder transaction.
* Policy checks should be implemented in this function, including checking the amount
* sent to us and checking the HTLCs.
*
* The preimages of outbound HTLCs that were fulfilled since the last commitment are provided.
* A validating signer should ensure that an HTLC output is removed only when the matching
* preimage is provided, or when the value to holder is restored.
*
* Note that all the relevant preimages will be provided, but there may also be additional
* irrelevant or duplicate preimages.
*
* This method is *not* asynchronous. If an `Err` is returned, the channel will be immediately
* closed. If you wish to make this operation asynchronous, you should instead return `Ok(())`
* and pause future signing operations until this validation completes.
*/
validate_holder_commitment(holder_tx: HolderCommitmentTransaction, outbound_htlc_preimages: Uint8Array[]): Result_NoneNoneZ;
/**
* Validate the counterparty's revocation.
*
* This is required in order for the signer to make sure that the state has moved
* forward and it is safe to sign the next counterparty commitment.
*
* This method is *not* asynchronous. If an `Err` is returned, the channel will be immediately
* closed. If you wish to make this operation asynchronous, you should instead return `Ok(())`
* and pause future signing operations until this validation completes.
*/
validate_counterparty_revocation(idx: bigint, secret: Uint8Array): Result_NoneNoneZ;
/**
* Returns an arbitrary identifier describing the set of keys which are provided back to you in
* some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
* [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys.
*
* This method is *not* asynchronous. Instead, the value must be cached locally.
*/
channel_keys_id(): Uint8Array;
/**
* Set the counterparty static channel data, including basepoints,
* `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint.
*
* This data is static, and will never change for a channel once set. For a given [`ChannelSigner`]
* instance, LDK will call this method exactly once - either immediately after construction
* (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding
* information has been generated.
*
* channel_parameters.is_populated() MUST be true.
*/
provide_channel_parameters(channel_parameters: ChannelTransactionParameters): void;
/**
* Frees any resources associated with this object given its this_arg pointer.
* Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
*/
get_pubkeys(): ChannelPublicKeys;
}