github.com/bchainhub/blockbook@v0.3.2/bchain/coins/pivx/pivxrpc.go (about) 1 package pivx 2 3 import ( 4 "blockbook/bchain" 5 "blockbook/bchain/coins/btc" 6 "encoding/json" 7 8 "github.com/golang/glog" 9 ) 10 11 // PivXRPC is an interface to JSON-RPC bitcoind service. 12 type PivXRPC struct { 13 *btc.BitcoinRPC 14 } 15 16 // NewPivXRPC returns new PivXRPC instance. 17 func NewPivXRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) { 18 b, err := btc.NewBitcoinRPC(config, pushHandler) 19 if err != nil { 20 return nil, err 21 } 22 23 s := &PivXRPC{ 24 b.(*btc.BitcoinRPC), 25 } 26 s.RPCMarshaler = btc.JSONMarshalerV1{} 27 s.ChainConfig.SupportsEstimateFee = true 28 s.ChainConfig.SupportsEstimateSmartFee = false 29 30 return s, nil 31 } 32 33 // Initialize initializes PivXRPC instance. 34 func (b *PivXRPC) Initialize() error { 35 ci, err := b.GetChainInfo() 36 if err != nil { 37 return err 38 } 39 chainName := ci.Chain 40 41 glog.Info("Chain name ", chainName) 42 params := GetChainParams(chainName) 43 44 // always create parser 45 b.Parser = NewPivXParser(params, b.ChainConfig) 46 47 // parameters for getInfo request 48 if params.Net == MainnetMagic { 49 b.Testnet = false 50 b.Network = "livenet" 51 } else { 52 b.Testnet = true 53 b.Network = "testnet" 54 } 55 56 glog.Info("rpc: block chain ", params.Name) 57 58 return nil 59 }