forked from trezor/blockbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pivxrpc.go
52 lines (40 loc) · 1.06 KB
/
pivxrpc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package pivx
import (
"blockbook/bchain"
"blockbook/bchain/coins/btc"
"encoding/json"
"github.com/golang/glog"
)
// PivXRPC is an interface to JSON-RPC bitcoind service.
type PivXRPC struct {
*btc.BitcoinRPC
}
// NewPivXRPC returns new PivXRPC instance.
func NewPivXRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
b, err := btc.NewBitcoinRPC(config, pushHandler)
if err != nil {
return nil, err
}
s := &PivXRPC{
b.(*btc.BitcoinRPC),
}
s.RPCMarshaler = btc.JSONMarshalerV1{}
s.ChainConfig.SupportsEstimateFee = true
s.ChainConfig.SupportsEstimateSmartFee = false
return s, nil
}
// Initialize initializes PivXRPC instance.
func (b *PivXRPC) 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 = NewPivXParser(params, b.ChainConfig)
b.Testnet = false
b.Network = "livenet"
glog.Info("rpc: block chain ", params.Name)
return nil
}