UNPKG

@node-dlc/core

Version:
84 lines (83 loc) 4.61 kB
/// <reference types="node" /> import { HashValue, OutPoint, TxBuilder, TxOut, Value } from '@node-dlc/bitcoin'; import { Htlc } from './Htlc'; export declare class TxFactory { /** * Creates a TxOut to attach to a funding transaction. This includes * the P2WSH-P2MS script that uses 2-2MS. The open and accept funding * pubkeys are sorted lexicographcially to create the script. * @param builder */ static createFundingOutput(value: Value, openPubKey: Buffer, acceptPubKey: Buffer): TxOut; /** * Constructs an unsigned commitment transaction according to BOLT3. * This method is a low level commitment transaction builder, meaning * it accepts primatives and constructs a commitment transaction * accordingly. The proper inputs are determiend * * @param isFunderLocal True when the funding node is local. This * is used to determine which output pays fees (to_local/to_remote). * @param commitmentNumber The commitment number of the transaction * which is used to generate the obscurred commitment number. * @param openPaymentBasePoint The basepoint sent in open_channel * which is used to generate the obscurred commitment number. * @param acceptPaymentBasePoint The basepoitn sent in accept_channel * which is used to generate the obscurred commitment number. * @param fundingOutPoint The outpoint of the funding transaction * which was established in funding_created. * @param dustLimitSatoshi The dust limit in sats after which outputs * will be prune * @param feePerKw The fee rate per kiloweight which will be deducted * from the funding node's output * @param localDelay The delay applied to the to_local output * @param localValue Value paid to the to_local RSMC output * @param remoteValue Value paid to the to_emote P2WPKH output * @param revocationPubKey The revocation public key used to in the * to_local and HTLC outputs * @param delayedPubKey The delayed public key used to spend the * to_local output * @param remotePubKey The public key used to spend the to_remote * output * @param reverseHtlcs True when the HTLC direction needs to be * inverted because the holder of this commitment transaction is * our counterparty. * @param localHtlcPubKey The public key used to spend HTLC outputs * by the commitment holder. * @param remoteHtlcPubKey The public key used to spend HTLC outputs * by the commitment counterparty. * @param htlcs A full list of HTLCs that will be selectively * included in the commitment transaction based on the feePerKw. */ static createCommitment(isFunderLocal: boolean, commitmentNumber: number, openPaymentBasePoint: Buffer, acceptPaymentBasePoint: Buffer, fundingOutPoint: OutPoint, dustLimitSatoshi: Value, feePerKw: bigint, localDelay: number, localValue: Value, remoteValue: Value, revocationPubKey: Buffer, delayedPubKey: Buffer, remotePubKey: Buffer, reverseHtlcs: boolean, localHtlcPubKey?: Buffer, remoteHtlcPubKey?: Buffer, htlcs?: Htlc[]): [TxBuilder, Htlc[]]; /** * Constructs an HTLC-Timeout transaction as defined in BOLT3. This * transaction spends an offered HTLC from the commitment transaction * and outputs the HTLC value less the fee. The output is spendable * via an RSMC that is sequence locked for the received by the * transaction owner. Finally this transaction has an absolute * locktime of the HTLC's cltv expiry. * @param commitmentTx * @param outputIndex * @param localDelay * @param revocationPubKey * @param delayedPubKey * @param feePerKw * @param htlc */ static createHtlcTimeout(commitmentTx: HashValue, outputIndex: number, localDelay: number, revocationPubKey: Buffer, delayedPubKey: Buffer, feePerKw: bigint, htlc: Htlc): TxBuilder; /** * Constructs an HTLC-Success transaction as defined in BOLT3. This * transaction spends a received HTLC form the commitment transaction * and outputs the HTLC value less the fee. The output is spendable * via an RSMC that is sequence locked for the received by the * transaction owner. * @param commitmentTx * @param outputIndex * @param localDelay * @param revocationPubKey * @param delayedPubKey * @param feePerKw * @param htlc */ static createHtlcSuccess(commitmentTx: HashValue, outputIndex: number, localDelay: number, revocationPubKey: Buffer, delayedPubKey: Buffer, feePerKw: bigint, htlc: Htlc): TxBuilder; }