All files hrp-pico.ts

100% Statements 9/9
100% Branches 7/7
100% Functions 1/1
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                    1x 49x 39x   18x   11x   5x   4x   1x      
/**
 * Returns the pico equivalent of the hrp multiplier as a BN object
 *
 * For instance:
 *   since m (milli) is 0.001 bitcoin, this is the equivalent of
 *   1000000000 or 1e9 pico bitcoin.
 *
 * @param hrpMultiplier
 * @return returns the BN pico bitcoin value
 */
export function hrpToPico(hrpMultiplier: string): bigint {
    if (!hrpMultiplier) return BigInt(1e12);
    switch (hrpMultiplier) {
        case "m":
            return BigInt(1e9);
        case "u":
            return BigInt(1e6);
        case "n":
            return BigInt(1e3);
        case "p":
            return BigInt(1);
        default:
            throw new Error("Invalid multiplier");
    }
}