import { ProtocolState } from './state'; import { ByteString, FixedArray, Sig, UTXO } from 'scrypt-ts'; import { Covenant } from './covenant'; import { MAX_STATE } from '../contracts/utils/txUtil'; import { PSBTOptions, ToSignInput } from './signer'; import { Psbt, Network, Transaction } from 'bitcoinjs-lib'; import { btc } from './btc'; import { PsbtInput } from 'bip174'; import { ChangeInfo } from '../contracts/utils/txUtil'; import { PreTxStatesInfo } from '../contracts/utils/stateUtils'; import { InputContext } from '../contracts/utils/sigHashUtils'; import { TapLeafSmartContract } from './tapLeafSmartContract'; export interface PsbtOptsOptional { network?: Network; maximumFeeRate?: number; } export interface TransactionInput { hash: string | Uint8Array; index: number; sequence?: number; } type Witness = Buffer[]; type Finalizer = (self: CatPsbt, inputIndex: number, // Which input is it? input: PsbtInput, // The PSBT input contents tapLeafHashToFinalize?: Uint8Array) => Witness; type AsyncFinalizer = (self: CatPsbt, inputIndex: number, // Which input is it? input: PsbtInput, // The PSBT input contents tapLeafHashToFinalize?: Uint8Array) => Promise; export type UnlockArgsBuilder = (curPsbt: CatPsbt, tapLeafContract: TapLeafSmartContract) => any[]; interface PsbtInputExtended extends PsbtInput, TransactionInput { finalizer?: Finalizer; sigRequests?: { inputIndex: InputIndex; options: Omit; }[]; } type TxStatesInfo = PreTxStatesInfo; export declare const DUST_LIMIT = 330; export type InputIndex = number; export type SubContractCall = { contractAlias?: string; method: string; argsBuilder: UnlockArgsBuilder; }; export declare class CatPsbt extends Psbt { private _txState; private sigRequests; private finalizers; private changeOutputIndex?; constructor(txStates?: ProtocolState, opts?: PsbtOptsOptional); updateState(): void; get txState(): ProtocolState; static create(): CatPsbt; toTxHex(): string; get unsignedTx(): Transaction; addInput(inputData: PsbtInputExtended): this; addCovenantInput(covenant: Covenant, subContractAlias?: string): this; updateCovenantInput(inputIndex: number, covenant: Covenant, subContractCall: SubContractCall): this; get inputAmount(): number; get outputAmount(): number; change(address: string, feeRate: number, estimatedVsize?: number): this; addFeeInputs(feeUtxos: UTXO[]): this; addCovenantOutput(covenant: Covenant, satoshis?: number): this; getOutputScriptList(): FixedArray; getOutputSatoshisList(): FixedArray; getTxStatesInfo(): TxStatesInfo; psbtOptions(autoFinalized?: boolean): PSBTOptions | undefined; setInputFinalizer(inputIndex: InputIndex, finalizer: AsyncFinalizer): this; finalizeAllInputs(): this; calculateInputSHPreimages(tx: btc.Transaction, inputTapLeafHashes: { inputIndex: number; tapLeafHash: Buffer; }[]): { SHPreimageObj: import("../contracts/utils/sigHashUtils").SHPreimage; sighash: { preimage: Buffer; hash: Buffer; }; }[]; calculateInputCtxs(): Map; finalizeAllInputsAsync(): Promise; getSig(inputIndex: InputIndex, options: Omit): Sig; getChangeInfo(): ChangeInfo; getChangeUTXO(): UTXO | null; getUtxo(outputIndex: number): UTXO; estimateVSize(): number; estimateFee(feeRate: number): number; get isFinalized(): boolean; private _cacheInputWitness; private _unfinalizedWitnessVsize; private _checkInputCnt; private _checkOutputCnt; private _addSigRequest; } export {}; //# sourceMappingURL=catPsbt.d.ts.map