github.com/cerberus-wallet/blockbook@v0.3.2/bchain/coins/digibyte/digibyterpc.go (about)

     1  package digibyte
     2  
     3  import (
     4  	"blockbook/bchain"
     5  	"blockbook/bchain/coins/btc"
     6  	"encoding/json"
     7  
     8  	"github.com/golang/glog"
     9  )
    10  
    11  // DigiByteRPC is an interface to JSON-RPC bitcoind service.
    12  type DigiByteRPC struct {
    13  	*btc.BitcoinRPC
    14  }
    15  
    16  // NewDigiByteRPC returns new DigiByteRPC instance.
    17  func NewDigiByteRPC(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 := &DigiByteRPC{
    24  		b.(*btc.BitcoinRPC),
    25  	}
    26  	s.RPCMarshaler = btc.JSONMarshalerV2{}
    27  	s.ChainConfig.SupportsEstimateFee = false
    28  
    29  	return s, nil
    30  }
    31  
    32  // Initialize initializes DigiByteRPC instance.
    33  func (b *DigiByteRPC) Initialize() error {
    34  	ci, err := b.GetChainInfo()
    35  	if err != nil {
    36  		return err
    37  	}
    38  	chainName := ci.Chain
    39  
    40  	glog.Info("Chain name ", chainName)
    41  	params := GetChainParams(chainName)
    42  
    43  	// always create parser
    44  	b.Parser = NewDigiByteParser(params, b.ChainConfig)
    45  
    46  	b.Testnet = false
    47  	b.Network = "livenet"
    48  
    49  	glog.Info("rpc: block chain ", params.Name)
    50  
    51  	return nil
    52  }