UNPKG

@btc-vision/transaction

Version:

OPNet transaction library allows you to create and sign transactions for the OPNet network.

83 lines (82 loc) 4.3 kB
import { Logger } from '@btc-vision/logger'; import { Network, P2TRPayment, Psbt, PsbtInput, PsbtInputExtended, Signer, Transaction } from '@btc-vision/bitcoin'; import { ECPairInterface } from 'ecpair'; import { UTXO } from '../../utxo/interfaces/IUTXO.js'; import { TapLeafScript } from '../interfaces/Tap.js'; import { ChainId } from '../../network/ChainId.js'; import { UnisatSigner } from '../browser/extensions/UnisatSigner.js'; export interface ITweakedTransactionData { readonly signer: Signer | ECPairInterface | UnisatSigner; readonly network: Network; readonly chainId?: ChainId; readonly nonWitnessUtxo?: Buffer; readonly noSignatures?: boolean; readonly unlockScript?: Buffer[]; } export declare enum TransactionSequence { REPLACE_BY_FEE = 4294967293, FINAL = 4294967295 } export declare abstract class TweakedTransaction extends Logger { readonly logColor: string; finalized: boolean; protected signer: Signer | ECPairInterface | UnisatSigner; protected tweakedSigner?: ECPairInterface; protected network: Network; protected signed: boolean; protected abstract readonly transaction: Psbt; protected sighashTypes: number[] | undefined; protected scriptData: P2TRPayment | null; protected tapData: P2TRPayment | null; protected readonly inputs: PsbtInputExtended[]; protected sequence: number; protected tapLeafScript: TapLeafScript | null; protected nonWitnessUtxo?: Buffer; protected readonly isBrowser: boolean; protected regenerated: boolean; protected ignoreSignatureErrors: boolean; protected noSignatures: boolean; protected unlockScript: Buffer[] | undefined; protected constructor(data: ITweakedTransactionData); static readScriptWitnessToWitnessStack(Buffer: Buffer): Buffer[]; static preEstimateTaprootTransactionFees(feeRate: bigint, numInputs: bigint, numOutputs: bigint, numWitnessElements: bigint, witnessElementSize: bigint, emptyWitness: bigint, taprootControlWitnessSize?: bigint, taprootScriptSize?: bigint): bigint; protected static signInput(transaction: Psbt, input: PsbtInput, i: number, signer: Signer | ECPairInterface, sighashTypes: number[]): void; protected static calculateSignHash(sighashTypes: number[]): number; ignoreSignatureError(): void; getScriptAddress(): string; getTransaction(): Transaction; getTapAddress(): string; disableRBF(): void; getTweakerHash(): Buffer | undefined; preEstimateTransactionFees(feeRate: bigint, numInputs: bigint, numOutputs: bigint, numSignatures: bigint, numPubkeys: bigint): bigint; protected generateTapData(): P2TRPayment; protected generateScriptAddress(): P2TRPayment; protected getSignerKey(): Signer | ECPairInterface; protected signInput(transaction: Psbt, input: PsbtInput, i: number, signer: Signer | ECPairInterface, reverse?: boolean, errored?: boolean): Promise<void>; protected splitArray<T>(arr: T[], chunkSize: number): T[][]; protected signInputs(transaction: Psbt): Promise<void>; protected signInputsNonWalletBased(transaction: Psbt): Promise<void>; protected internalPubKeyToXOnly(): Buffer; protected internalInit(): void; protected tweakSigner(): void; protected getTweakedSigner(useTweakedHash?: boolean, signer?: Signer | ECPairInterface): ECPairInterface | undefined; protected generateP2SHRedeemScript(customWitnessScript: Buffer): Buffer | undefined; protected generateP2SHRedeemScriptLegacy(inputAddr: string): { redeemScript: Buffer; outputScript: Buffer; } | undefined; protected generateP2SHP2PKHRedeemScript(inputAddr: string): { redeemScript: Buffer; outputScript: Buffer; } | undefined; protected generatePsbtInputExtended(utxo: UTXO, i: number, _extra?: boolean): PsbtInputExtended; protected customFinalizerP2SH: (inputIndex: number, input: PsbtInput, scriptA: Buffer, isSegwit: boolean, isP2SH: boolean, isP2WSH: boolean) => { finalScriptSig: Buffer | undefined; finalScriptWitness: Buffer | undefined; }; protected signInputsWalletBased(transaction: Psbt): Promise<void>; private attemptSignTaproot; private isTaprootScriptSpend; private signTaprootInput; private signNonTaprootInput; }