@node-dlc/bitcoin
Version:
117 lines (116 loc) • 3.85 kB
TypeScript
/// <reference types="node" />
import { StreamReader } from '@node-dlc/bufio';
import { ICloneable } from './ICloneable';
import { TimeLockMode } from './TimeLockMode';
/**
* A transaction input's nSequence field according to BIP 68 where
* rules for relative timelocks are defined. Relative timelocks prevent
* mining of a transaction until a certain age of the spent output
* in blocks or timespan.
*
* nSequence defaults to a value of 0xffff_ffff which disables the field.
* When using a nLocktime, at least one transaction must be non-default.
* In this condition, it is standard to use 0xffff_fffe.
*/
export declare class Sequence implements ICloneable<Sequence> {
/**
* Parses the value from a byte stream
* @param reader
*/
static parse(reader: StreamReader): Sequence;
/**
* Creates an nSequence value of 0xffff_fffe which is used to enable
* nLockTime.
*/
static locktime(): Sequence;
/**
* Creates an nSequence value of 0xffff_fffd which is used to
* enable opt-in full replace-by-fee.
*/
static rbf(): Sequence;
/**
* Creates an nSequence value of 0xffff_ffff
*/
static default(): Sequence;
/**
* Creates an nSequence value of 0
*/
static zero(): Sequence;
/**
* Creates an nSequence value with the specified block delay
* @param blocks number of blocks sequence must wait
*/
static blockDelay(blocks: number): Sequence;
/**
* Creates an nSequence value with the specified time delay
* @param seconds delay in seconds which will be rounded up to the
* nearest 512 second interval
*/
static timeDelay(seconds: number): Sequence;
/**
* Gets or sets the raw nSequence value.
*/
get value(): number;
set value(val: number);
private _value;
constructor(val?: number);
/**
* Returns true when the nSequence is the default value 0xffff_ffff
*/
get isDefault(): boolean;
/**
* Returns true when the relative timelock is enabled. Technically
* this occurs when the top-most bit is unset. This means that the
* default value of 0xffff_ffff is unset.
*/
get enabled(): boolean;
/**
* Returns true for a value that would enable nLockTime. To enable
* nLockTime, at least one input in the transaction must have a
* non-default nSequence value.
*/
get isLockTimeSignaled(): boolean;
/**
* Returns true for a value that would signal opt-in replace-by-fee
* as defined in BIP 125. To signal this, the nSequence must be less
* than 0xffffffff-1.
*/
get isRBFSignaled(): boolean;
/**
* Gets the time lock mode for the nSequence. Technically, the bit
* with index 22 controls the mode. When the bit is set, it will use
* time-based relative time locks. When it is unset, it will use
* block-based relatively time locks.
*/
get mode(): TimeLockMode;
/**
* Gets or sets a relative timelock in seconds. Time-based relative
* time locks are encoded in 512 second granularity which is close
* to the 600 seconds each block should be generated in. When
* setting a value in seconds, it will rounded up to the nearest
* 512s granularity.
*/
get timeDelay(): number;
set timeDelay(seconds: number);
/**
* Gets or set a relative timelock in blocks.
*/
get blockDelay(): number;
set blockDelay(blocks: number);
/**
* Serializes the value to a buffer
*/
serialize(): Buffer;
/**
* Returns the raw value as a hex encoded string, eg: 0xfffffffe
*/
toString(): string;
/**
* Returns the raw value as a hex encoded string, eg: 0xfffffffe
*/
toJSON(): string;
/**
* Clone via deep copy
*/
clone(): Sequence;
}