@ecash/lib
Version:
Library for eCash transaction building
89 lines • 3.29 kB
TypeScript
import { Bytes } from './io/bytes.js';
import { Writer } from './io/writer.js';
import { Script } from './script.js';
/**
* Default value for nSequence of inputs if left undefined; this opts out of
* BIP68 relative lock-time, and if all inputs have this value, nLockTime is
* disabled, too.
*
* This is chosen as the default as it's the default in the node too,
* see CTxIn in /src/primitives/transaction.h.
**/
export declare const DEFAULT_SEQUENCE = 4294967295;
/** Current tx version, see CTransaction in /stc/primitives/transaction.h */
export declare const DEFAULT_TX_VERSION = 2;
/** COutPoint, pointing to a coin being spent. */
export interface OutPoint {
/**
* TxId of the output of the coin, either a big-endian hex encoded TxId
* or a little-endian bytearray.
**/
txid: string | Uint8Array;
/** Index in the outputs of the tx of the coin. */
outIdx: number;
}
/** CTxIn, spending an unspent output. */
export interface TxInput {
/** Points to an output being spent. */
prevOut: OutPoint;
/** scriptSig unlocking the output, defaults to the empty Script. */
script?: Script;
/** nSequence, defaults to 0xffffffff if unspecified. */
sequence?: number;
/** Sign data required to sign an input */
signData?: SignData;
}
/** CTxOut, creating a new output. */
export interface TxOutput {
/** Value in satoshis of the output (1 XEC = 100 satoshis) */
value: number | bigint;
/** Script locking the output */
script: Script;
}
/** All the data required to sign an input (using BIP143). */
export interface SignData {
/** Value of the output being spent */
value: number | bigint;
/** Script of the output being spent (not for P2SH) */
outputScript?: Script;
/**
* For P2SH inputs, the preimage of the script hash locking the output being
* spent.
**/
redeemScript?: Script;
}
/** CTransaction, a Bitcoin transaction. */
export declare class Tx {
/** nVersion of the tx */
version: number;
/** vin, tx inputs spending outputs of other txs */
inputs: TxInput[];
/** vout, tx outputs created in this tx */
outputs: TxOutput[];
/** nLockTime of the tx, specifies when the tx can be mined earliest */
locktime: number;
constructor(params?: {
version?: number;
inputs?: TxInput[];
outputs?: TxOutput[];
locktime?: number;
});
/** Serialize the tx to a byte array */
ser(): Uint8Array;
/** Calculate the serialized size of the tx */
serSize(): number;
/** Write the tx to the given writer */
write(writer: Writer): void;
}
export declare function readTxOutput(bytes: Bytes): TxOutput;
/** Write an outpoint to a Writer */
export declare function writeOutPoint(outpoint: OutPoint, writer: Writer): void;
/** Write a TxInput to a Writer */
export declare function writeTxInput(input: TxInput, writer: Writer): void;
/** Write a TxOutput to a Writer */
export declare function writeTxOutput(output: TxOutput, writer: Writer): void;
/** Create a deep copy of the TxInput */
export declare function copyTxInput(input: TxInput): TxInput;
/** Create a deep copy of the TxOutput */
export declare function copyTxOutput(output: TxOutput): TxOutput;
//# sourceMappingURL=tx.d.ts.map