All files Network.ts

90.91% Statements 20/22
100% Branches 0/0
66.67% Functions 4/6
90.91% Lines 20/22

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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 841x   3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x               153x       8x               83x       1x                             1x                             1x                             1x  
export class Network {
    constructor(
        readonly name: string,
        readonly p2pkhPrefix: number,
        readonly p2shPrefix: number,
        readonly p2wpkhPrefix: string,
        readonly p2wshPrefix: string,
        readonly xpubVersion: number,
        readonly xprvVersion: number,
        readonly ypubVersion: number,
        readonly yprvVersion: number,
        readonly zpubVersion: number,
        readonly zprvVersion: number,
        readonly wifPrefix: number,
    ) {}
 
    public isMainnet() {
        return this.name === "mainnet";
    }
 
    public static get mainnet(): Network {
        return mainnet;
    }
 
    public static get testnet(): Network {
        return testnet;
    }
 
    public static get regtest(): Network {
        return regtest;
    }
 
    public static get all(): Network[] {
        return all;
    }
}
 
const mainnet = new Network(
    "mainnet",
    0x00, // 1
    0x05, // 3
    "bc",
    "bc",
    0x0488b21e, // xpub
    0x0488ade4, // xprv
    0x049d7cb2, // ypub
    0x049d7878, // yprv
    0x04b24746, // zpub
    0x04b2430c, // zprv
    0x80, // 5 (uncompressed), K or L (compressed)
);
 
const testnet = new Network(
    "testnet",
    0x6f, // m or n
    0xc4, // 2
    "tb",
    "tb",
    0x043587cf, // tpub
    0x04358394, // tprv
    0x044a5262, // upub
    0x044a4e28, // uprv
    0x045f1cf6, // vpub
    0x045f18bc, // vprv
    0xef,
);
 
const regtest = new Network(
    "regtest",
    0x6f, // m or n
    0xc4, // 2
    "bcrt",
    "bcrt",
    0x043587cf, // tpub
    0x04358394, // tprv
    0x044a5262, // upub
    0x044a4e28, // uprv
    0x045f1cf6, // vpub
    0x045f18bc, // vprv
    0xef,
);
 
const all = [mainnet, testnet, regtest];