github.com/trezor/blockbook@v0.4.1-0.20240328132726-e9a08582ee2c/bchain/coins/vertcoin/vertcoinparser.go (about) 1 package vertcoin 2 3 import ( 4 "github.com/martinboehm/btcd/wire" 5 "github.com/martinboehm/btcutil/chaincfg" 6 "github.com/trezor/blockbook/bchain/coins/btc" 7 ) 8 9 // magic numbers 10 const ( 11 MainnetMagic wire.BitcoinNet = 0xdab5bffb 12 TestnetMagic wire.BitcoinNet = 0x74726576 // "vert" word 13 RegtestMagic wire.BitcoinNet = 0xdab5bffc 14 ) 15 16 // chain parameters 17 var ( 18 MainNetParams chaincfg.Params 19 TestNetParams chaincfg.Params 20 ) 21 22 func init() { 23 MainNetParams = chaincfg.MainNetParams 24 MainNetParams.Net = MainnetMagic 25 MainNetParams.PubKeyHashAddrID = []byte{71} 26 MainNetParams.ScriptHashAddrID = []byte{5} 27 MainNetParams.Bech32HRPSegwit = "vtc" 28 29 TestNetParams = chaincfg.TestNet3Params 30 TestNetParams.Net = TestnetMagic 31 TestNetParams.PubKeyHashAddrID = []byte{74} 32 TestNetParams.ScriptHashAddrID = []byte{196} 33 TestNetParams.Bech32HRPSegwit = "tvtc" 34 } 35 36 // VertcoinParser handle 37 type VertcoinParser struct { 38 *btc.BitcoinParser 39 } 40 41 // NewVertcoinParser returns new VertcoinParser instance 42 func NewVertcoinParser(params *chaincfg.Params, c *btc.Configuration) *VertcoinParser { 43 p := &VertcoinParser{BitcoinParser: btc.NewBitcoinParser(params, c)} 44 p.VSizeSupport = true 45 return p 46 } 47 48 // GetChainParams contains network parameters for the main Vertcoin network, 49 // and the test Vertcoin network 50 func GetChainParams(chain string) *chaincfg.Params { 51 if !chaincfg.IsRegistered(&MainNetParams) { 52 err := chaincfg.Register(&MainNetParams) 53 if err == nil { 54 err = chaincfg.Register(&TestNetParams) 55 } 56 if err != nil { 57 panic(err) 58 } 59 } 60 switch chain { 61 case "test": 62 return &TestNetParams 63 default: 64 return &MainNetParams 65 } 66 }