send-crypto
Version:
A minimal JavaScript library / wallet for sending crypto assets
38 lines (37 loc) • 1.3 kB
TypeScript
export interface UTXO {
readonly txHash: string;
readonly vOut: number;
readonly amount: number;
readonly scriptPubKey?: string;
readonly confirmations: number;
}
/**
* sortUTXOs compares two UTXOs by amount, then confirmations and then hash.
*
* @example
* sortUTXOs({amount: 1, confirmations: 1}, {amount: 2, confirmations: 0});
* // -1, representing that the first parameter should be ordered first.
*
* @returns a negative value to represent that a should come before b or a
* positive value to represent that b should come before a.
*/
export declare const sortUTXOs: (a: UTXO, b: UTXO) => number;
/**
* fixValue turns a readable value, e.g. `0.0001` BTC, to the value in the smallest
* unit, e.g. `10000` sats.
*
* @example
* fixValue(0.0001, 8) = 10000;
*
* @param value Value in the readable representation, e.g. `0.0001` BTC.
* @param decimals The number of decimals to shift by, e.g. 8.
*/
export declare const fixValue: (value: number, decimals: number) => number;
/**
* fixUTXO calls {{fixValue}} on the value of the UTXO.
*/
export declare const fixUTXO: (utxo: UTXO, decimals: number) => UTXO;
/**
* fixUTXOs maps over an array of UTXOs and calls {{fixValue}}.
*/
export declare const fixUTXOs: (utxos: readonly UTXO[], decimals: number) => UTXO[];