|
| 1 | +package lbry |
| 2 | + |
| 3 | +import ( |
| 4 | + "time" |
| 5 | + |
| 6 | + "github.com/btcsuite/btcd/chaincfg" |
| 7 | + "github.com/btcsuite/btcd/chaincfg/chainhash" |
| 8 | + "github.com/btcsuite/btcd/wire" |
| 9 | +) |
| 10 | + |
| 11 | +func init() { |
| 12 | + if err := chaincfg.Register(&MainNetParams); err != nil { |
| 13 | + panic(err) |
| 14 | + } |
| 15 | + if err := chaincfg.Register(&TestNetParams); err != nil { |
| 16 | + panic(err) |
| 17 | + } |
| 18 | + if err := chaincfg.Register(&RegressionNetParams); err != nil { |
| 19 | + panic(err) |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +// genesisCoinbaseTx is the coinbase transaction for the genesis blocks for |
| 24 | +// the main network, regression test network, and test network (version 3). |
| 25 | +var genesisCoinbaseTx = wire.MsgTx{ |
| 26 | + Version: 1, |
| 27 | + TxIn: []*wire.TxIn{ |
| 28 | + { |
| 29 | + PreviousOutPoint: wire.OutPoint{ |
| 30 | + Hash: chainhash.Hash{}, |
| 31 | + Index: 0xffffffff, |
| 32 | + }, |
| 33 | + SignatureScript: []byte{ |
| 34 | + 0x04, 0xff, 0xff, 0x00, 0x1d, 0x01, 0x04, 0x17, |
| 35 | + 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x20, 0x74, |
| 36 | + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, |
| 37 | + 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, |
| 38 | + }, |
| 39 | + Sequence: 0xffffffff, |
| 40 | + }, |
| 41 | + }, |
| 42 | + TxOut: []*wire.TxOut{ |
| 43 | + { |
| 44 | + Value: 0x12a05f200, |
| 45 | + PkScript: []byte{ |
| 46 | + 0x76, 0xa9, 0x14, 0x34, 0x59, 0x91, 0xdb, 0xf5, |
| 47 | + 0x7b, 0xfb, 0x01, 0x4b, 0x87, 0x00, 0x6a, 0xcd, |
| 48 | + 0xfa, 0xfb, 0xfc, 0x5f, 0xe8, 0x29, 0x2f, 0x88, |
| 49 | + 0xac, |
| 50 | + }, |
| 51 | + }, |
| 52 | + }, |
| 53 | + LockTime: 0, |
| 54 | +} |
| 55 | + |
| 56 | +// https://github.com/lbryio/lbrycrd/blob/master/src/chainparams.cpp#L19 |
| 57 | +var genesisMerkleRoot = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. |
| 58 | + 0xcc, 0x59, 0xe5, 0x9f, 0xf9, 0x7a, 0xc0, 0x92, |
| 59 | + 0xb5, 0x5e, 0x42, 0x3a, 0xa5, 0x49, 0x51, 0x51, |
| 60 | + 0xed, 0x6f, 0xb8, 0x05, 0x70, 0xa5, 0xbb, 0x78, |
| 61 | + 0xcd, 0x5b, 0xd1, 0xc3, 0x82, 0x1c, 0x21, 0xb8, |
| 62 | +}) |
| 63 | + |
| 64 | +var genesisBlock = wire.MsgBlock{ |
| 65 | + Header: wire.BlockHeader{ |
| 66 | + Version: 1, |
| 67 | + PrevBlock: chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 |
| 68 | + MerkleRoot: genesisMerkleRoot, // b8211c82c3d15bcd78bba57005b86fed515149a53a425eb592c07af99fe559cc |
| 69 | + Timestamp: time.Unix(1446058291, 0), // Wednesday, October 28, 2015 6:51:31 PM GMT |
| 70 | + Bits: 0x1f00ffff, |
| 71 | + Nonce: 1287, |
| 72 | + }, |
| 73 | + Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, |
| 74 | +} |
| 75 | + |
| 76 | +var genesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. |
| 77 | + 0x63, 0xf4, 0x34, 0x6a, 0x4d, 0xb3, 0x4f, 0xdf, |
| 78 | + 0xce, 0x29, 0xa7, 0x0f, 0x5e, 0x8d, 0x11, 0xf0, |
| 79 | + 0x65, 0xf6, 0xb9, 0x16, 0x02, 0xb7, 0x03, 0x6c, |
| 80 | + 0x7f, 0x22, 0xf3, 0xa0, 0x3b, 0x28, 0x89, 0x9c, |
| 81 | +}) |
| 82 | + |
| 83 | +func newHashFromStr(hexStr string) *chainhash.Hash { |
| 84 | + hash, err := chainhash.NewHashFromStr(hexStr) |
| 85 | + if err != nil { |
| 86 | + panic(err) |
| 87 | + } |
| 88 | + return hash |
| 89 | +} |
| 90 | + |
| 91 | +// MainNetParams returns the chain configuration for mainnet. |
| 92 | +var MainNetParams = chaincfg.Params{ |
| 93 | + Name: "mainnet", |
| 94 | + Net: 0xfae4aaf1, |
| 95 | + DefaultPort: "9246", |
| 96 | + |
| 97 | + // Chain parameters |
| 98 | + GenesisBlock: &genesisBlock, |
| 99 | + GenesisHash: &genesisHash, |
| 100 | + |
| 101 | + // Address encoding magics |
| 102 | + PubKeyHashAddrID: 85, |
| 103 | + ScriptHashAddrID: 122, |
| 104 | + PrivateKeyID: 28, |
| 105 | + WitnessPubKeyHashAddrID: 0x06, // starts with p2 |
| 106 | + WitnessScriptHashAddrID: 0x0A, // starts with 7Xh |
| 107 | + BIP0034Height: 1, |
| 108 | + BIP0065Height: 200000, |
| 109 | + BIP0066Height: 200000, |
| 110 | + |
| 111 | + // BIP32 hierarchical deterministic extended key magics |
| 112 | + HDPrivateKeyID: [4]byte{0x04, 0x88, 0xad, 0xe4}, // starts with xprv |
| 113 | + HDPublicKeyID: [4]byte{0x04, 0x88, 0xb2, 0x1e}, // starts with xpub |
| 114 | + |
| 115 | + // Human-readable part for Bech32 encoded segwit addresses, as defined in |
| 116 | + // BIP 173. |
| 117 | + Bech32HRPSegwit: "lbc", |
| 118 | + |
| 119 | + // BIP44 coin type used in the hierarchical deterministic path for |
| 120 | + // address generation. |
| 121 | + HDCoinType: 0x8c, |
| 122 | +} |
| 123 | + |
| 124 | +// TestNetParams returns the chain configuration for testnet. |
| 125 | +var TestNetParams = chaincfg.Params{ |
| 126 | + Name: "testnet", |
| 127 | + Net: 0xfae4aae1, |
| 128 | + DefaultPort: "19246", |
| 129 | + |
| 130 | + // Chain parameters |
| 131 | + GenesisBlock: &genesisBlock, |
| 132 | + GenesisHash: &genesisHash, |
| 133 | + |
| 134 | + // Address encoding magics |
| 135 | + PubKeyHashAddrID: 111, |
| 136 | + ScriptHashAddrID: 196, |
| 137 | + PrivateKeyID: 239, |
| 138 | + |
| 139 | + // BIP32 hierarchical deterministic extended key magics |
| 140 | + HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with xprv |
| 141 | + HDPublicKeyID: [4]byte{0x04, 0x35, 0x87, 0xcf}, // starts with xpub |
| 142 | + |
| 143 | + // Human-readable part for Bech32 encoded segwit addresses, as defined in |
| 144 | + // BIP 173. |
| 145 | + Bech32HRPSegwit: "tlbc", |
| 146 | + |
| 147 | + // BIP44 coin type used in the hierarchical deterministic path for |
| 148 | + // address generation. |
| 149 | + HDCoinType: 0x8c, |
| 150 | +} |
| 151 | + |
| 152 | +// RegressionNetParams returns the chain configuration for regression net. |
| 153 | +var RegressionNetParams = chaincfg.Params{ |
| 154 | + Name: "regtest", |
| 155 | + |
| 156 | + // LBRY has 0xfae4aad1 as RegTest (same as Bitcoin's RegTest). |
| 157 | + // Setting it to an arbitrary value (leet_hex(LBRY)), so that we can |
| 158 | + // register the regtest network. |
| 159 | + Net: 0xfae4aad1, |
| 160 | + |
| 161 | + // Address encoding magics |
| 162 | + PubKeyHashAddrID: 111, |
| 163 | + ScriptHashAddrID: 196, |
| 164 | + PrivateKeyID: 239, |
| 165 | + |
| 166 | + // BIP32 hierarchical deterministic extended key magics |
| 167 | + HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with xprv |
| 168 | + HDPublicKeyID: [4]byte{0x04, 0x35, 0x87, 0xcf}, // starts with xpub |
| 169 | + |
| 170 | + // Human-readable part for Bech32 encoded segwit addresses, as defined in |
| 171 | + // BIP 173. |
| 172 | + Bech32HRPSegwit: "rlbc", |
| 173 | + |
| 174 | + // BIP44 coin type used in the hierarchical deterministic path for |
| 175 | + // address generation. |
| 176 | + HDCoinType: 0x8c, |
| 177 | +} |
0 commit comments