@node-dlc/bitcoin
Version:
123 lines (122 loc) • 3.51 kB
TypeScript
import { ICloneable } from './ICloneable';
/**
* Represents bitcoin value that can be converted to or from multiple
* formats.
*/
export declare class Value implements ICloneable<Value> {
/**
* Creates a value object from value in bitcoin, eg: 1.12345678
* @param num
*/
static fromBitcoin(num: number): Value;
/**
* Creates a value instance from value in satoshis where 1 satoshis
* equates to 0.00000001 bitcoin.
* @param num
*/
static fromSats(num: bigint | number): Value;
/**
* Creates a value instance from value in millisatoshis, 1/1000 of a
* satoshi.
* eg: 123 millisatoshis equates to 0.123 satoshis
* eg: 123 millisatoshis equates to 0.00000000123 bitcoin
* @param num
*/
static fromMilliSats(num: bigint | number): Value;
/**
* Creates a value instance from value in microsatoshis, 1/1e6 of a
* satoshi.
* eg: 123 microsatoshis equates to 0.000123 satoshis
* eg: 123 microsatoshis equates to 0.00000000000123 bitcoin
* @param num
*/
static fromMicroSats(num: bigint | number): Value;
/**
* Creates a value instance from value in picosatoshis, 1/1e12 of a
* satoshi.
* eg: 123 picosatoshis equates to 0.000000000123 satoshis
* eg: 123 picosatoshis equates to 0.00000000000000000123 bitcoin
* @param num
*/
static fromPicoSats(num: bigint | number): Value;
/**
* Generates a value instance of zero
*/
static zero(): Value;
_picoSats: bigint;
/**
* Gets the value in picosatoshis (1/1e12 satoshis)
*/
get psats(): bigint;
/**
* Gets the value in millionth of satoshis (1/1e6 satoshis)
*/
get microsats(): bigint;
/**
* Gets the value in millisatoshis (1/1000 satoshis)
*/
get msats(): bigint;
/**
* Gets the value in satoshis (1/1e8 bitcoin)
*/
get sats(): bigint;
/**
* Gets the value in bitcoin
*/
get bitcoin(): number;
constructor(picoSats: bigint);
/**
* Clone via deep copy
*/
clone(): Value;
/**
* Adds another value to this instance and returns this instance
* @param other
*/
add(other: Value): this;
/**
* Adds another value to the current value and returns a new Value instance
* @param other
*/
addn(other: Value): Value;
/**
* Subtracts another value from this instance and returns this instance
* @param other
*/
sub(other: Value): this;
/**
* Subtracts another value from the current value and returns a new Value instance
* @param other
*/
subn(other: Value): Value;
/**
* Returns true if this value is less than the other value
* @param other
*/
lt(other: Value): boolean;
/**
* Returns true if this value is equal to the other value
* @param other
*/
eq(other: Value): boolean;
/**
* Returns true if this value is greater than the other value
* @param other
*/
gt(other: Value): boolean;
/**
* Returns true if this value is greater than or equal to the other value
* @param other
*/
gte(other: Value): boolean;
/**
* Returns true if this value is less than or equal to the other value
* @param other
*/
lte(other: Value): boolean;
/**
* Returns a string representation of the value in bitcoin format
* with 8 decimal places
*/
toString(): string;
}