UNPKG

@node-dlc/core

Version:
77 lines (76 loc) 3.33 kB
/// <reference types="node" /> import { Script } from '@node-dlc/bitcoin'; export declare class ScriptFactory { /** * Constructs the P2MS commit script used in in the funding transaction * as defined in BOLT3. The pubkeys must be sorted in lexicographical * order. * * @param openPubKey funding_pubkey sent in open_channel * @param acceptPubKey funding_pubkey sent in accept_channel */ static fundingScript(openPubKey: Buffer, acceptPubKey: Buffer): Script; /** * Constructs an revocable sequence maturing contract using the * provided keys and delay. This script is used in the `to_local` * output of the commmitment transaction as well as the secondary * HTLC-Success and HTLC-Timeout transactions. * * @param revocationPubKey the revocation pubkey that has the ability * to perform a penalty transaction should a revoked version of this * output be spend. * @param delayedPubKey the delayed pubkey spendable after the * sequence delay * @param toSelfDelay the sequence delay in blocks */ static toLocalScript(revocationPubKey: Buffer, delayedPubKey: Buffer, toSelfDelay: number): Script; /** * Constructs the script for an offered HTLC output of a commitment * transaction as defined in BOLT3. This enables on-chain resolution * of an HTLC to the local node via the secondary HTLC-Timeout * transaction. This secondary transaction is both sequence delayed * and timelocked and requires signatures by both parties to prevent * premature spending. The remote node can immediately resolve the * transaction wit knowledge of the preimage. * * Revocable with witness: * [revocationSig, revocationPubKey] * * Pay to local via the HTLC-Timeout transaction by using witness * [0, remoteHtlcSig, localHtlcSig, <>] * * Pay to remote counterparty without delay using witness * [remoteHtlcSig, preimage] * * @param paymentHash * @param revocationPubKey * @param localHtlcPubKey * @param remoteHtlcPubKey */ static offeredHtlcScript(paymentHash: Buffer, revocationPubKey: Buffer, localHtlcPubKey: Buffer, remoteHtlcPubKey: Buffer): Script; /** * Constructs the script for a received HTLC output of a commitment * transaction as defined in BOLT3. This enables on-chain resolution * of an HTLC to the local node via the secondary HTLC-Success * transaction. This secondary transaction is sequence delayed and * thus local spends require both parties signatures. The remote * node can perform a timeout of this output after the timelock * expires. * * Revocable with witness: * [revocationSig, revocationPubKey] * * Pay to local via the HTLC-Success transaction by using witness * [0, remoteHtlcSig, localHtlcSig, preimage] * * Pay to remote counterparty after the CLTV expiry using witness * [remoteHtlcSig, <>] * * @param paymentHash * @param cltvExpiry * @param revocationPubKey * @param localHtlcPubKey * @param remoteHtlcPubKey */ static receivedHtlcScript(paymentHash: Buffer, cltvExpiry: number, revocationPubKey: Buffer, localHtlcPubKey: Buffer, remoteHtlcPubKey: Buffer): Script; }