decred.org/dcrdex@v1.0.5/dex/networks/bch/params.go (about) 1 // This code is available on the terms of the project LICENSE.md file, 2 // also available online at https://blueoakcouncil.org 3 4 package bch 5 6 import ( 7 "decred.org/dcrdex/dex" 8 "decred.org/dcrdex/dex/networks/btc" 9 "github.com/btcsuite/btcd/chaincfg" 10 "github.com/btcsuite/btcd/chaincfg/chainhash" 11 ) 12 13 func mustHash(hash string) *chainhash.Hash { 14 h, err := chainhash.NewHashFromStr(hash) 15 if err != nil { 16 panic(err.Error()) 17 } 18 return h 19 } 20 21 var ( 22 UnitInfo = dex.UnitInfo{ 23 AtomicUnit: "Sats", 24 Conventional: dex.Denomination{ 25 Unit: "BCH", 26 ConversionFactor: 1e8, 27 }, 28 Alternatives: []dex.Denomination{ 29 { 30 Unit: "mBCH", 31 ConversionFactor: 1e5, 32 }, 33 { 34 Unit: "µBCH", 35 ConversionFactor: 1e2, 36 }, 37 }, 38 FeeRateDenom: "B", 39 } 40 // MainNetParams are the clone parameters for mainnet. 41 MainNetParams = btc.ReadCloneParams(&btc.CloneParams{ 42 Name: "mainnet", 43 PubKeyHashAddrID: 0x00, 44 ScriptHashAddrID: 0x05, 45 Bech32HRPSegwit: "bitcoincash", 46 CoinbaseMaturity: 100, 47 Net: 0xe8f3e1e3, 48 GenesisHash: mustHash("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"), // same as BTC! 49 }) 50 // TestNet4Params are the clone parameters for testnet4. 51 TestNet4Params = btc.ReadCloneParams(&btc.CloneParams{ 52 Name: "testnet4", 53 PubKeyHashAddrID: 0x6f, 54 ScriptHashAddrID: 0xc4, 55 Bech32HRPSegwit: "bchtest", 56 CoinbaseMaturity: 100, 57 Net: 0xafdab7e2, 58 GenesisHash: mustHash("000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"), 59 }) 60 // RegressionNetParams are the clone parameters for simnet. 61 RegressionNetParams = btc.ReadCloneParams(&btc.CloneParams{ 62 Name: "regtest", 63 PubKeyHashAddrID: 0x6f, 64 ScriptHashAddrID: 0xc4, 65 Bech32HRPSegwit: "bchreg", 66 CoinbaseMaturity: 100, 67 // Net is not the standard for BCH simnet, since they never changed it 68 // from the BTC value. The only place we currently use Net is in 69 // btcd/chaincfg.Register, where it is checked to prevent duplicate 70 // registration, so our only requirement is that it is unique. This one 71 // was just generated with a prng. 72 Net: 0xee87f733, 73 GenesisHash: mustHash("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"), // same as BTC! 74 }) 75 ) 76 77 func init() { 78 for _, params := range []*chaincfg.Params{MainNetParams, TestNet4Params, RegressionNetParams} { 79 err := chaincfg.Register(params) 80 if err != nil { 81 panic("failed to register bch parameters: " + err.Error()) 82 } 83 } 84 }