@node-dlc/bitcoin
Version:
49 lines (48 loc) • 1.4 kB
TypeScript
import { Value } from './Value';
/**
* Represents bitcoin amount that can be converted to or from multiple
* formats.
*
* The key difference between Amount and Value, is Amount can be negative
*
* Value should be used for Bitcoin transactions, Amount should only be used
* for UI display, i.e. PnL
*/
export declare class Amount extends Value {
/**
* Creates a value object from amount in bitcoin, eg: 1.12345678
* @param num
*/
static fromBitcoin(num: number): Amount;
/**
* Creates a value instance from value in satoshis where 1 satoshis
* equates to 0.00000001 bitcoin.
* @param num
*/
static fromSats(num: bigint | number): Amount;
/**
* Creates a value instance from amount
* @param value
* @returns
*/
static fromValue(value: Value): Amount;
/**
* Gets the value in bitcoin
*/
get bitcoin(): number;
private constructor();
/**
* Modifies the current instance by subtracting the other value
* from our existing value. Since Amount is signed, the value can
* be less than zero.
* @param other
*/
sub(other: Value): this;
/**
* Subtracts supplied value from the current value and returns a new
* value instance. Since Amount is signed, the value can
* be less than zero.
* @param other
*/
subn(other: Value): Amount;
}