blockbook/bchain/coins/vertcoin/vertcoinrpc.go
Petr Kracík cb7c54ff21 Vertcoin (#13)
* Initial vertcoin backend commit

* Readme vertcoin ports

* Fix bin

* Vertcoin blockbook initial commit

* Vertcoin fix services port, faked magic due duplicity
2018-06-22 13:11:07 +02:00

62 lines
1.3 KiB
Go

package vertcoin
import (
"blockbook/bchain"
"blockbook/bchain/coins/btc"
"encoding/json"
"github.com/golang/glog"
)
// VertcoinRPC is an interface to JSON-RPC bitcoind service.
type VertcoinRPC struct {
*btc.BitcoinRPC
}
// NewVertcoinRPC returns new VertcoinRPC instance.
func NewVertcoinRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
b, err := btc.NewBitcoinRPC(config, pushHandler)
if err != nil {
return nil, err
}
s := &VertcoinRPC{
b.(*btc.BitcoinRPC),
}
s.RPCMarshaler = btc.JSONMarshalerV2{}
return s, nil
}
// Initialize initializes VertcoinRPC instance.
func (b *VertcoinRPC) Initialize() error {
chainName, err := b.GetChainInfoAndInitializeMempool(b)
if err != nil {
return err
}
glog.Info("Chain name ", chainName)
params := GetChainParams(chainName)
// always create parser
b.Parser = NewVertcoinParser(params, b.ChainConfig)
// parameters for getInfo request
if params.Net == MainnetMagic {
b.Testnet = false
b.Network = "livenet"
} else {
b.Testnet = true
b.Network = "testnet"
}
glog.Info("rpc: block chain ", params.Name)
return nil
}
// EstimateFee returns fee estimation.
func (b *VertcoinRPC) EstimateFee(blocks int) (float64, error) {
return b.EstimateSmartFee(blocks, true)
}