github.com/cerberus-wallet/blockbook@v0.3.2/bchain/coins/omotenashicoin/omotenashicoinrpc.go (about) 1 package omotenashicoin 2 3 import ( 4 "blockbook/bchain" 5 "blockbook/bchain/coins/btc" 6 "encoding/json" 7 8 "github.com/golang/glog" 9 ) 10 11 // OmotenashiCoinRPC is an interface to JSON-RPC bitcoind service. 12 type OmotenashiCoinRPC struct { 13 *btc.BitcoinRPC 14 } 15 16 // NewOmotenashiCoinRPC returns new OmotenashiCoinRPC instance. 17 func NewOmotenashiCoinRPC(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 := &OmotenashiCoinRPC{ 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 OmotenashiCoinRPC instance. 34 func (b *OmotenashiCoinRPC) 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 = NewOmotenashiCoinParser(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 }