@btc-stamps/tx-builder
Version:
Transaction builder for Bitcoin Stamps and SRC-20 tokens with advanced UTXO selection
923 lines (905 loc) • 27.5 kB
text/typescript
import { Buffer } from 'node:buffer';
import * as bitcoin from 'bitcoinjs-lib';
import { Network, Psbt, Transaction } from 'bitcoinjs-lib';
import { I as IFeeEstimator, b as FeeEstimatorOptions, a as FeeRate, c as FeeEstimate, d as InputType, O as OutputType, S as SizeCalculation, D as DustThresholds, N as NormalizedFeeRate } from './fee-normalizer-BGRDTCVR.cjs';
import { U as UTXO } from './provider.interface-53Rg30ZJ.cjs';
import { ECPairInterface } from 'ecpair';
import { S as SRC20Options, a as SRC20BuilderOptions } from './src20.interface-4GEU42wj.cjs';
/**
* Transaction Builder Interface
* Core interface for building Bitcoin transactions
*/
interface TransactionInput {
utxo: UTXO;
sequence?: number;
witnessUtxo?: {
script: Buffer;
value: number;
};
nonWitnessUtxo?: Buffer;
}
interface TransactionOutput {
address?: string;
script?: Buffer;
value: number;
}
interface BuildOptions {
inputs?: TransactionInput[];
outputs: TransactionOutput[];
changeAddress?: string;
feeRate?: number;
rbf?: boolean;
locktime?: number;
version?: number;
network?: Network;
}
interface SignOptions {
keyPair?: ECPairInterface;
keyPairs?: ECPairInterface[];
signAll?: boolean;
sighashType?: number;
}
interface ITransactionBuilder {
/**
* Create a new transaction
*/
create(options: BuildOptions): Promise<Psbt>;
/**
* Add inputs to transaction (with validation)
*/
addInputs(psbt: Psbt, inputs: TransactionInput[]): Promise<void>;
/**
* Add outputs to transaction (with validation)
*/
addOutputs(psbt: Psbt, outputs: TransactionOutput[]): Promise<void>;
/**
* Add change output if needed
*/
addChange(psbt: Psbt, changeAddress: string, changeAmount: number): void;
/**
* Sign transaction
*/
sign(psbt: Psbt, options: SignOptions): Promise<void>;
/**
* Finalize and extract transaction (with validation)
*/
finalize(psbt: Psbt): Promise<Transaction>;
/**
* Build complete transaction from UTXOs
*/
buildFromUTXOs(utxos: UTXO[], outputs: TransactionOutput[], changeAddress: string, options?: Partial<BuildOptions>): Psbt;
/**
* Estimate transaction size
*/
estimateSize(numInputs: number, numOutputs: number, isSegwit?: boolean): number;
/**
* Calculate transaction fee
*/
calculateFee(size: number, feeRate: number): number;
}
interface TransactionBuilderConfig {
network: Network;
dustThreshold?: number;
defaultFeeRate?: number;
defaultRbf?: boolean;
}
/**
* Hardware Wallet Interface Definitions
*/
interface DerivationPath {
/** Master key fingerprint */
masterFingerprint: Buffer;
/** BIP32 derivation path */
path: string;
}
interface SignPsbtOptions {
/** PSBT to sign */
psbt: Psbt;
/** Input indices to sign */
inputIndices: number[];
/** Derivation paths for each input */
derivationPaths: DerivationPath[];
/** Bitcoin network */
network: Network;
}
interface SigningError {
/** Input index that failed */
inputIndex: number;
/** Error message */
error: string;
}
interface SignPsbtResult {
/** Signed PSBT */
psbt: Psbt;
/** Any signing errors */
errors?: SigningError[];
}
interface IHardwareWallet {
/**
* Sign a PSBT with the hardware wallet
*/
signPsbt(options: SignPsbtOptions): Promise<SignPsbtResult>;
/**
* Get extended public key for a derivation path
*/
getExtendedPublicKey(path: string): Promise<string>;
/**
* Get device information
*/
getDeviceInfo(): Promise<{
model: string;
version: string;
fingerprint: Buffer;
}>;
/**
* Check if device is connected and ready
*/
isReady(): Promise<boolean>;
}
/**
* Enhanced Fee Estimator Implementation
* Provides accurate witness size calculation and dynamic dust thresholds
* Uses normalized satsPerVB for consistency with BTCStampsExplorer
*/
declare class FeeEstimator implements IFeeEstimator {
private options;
private src20Options;
private electrumXFeeEstimator?;
private mockElectrumXProvider?;
private static readonly OUTPUT_SIZES;
private static readonly INPUT_BASE_SIZES;
private static readonly WITNESS_SIZES;
private static readonly BASE_DUST_THRESHOLDS;
constructor(options?: FeeEstimatorOptions, src20Options?: SRC20Options);
getFeeRates(): Promise<FeeRate>;
estimateFee(size: number, priority: 'low' | 'medium' | 'high' | 'urgent'): Promise<FeeEstimate>;
calculateTransactionSize(inputs: Array<{
type: InputType;
witnessScript?: Buffer;
}>, outputs: Array<{
type: OutputType;
size?: number;
}>): SizeCalculation;
getOutputSize(type: OutputType, scriptSize?: number): number;
getInputSize(type: InputType, witnessScript?: Buffer): SizeCalculation;
getDustThresholds(feeRate?: number): DustThresholds;
calculateCPFP(parentTxid: string, parentFee: number, childSize: number, targetFeeRate: number): Promise<number>;
calculateRBF(originalFee: number, minRelayFee?: number): number;
/**
* Get fee estimation for specific transaction parameters
*/
getOptimalFee(params: {
inputs: Array<{
type: InputType;
witnessScript?: Buffer;
}>;
outputs: Array<{
type: OutputType;
size?: number;
}>;
priority?: 'low' | 'medium' | 'high' | 'urgent';
}): Promise<FeeEstimate & {
sizeBreakdown: SizeCalculation;
}>;
/**
* Validate if output value is above dust threshold
*/
isAboveDustThreshold(value: number, outputType: OutputType, feeRate?: number): boolean;
/**
* Normalize fee rates from external providers to ensure consistency
*/
private normalizeFeeRatesFromProvider;
/**
* Get normalized fee rates for all priority levels
*/
getNormalizedFeeRates(): Promise<{
low: NormalizedFeeRate;
medium: NormalizedFeeRate;
high: NormalizedFeeRate;
urgent: NormalizedFeeRate;
}>;
/**
* Get fee rates from mempool.space API
*/
private getMempoolSpaceFeeRates;
/**
* Get fee rates from Blockstream API
*/
private getBlockstreamFeeRates;
/**
* Set custom fee provider
*/
setProvider(provider: NonNullable<FeeEstimatorOptions['provider']>): void;
/**
* Get current provider configuration
*/
getProviderInfo(): {
provider: string;
electrumXConnected: boolean;
fallbackFeeRate: number;
useMockProvider: boolean;
};
/**
* Test connection to current fee provider
*/
testProvider(): Promise<{
success: boolean;
provider: string;
latency?: number;
error?: string;
}>;
}
/**
* SRC-20 Specific Fee Calculator
* Implements stamp-specific fee rules and minimum value requirements
* Uses normalized satsPerVB for consistency with BTCStampsExplorer
*/
interface Src20FeeRules {
preferredFeeRateSatsPerVB: number;
priorityMultiplier: number;
maxDataOutputs: number;
}
interface Src20TransactionParams {
stampValue: number;
dataOutputCount: number;
changeOutputType?: OutputType;
hasStampInput?: boolean;
isStampCreation?: boolean;
isStampTransfer?: boolean;
}
/**
* Calculator for SRC-20 stamp transaction fees with specific business rules
*/
declare class Src20FeeCalculator extends FeeEstimator {
private rules;
constructor(rules?: Partial<Src20FeeRules>, src20Options?: SRC20BuilderOptions);
/**
* Calculate fee for SRC-20 stamp transaction using normalized satsPerVB
*/
calculateStampTransactionFee(params: Src20TransactionParams, inputs: Array<{
type: InputType;
witnessScript?: Buffer;
}>, outputs: Array<{
type: OutputType;
size?: number;
}>, priority?: 'low' | 'medium' | 'high' | 'urgent'): Promise<FeeEstimate & {
src20Rules: {
appliedMultiplier: number;
dataOutputCount: number;
recommendedFeeRateSatsPerVB: number;
};
normalizedFee: NormalizedFeeRate;
sizeBreakdown: {
inputSize: number;
outputSize: number;
witnessSize: number;
virtualSize: number;
};
}>;
/**
* Validate SRC-20 stamp transaction parameters
*/
private validateStampParams;
/**
* Calculate adjusted fee rate for SRC-20 transactions using normalized satsPerVB
*/
private calculateAdjustedFeeRateNormalized;
/**
* Calculate adjusted fee rate for SRC-20 transactions (legacy method for backward compatibility)
* @deprecated Use calculateAdjustedFeeRateNormalized instead
*/
private __calculateAdjustedFeeRate;
/**
* Get priority multiplier for stamp transactions
*/
private getStampPriorityMultiplier;
/**
* Calculate total effective multiplier for fee calculation
*/
private calculateTotalMultiplier;
/**
* Check if transaction qualifies for SRC-20 rules
*/
isStampTransaction(params: Src20TransactionParams): boolean;
/**
* Calculate optimal change output value for stamp transactions
*/
calculateOptimalChange(inputValue: number, outputValue: number, estimatedFee: number, _changeType?: OutputType): {
changeValue: number;
shouldCreateChange: boolean;
dustThreshold: number;
};
/**
* Get recommended fee rates for different stamp transaction types (normalized to satsPerVB)
*/
getRecommendedFeeRates(): {
stampCreation: {
low: number;
medium: number;
high: number;
urgent: number;
};
stampTransfer: {
low: number;
medium: number;
high: number;
urgent: number;
};
regularWithStamp: {
low: number;
medium: number;
high: number;
urgent: number;
};
};
/**
* Get normalized recommended fee rates for different stamp transaction types
*/
getNormalizedRecommendedFeeRates(): {
stampCreation: {
low: NormalizedFeeRate;
medium: NormalizedFeeRate;
high: NormalizedFeeRate;
urgent: NormalizedFeeRate;
};
stampTransfer: {
low: NormalizedFeeRate;
medium: NormalizedFeeRate;
high: NormalizedFeeRate;
urgent: NormalizedFeeRate;
};
regularWithStamp: {
low: NormalizedFeeRate;
medium: NormalizedFeeRate;
high: NormalizedFeeRate;
urgent: NormalizedFeeRate;
};
};
/**
* Estimate total transaction cost including stamp value
*/
estimateStampTransactionCost(params: Src20TransactionParams, inputs: Array<{
type: InputType;
witnessScript?: Buffer;
}>, outputs: Array<{
type: OutputType;
size?: number;
}>, priority?: 'low' | 'medium' | 'high' | 'urgent'): Promise<{
stampValue: number;
networkFee: number;
totalCost: number;
breakdown: {
baseTransactionFee: number;
stampPremium: number;
dataPremium: number;
priorityMultiplier: number;
};
}>;
/**
* Get current SRC-20 fee rules
*/
getStampRules(): Src20FeeRules;
/**
* Update SRC-20 fee rules
*/
updateStampRules(newRules: Partial<Src20FeeRules>): void;
}
/**
* Create an SRC-20 fee calculator with customizable rules for token transactions
*
* @param customRules - Optional partial fee rules to override defaults
* @param src20Options - Optional SRC-20 specific configuration
* @returns A configured Src20FeeCalculator instance
*
* @example Basic SRC-20 fee calculation
* ```typescript
* const calculator = createSrc20FeeCalculator();
* const fee = calculator.calculateTransferFee(utxos, feeRate);
* ```
*
* @example With custom rules
* ```typescript
* const calculator = createSrc20FeeCalculator({
* baseMultiplier: 1.5,
* minFeeMultiplier: 2
* });
* ```
*/
declare function createSrc20FeeCalculator(customRules?: Partial<Src20FeeRules>, src20Options?: SRC20BuilderOptions): Src20FeeCalculator;
/**
* Main Transaction Builder Implementation
*/
/**
* Main transaction builder for creating Bitcoin transactions with advanced features
*
* @remarks
* Provides comprehensive transaction building capabilities including:
* - UTXO selection and management
* - Fee calculation and optimization
* - Multi-signature support
* - RBF (Replace-By-Fee) configuration
* - Dust threshold management
*
* @example
* ```typescript
* const builder = new TransactionBuilder({
* network: networks.bitcoin,
* dustThreshold: 546,
* defaultFeeRate: 10
* });
*
* const psbt = await builder.buildTransaction({
* inputs: [...],
* outputs: [...],
* feeRate: 15
* });
* ```
*/
declare class TransactionBuilder implements ITransactionBuilder {
private config;
private feeEstimator;
private dustCalculator;
private src20FeeCalculator;
private advancedFeeCalculator;
private validationEngine;
constructor(config: TransactionBuilderConfig);
create(options: BuildOptions): Promise<bitcoin.Psbt & {
outputCount: number;
}>;
addInputs(psbt: bitcoin.Psbt, inputs: TransactionInput[]): Promise<void>;
addOutputs(psbt: bitcoin.Psbt, outputs: TransactionOutput[]): Promise<void>;
addChange(psbt: bitcoin.Psbt, changeAddress: string, changeAmount: number): void;
sign(psbt: bitcoin.Psbt, options: SignOptions): Promise<void>;
finalize(psbt: bitcoin.Psbt): Promise<bitcoin.Transaction>;
buildFromUTXOs(utxos: UTXO[], outputs: TransactionOutput[], changeAddress: string, options?: Partial<BuildOptions>): bitcoin.Psbt & {
outputCount: number;
};
/**
* Estimate transaction size in bytes
* Basic formula: ~180 bytes per input + ~34 bytes per output + ~10 bytes overhead
*/
estimateSize(inputCount: number, outputCount: number, hasWitness?: boolean): number;
/**
* Calculate fee based on size and fee rate
* Simply: size * feeRate
*/
calculateFee(size: number, feeRate: number): number;
/**
* Get network type string from bitcoin.Network
* Return 'mainnet', 'testnet', or 'regtest' based on network
*/
getNetworkType(network?: bitcoin.Network): string;
/**
* Calculate fee for stamp transaction using SRC-20 calculator
*/
calculateStampTransactionFee(params: Src20TransactionParams, inputs: Array<{
type: InputType;
witnessScript?: Buffer;
}>, outputs: Array<{
type: OutputType;
size?: number;
}>, priority?: 'low' | 'medium' | 'high' | 'urgent'): Promise<ReturnType<typeof this$1.src20FeeCalculator.calculateStampTransactionFee>>;
/**
* Estimate total cost of stamp transaction including stamp value
*/
estimateStampTransactionCost(params: Src20TransactionParams, inputs: Array<{
type: InputType;
witnessScript?: Buffer;
}>, outputs: Array<{
type: OutputType;
size?: number;
}>, priority?: 'low' | 'medium' | 'high' | 'urgent'): Promise<ReturnType<typeof this$1.src20FeeCalculator.estimateStampTransactionCost>>;
/**
* Get SRC-20 minimum value (500,000 satoshis)
*/
getSrc20MinValue(): number;
/**
* Get stamp fee rates for different transaction types
*/
getStampFeeRates(): ReturnType<typeof this$1.src20FeeCalculator.getRecommendedFeeRates>;
/**
* Check if change amount is above dust threshold
*/
isChangeAboveDust(amount: number, outputType?: OutputType): boolean;
/**
* Estimate optimal fee for different input/output combinations
*/
estimateOptimalFee(inputs: Array<{
type: InputType;
}>, outputs: Array<{
type: OutputType;
}>, priority?: 'low' | 'medium' | 'high' | 'urgent'): Promise<{
totalFee: number;
feeRate: number;
virtualSize: number;
}>;
/**
* Get dynamic dust thresholds for different output types
*/
getDustThresholds(feeRate?: number): DustThresholds;
/**
* Estimate transaction size with different input/output types
*/
estimateSizeWithTypes(inputs: Array<{
type: InputType;
}>, outputs: Array<{
type: OutputType;
}>): number;
/**
* Check if transaction meets stamp criteria
*/
isStampTransaction(params: {
stampValue: number;
dataOutputCount: number;
isStampCreation: boolean;
}): boolean;
/**
* Calculate optimal change for stamp transactions
*/
calculateStampOptimalChange(inputValue: number, outputValue: number, estimatedFee: number): {
changeValue: number;
shouldCreateChange: boolean;
};
}
/**
* PSBT (Partially Signed Bitcoin Transaction) Builder
* Advanced PSBT operations and utilities
*/
interface PSBTOptions {
network?: Network;
maximumFeeRate?: number;
version?: number;
locktime?: number;
}
/**
* Builder for creating and manipulating Partially Signed Bitcoin Transactions (PSBTs)
*
* @remarks
* PSBTBuilder provides a fluent interface for constructing PSBTs with support for:
* - Multiple input types (P2PKH, P2WPKH, P2SH, P2WSH)
* - Witness and non-witness UTXOs
* - Custom scripts and redeem scripts
* - Fee calculation and validation
* - Transaction finalization
*
* @example
* ```typescript
* const builder = new PSBTBuilder();
* const psbt = builder
* .addInput(utxo)
* .addOutput({ address: 'bc1q...', value: 100000 })
* .build();
* ```
*/
declare class PSBTBuilder {
protected psbt: bitcoin.Psbt;
private network;
constructor(options?: PSBTOptions);
/**
* Create PSBT from base64 string
*/
static fromBase64(base64: string, network?: Network): PSBTBuilder;
/**
* Create PSBT from hex string
*/
static fromHex(hex: string, network?: Network): PSBTBuilder;
/**
* Create PSBT from buffer
*/
static fromBuffer(buffer: Buffer, network?: Network): PSBTBuilder;
/**
* Add standard input
*/
addInput(txid: string, vout: number, options?: {
sequence?: number;
witnessUtxo?: {
script: Buffer;
value: number;
};
nonWitnessUtxo?: Buffer;
redeemScript?: Buffer;
witnessScript?: Buffer;
}): this;
/**
* Add standard output
*/
addOutput(addressOrScript: string | Buffer, value: number): this;
/**
* Add OP_RETURN output
*/
addDataOutput(data: Buffer): this;
/**
* Combine multiple PSBTs
*/
combine(...psbts: bitcoin.Psbt[]): this;
/**
* Validate all inputs have signatures
*/
validateSignatures(): boolean;
/**
* Get fee amount
*/
getFee(): number;
/**
* Get fee rate (sat/vB)
*/
getFeeRate(): number;
/**
* Extract transaction without finalizing
*/
extractTransaction(skipFinalization?: boolean): bitcoin.Transaction | null;
/**
* Clone PSBT
*/
clone(): PSBTBuilder;
/**
* Export to base64
*/
toBase64(): string;
/**
* Export to hex
*/
toHex(): string;
/**
* Export to buffer
*/
toBuffer(): Buffer;
/**
* Get underlying PSBT
*/
getPSBT(): bitcoin.Psbt & {
outputCount: number;
};
}
/**
* Enhanced PSBT Builder
* BIP-174 compliant PSBT builder with advanced features
*/
interface EnhancedPSBTOptions extends PSBTOptions {
/** Enable strict BIP-174 compliance */
strictCompliance?: boolean;
/** Enable hardware wallet mode */
hardwareWalletMode?: boolean;
/** Target hardware wallet type */
targetWalletType?: 'ledger' | 'trezor' | 'coldcard';
}
interface PSBTMetadata {
/** Transaction version */
version?: number;
/** Transaction locktime */
locktime?: number;
/** Input count */
inputCount: number;
/** Output count */
outputCount: number;
/** Fee amount */
fee?: number;
/** Fee rate (sat/vB) */
feeRate?: number;
/** Transaction size estimate */
estimatedSize?: number;
/** RBF enabled */
rbfEnabled?: boolean;
}
interface InputMetadata {
/** Input index */
index: number;
/** Previous transaction ID */
prevTxid: string;
/** Previous output index */
prevVout: number;
/** Input value */
value: number;
/** Input script type */
scriptType: 'p2pkh' | 'p2wpkh' | 'p2sh-p2wpkh' | 'p2tr' | 'p2wsh' | 'p2sh' | 'unknown';
/** Sequence number */
sequence: number;
/** Has witness UTXO */
hasWitnessUtxo: boolean;
/** Has non-witness UTXO */
hasNonWitnessUtxo: boolean;
/** BIP32 derivation paths */
derivationPaths: DerivationPath[];
/** Signatures count */
signaturesCount: number;
/** Required signatures count */
signaturesRequired: number;
}
interface OutputMetadata {
/** Output index */
index: number;
/** Output value */
value: number;
/** Output address (if applicable) */
address?: string;
/** Output script type */
scriptType: 'p2pkh' | 'p2wpkh' | 'p2sh' | 'p2tr' | 'p2wsh' | 'op_return' | 'unknown';
/** Is change output */
isChange?: boolean;
/** BIP32 derivation paths */
derivationPaths: DerivationPath[];
}
/**
* Enhanced PSBT Builder with BIP-174 compliance and advanced features
*/
declare class EnhancedPSBTBuilder extends PSBTBuilder {
private options;
private inputDerivations;
private outputDerivations;
constructor(options?: EnhancedPSBTOptions);
/**
* Add input with enhanced validation and metadata
*/
addEnhancedInput(txid: string, vout: number, options?: {
sequence?: number;
witnessUtxo?: {
script: Buffer;
value: number;
};
nonWitnessUtxo?: Buffer;
redeemScript?: Buffer;
witnessScript?: Buffer;
derivationPaths?: DerivationPath[];
publicKeys?: Buffer[];
}): this;
/**
* Add output with enhanced validation and metadata
*/
addEnhancedOutput(addressOrScript: string | Buffer, value: number, options?: {
derivationPaths?: DerivationPath[];
publicKeys?: Buffer[];
isChange?: boolean;
}): this;
/**
* Add BIP32 derivation information to input
*/
addInputDerivation(inputIndex: number, derivation: DerivationPath, publicKey: Buffer): void;
/**
* Add BIP32 derivation information to output
*/
addOutputDerivation(outputIndex: number, derivation: DerivationPath, publicKey: Buffer): void;
/**
* Set input witness UTXO (required for segwit inputs)
*/
setInputWitnessUtxo(inputIndex: number, witnessUtxo: {
script: Buffer;
value: number;
}): void;
/**
* Set input non-witness UTXO for legacy inputs
*/
setInputNonWitnessUtxo(inputIndex: number, nonWitnessUtxo: Buffer): void;
/**
* Add redeem script for P2SH inputs
*/
addInputRedeemScript(inputIndex: number, redeemScript: Buffer): void;
/**
* Add witness script for P2WSH inputs
*/
addInputWitnessScript(inputIndex: number, witnessScript: Buffer): void;
/**
* Get comprehensive PSBT metadata
*/
getMetadata(): PSBTMetadata;
/**
* Get input metadata
*/
getInputMetadata(inputIndex: number): InputMetadata;
/**
* Get output metadata
*/
getOutputMetadata(outputIndex: number): OutputMetadata;
/**
* Check if Replace-by-Fee is enabled
* Note: RBF should be enabled when adding inputs, not after PSBT creation
*/
getRbfStatus(): boolean;
/**
* Create enhanced clone with metadata preservation
*/
enhancedClone(): EnhancedPSBTBuilder;
private calculateFeeIfPossible;
private calculateFeeRateIfPossible;
private estimateTransactionSize;
private isRbfEnabled;
private detectInputScriptType;
private detectOutputScriptType;
private extractAddressFromScript;
private isChangeOutput;
/**
* Validate PSBT for hardware wallet compatibility
*/
validateForHardwareWallet(_walletType: 'ledger' | 'trezor' | 'coldcard'): {
valid: boolean;
issues: string[];
};
/**
* Sign PSBT with hardware wallet
*/
signWithHardwareWallet(hardwareWallet: IHardwareWallet): Promise<void>;
}
/**
* Bitcoin Script Builder
* Utilities for creating various Bitcoin scripts
*/
/**
* Builder for creating various types of Bitcoin scripts
*
* @remarks
* ScriptBuilder provides utilities for creating different Bitcoin script types
* used in transactions. It abstracts the complexity of script creation and
* provides a simple interface for common script patterns.
*
* Supported script types:
* - P2PKH (Pay to Public Key Hash)
* - P2WPKH (Pay to Witness Public Key Hash)
* - P2SH (Pay to Script Hash)
* - P2WSH (Pay to Witness Script Hash)
* - P2TR (Pay to Taproot)
* - Multisig scripts
* - Custom OP_RETURN data scripts
*
* @example
* ```typescript
* const scriptBuilder = new ScriptBuilder(networks.bitcoin);
*
* // Create a P2WPKH script
* const p2wpkhScript = scriptBuilder.createP2WPKH('bc1q...');
*
* // Create a multisig script
* const multisigScript = scriptBuilder.createMultisig(2, [pubkey1, pubkey2, pubkey3]);
* ```
*/
declare class ScriptBuilder {
private network;
constructor(network?: Network);
/**
* Create P2PKH (Pay to Public Key Hash) script
*/
createP2PKH(address: string): Buffer;
/**
* Create P2WPKH (Pay to Witness Public Key Hash) script
*/
createP2WPKH(address: string): Buffer;
/**
* Create P2SH (Pay to Script Hash) script
*/
createP2SH(redeemScript: Buffer): Buffer;
/**
* Create P2WSH (Pay to Witness Script Hash) script
*/
createP2WSH(witnessScript: Buffer): Buffer;
/**
* Create multisig script
*/
createMultisig(m: number, pubkeys: Buffer[]): Buffer;
/**
* Create OP_RETURN script
*/
createOpReturn(data: Buffer | Buffer[]): Buffer;
/**
* Create bare multisig for stamps (1-of-2 or 1-of-3)
*/
createBareMultisigForStamps(pubkeys: Buffer[], _dataChunks: Buffer[]): Buffer;
/**
* Create P2SH-wrapped multisig
*/
createP2SHMultisig(m: number, pubkeys: Buffer[]): {
address: string;
redeemScript: Buffer;
scriptPubKey: Buffer;
};
/**
* Create timelocked script
*/
createTimelocked(locktime: number, pubkey: Buffer): Buffer;
/**
* Parse script to identify type
*/
identifyScript(script: Buffer): string;
/**
* Validate script
*/
isValidScript(script: Buffer): boolean;
}
export { type EnhancedPSBTOptions as E, FeeEstimator as F, type InputMetadata as I, type OutputMetadata as O, type PSBTOptions as P, ScriptBuilder as S, TransactionBuilder as T, PSBTBuilder as a, type PSBTMetadata as b, EnhancedPSBTBuilder as c, createSrc20FeeCalculator as d };