Merge branch 'dash'
This commit is contained in:
commit
259d447281
@ -70,16 +70,6 @@ type cmdGetBlock struct {
|
||||
} `json:"params"`
|
||||
}
|
||||
|
||||
type resGetBlockRaw struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result string `json:"result"`
|
||||
}
|
||||
|
||||
type resGetBlockThin struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result bchain.ThinBlock `json:"result"`
|
||||
}
|
||||
|
||||
// estimatesmartfee
|
||||
|
||||
type cmdEstimateSmartFee struct {
|
||||
@ -89,14 +79,6 @@ type cmdEstimateSmartFee struct {
|
||||
} `json:"params"`
|
||||
}
|
||||
|
||||
type resEstimateSmartFee struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result struct {
|
||||
Feerate float64 `json:"feerate"`
|
||||
Blocks int `json:"blocks"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
// GetBlock returns block with given hash.
|
||||
func (b *BCashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) {
|
||||
var err error
|
||||
@ -126,7 +108,7 @@ func (b *BCashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) {
|
||||
func (b *BCashRPC) GetBlockRaw(hash string) ([]byte, error) {
|
||||
glog.V(1).Info("rpc: getblock (verbose=0) ", hash)
|
||||
|
||||
res := resGetBlockRaw{}
|
||||
res := btc.ResGetBlockRaw{}
|
||||
req := cmdGetBlock{Method: "getblock"}
|
||||
req.Params.BlockHash = hash
|
||||
req.Params.Verbose = false
|
||||
@ -153,7 +135,7 @@ func (b *BCashRPC) GetBlockFull(hash string) (*bchain.Block, error) {
|
||||
func (b *BCashRPC) EstimateSmartFee(blocks int, conservative bool) (float64, error) {
|
||||
glog.V(1).Info("rpc: estimatesmartfee ", blocks)
|
||||
|
||||
res := resEstimateSmartFee{}
|
||||
res := btc.ResEstimateSmartFee{}
|
||||
req := cmdEstimateSmartFee{Method: "estimatesmartfee"}
|
||||
req.Params.Blocks = blocks
|
||||
// conservative param is omitted
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"blockbook/bchain/coins/bch"
|
||||
"blockbook/bchain/coins/btc"
|
||||
"blockbook/bchain/coins/btg"
|
||||
"blockbook/bchain/coins/dash"
|
||||
"blockbook/bchain/coins/eth"
|
||||
"blockbook/bchain/coins/zec"
|
||||
"blockbook/common"
|
||||
@ -32,6 +33,8 @@ func init() {
|
||||
blockChainFactories["Bcash"] = bch.NewBCashRPC
|
||||
blockChainFactories["Bcash Testnet"] = bch.NewBCashRPC
|
||||
blockChainFactories["Bgold"] = btg.NewBGoldRPC
|
||||
blockChainFactories["Dash"] = dash.NewDashRPC
|
||||
blockChainFactories["Dash Testnet"] = dash.NewDashRPC
|
||||
}
|
||||
|
||||
// GetCoinNameFromConfig gets coin name from config file
|
||||
|
||||
@ -20,18 +20,19 @@ import (
|
||||
|
||||
// BitcoinRPC is an interface to JSON-RPC bitcoind service.
|
||||
type BitcoinRPC struct {
|
||||
client http.Client
|
||||
rpcURL string
|
||||
user string
|
||||
password string
|
||||
Parser bchain.BlockChainParser
|
||||
Testnet bool
|
||||
Network string
|
||||
Mempool *bchain.UTXOMempool
|
||||
ParseBlocks bool
|
||||
pushHandler func(bchain.NotificationType)
|
||||
mq *bchain.MQ
|
||||
ChainConfig *Configuration
|
||||
client http.Client
|
||||
rpcURL string
|
||||
user string
|
||||
password string
|
||||
Parser bchain.BlockChainParser
|
||||
Testnet bool
|
||||
Network string
|
||||
Mempool *bchain.UTXOMempool
|
||||
ParseBlocks bool
|
||||
pushHandler func(bchain.NotificationType)
|
||||
mq *bchain.MQ
|
||||
ChainConfig *Configuration
|
||||
RPCMarshaler RPCMarshaler
|
||||
}
|
||||
|
||||
type Configuration struct {
|
||||
@ -76,13 +77,14 @@ func NewBitcoinRPC(config json.RawMessage, pushHandler func(bchain.NotificationT
|
||||
}
|
||||
|
||||
s := &BitcoinRPC{
|
||||
client: http.Client{Timeout: time.Duration(c.RPCTimeout) * time.Second, Transport: transport},
|
||||
rpcURL: c.RPCURL,
|
||||
user: c.RPCUser,
|
||||
password: c.RPCPass,
|
||||
ParseBlocks: c.Parse,
|
||||
ChainConfig: &c,
|
||||
pushHandler: pushHandler,
|
||||
client: http.Client{Timeout: time.Duration(c.RPCTimeout) * time.Second, Transport: transport},
|
||||
rpcURL: c.RPCURL,
|
||||
user: c.RPCUser,
|
||||
password: c.RPCPass,
|
||||
ParseBlocks: c.Parse,
|
||||
ChainConfig: &c,
|
||||
pushHandler: pushHandler,
|
||||
RPCMarshaler: JSONMarshalerV2{},
|
||||
}
|
||||
|
||||
return s, nil
|
||||
@ -165,47 +167,47 @@ func (b *BitcoinRPC) GetSubversion() string {
|
||||
|
||||
// getblockhash
|
||||
|
||||
type cmdGetBlockHash struct {
|
||||
type CmdGetBlockHash struct {
|
||||
Method string `json:"method"`
|
||||
Params struct {
|
||||
Height uint32 `json:"height"`
|
||||
} `json:"params"`
|
||||
}
|
||||
|
||||
type resGetBlockHash struct {
|
||||
type ResGetBlockHash struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result string `json:"result"`
|
||||
}
|
||||
|
||||
// getbestblockhash
|
||||
|
||||
type cmdGetBestBlockHash struct {
|
||||
type CmdGetBestBlockHash struct {
|
||||
Method string `json:"method"`
|
||||
}
|
||||
|
||||
type resGetBestBlockHash struct {
|
||||
type ResGetBestBlockHash struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result string `json:"result"`
|
||||
}
|
||||
|
||||
// getblockcount
|
||||
|
||||
type cmdGetBlockCount struct {
|
||||
type CmdGetBlockCount struct {
|
||||
Method string `json:"method"`
|
||||
}
|
||||
|
||||
type resGetBlockCount struct {
|
||||
type ResGetBlockCount struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result uint32 `json:"result"`
|
||||
}
|
||||
|
||||
// getblockchaininfo
|
||||
|
||||
type cmdGetBlockChainInfo struct {
|
||||
type CmdGetBlockChainInfo struct {
|
||||
Method string `json:"method"`
|
||||
}
|
||||
|
||||
type resGetBlockChainInfo struct {
|
||||
type ResGetBlockChainInfo struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result struct {
|
||||
Chain string `json:"chain"`
|
||||
@ -217,18 +219,18 @@ type resGetBlockChainInfo struct {
|
||||
|
||||
// getrawmempool
|
||||
|
||||
type cmdGetMempool struct {
|
||||
type CmdGetMempool struct {
|
||||
Method string `json:"method"`
|
||||
}
|
||||
|
||||
type resGetMempool struct {
|
||||
type ResGetMempool struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result []string `json:"result"`
|
||||
}
|
||||
|
||||
// getblockheader
|
||||
|
||||
type cmdGetBlockHeader struct {
|
||||
type CmdGetBlockHeader struct {
|
||||
Method string `json:"method"`
|
||||
Params struct {
|
||||
BlockHash string `json:"blockhash"`
|
||||
@ -236,14 +238,14 @@ type cmdGetBlockHeader struct {
|
||||
} `json:"params"`
|
||||
}
|
||||
|
||||
type resGetBlockHeader struct {
|
||||
type ResGetBlockHeader struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result bchain.BlockHeader `json:"result"`
|
||||
}
|
||||
|
||||
// getblock
|
||||
|
||||
type cmdGetBlock struct {
|
||||
type CmdGetBlock struct {
|
||||
Method string `json:"method"`
|
||||
Params struct {
|
||||
BlockHash string `json:"blockhash"`
|
||||
@ -251,24 +253,24 @@ type cmdGetBlock struct {
|
||||
} `json:"params"`
|
||||
}
|
||||
|
||||
type resGetBlockRaw struct {
|
||||
type ResGetBlockRaw struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result string `json:"result"`
|
||||
}
|
||||
|
||||
type resGetBlockThin struct {
|
||||
type ResGetBlockThin struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result bchain.ThinBlock `json:"result"`
|
||||
}
|
||||
|
||||
type resGetBlockFull struct {
|
||||
type ResGetBlockFull struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result bchain.Block `json:"result"`
|
||||
}
|
||||
|
||||
// getrawtransaction
|
||||
|
||||
type cmdGetRawTransaction struct {
|
||||
type CmdGetRawTransaction struct {
|
||||
Method string `json:"method"`
|
||||
Params struct {
|
||||
Txid string `json:"txid"`
|
||||
@ -276,19 +278,19 @@ type cmdGetRawTransaction struct {
|
||||
} `json:"params"`
|
||||
}
|
||||
|
||||
type resGetRawTransaction struct {
|
||||
type ResGetRawTransaction struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result json.RawMessage `json:"result"`
|
||||
}
|
||||
|
||||
type resGetRawTransactionNonverbose struct {
|
||||
type ResGetRawTransactionNonverbose struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result string `json:"result"`
|
||||
}
|
||||
|
||||
// estimatesmartfee
|
||||
|
||||
type cmdEstimateSmartFee struct {
|
||||
type CmdEstimateSmartFee struct {
|
||||
Method string `json:"method"`
|
||||
Params struct {
|
||||
ConfTarget int `json:"conf_target"`
|
||||
@ -296,7 +298,7 @@ type cmdEstimateSmartFee struct {
|
||||
} `json:"params"`
|
||||
}
|
||||
|
||||
type resEstimateSmartFee struct {
|
||||
type ResEstimateSmartFee struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result struct {
|
||||
Feerate float64 `json:"feerate"`
|
||||
@ -306,38 +308,38 @@ type resEstimateSmartFee struct {
|
||||
|
||||
// estimatefee
|
||||
|
||||
type cmdEstimateFee struct {
|
||||
type CmdEstimateFee struct {
|
||||
Method string `json:"method"`
|
||||
Params struct {
|
||||
Blocks int `json:"nblocks"`
|
||||
} `json:"params"`
|
||||
}
|
||||
|
||||
type resEstimateFee struct {
|
||||
type ResEstimateFee struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result float64 `json:"result"`
|
||||
}
|
||||
|
||||
// sendrawtransaction
|
||||
|
||||
type cmdSendRawTransaction struct {
|
||||
type CmdSendRawTransaction struct {
|
||||
Method string `json:"method"`
|
||||
Params []string `json:"params"`
|
||||
}
|
||||
|
||||
type resSendRawTransaction struct {
|
||||
type ResSendRawTransaction struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result string `json:"result"`
|
||||
}
|
||||
|
||||
// getmempoolentry
|
||||
|
||||
type cmdGetMempoolEntry struct {
|
||||
type CmdGetMempoolEntry struct {
|
||||
Method string `json:"method"`
|
||||
Params []string `json:"params"`
|
||||
}
|
||||
|
||||
type resGetMempoolEntry struct {
|
||||
type ResGetMempoolEntry struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result *bchain.MempoolEntry `json:"result"`
|
||||
}
|
||||
@ -347,8 +349,8 @@ func (b *BitcoinRPC) GetBestBlockHash() (string, error) {
|
||||
|
||||
glog.V(1).Info("rpc: getbestblockhash")
|
||||
|
||||
res := resGetBestBlockHash{}
|
||||
req := cmdGetBestBlockHash{Method: "getbestblockhash"}
|
||||
res := ResGetBestBlockHash{}
|
||||
req := CmdGetBestBlockHash{Method: "getbestblockhash"}
|
||||
err := b.Call(&req, &res)
|
||||
|
||||
if err != nil {
|
||||
@ -364,8 +366,8 @@ func (b *BitcoinRPC) GetBestBlockHash() (string, error) {
|
||||
func (b *BitcoinRPC) GetBestBlockHeight() (uint32, error) {
|
||||
glog.V(1).Info("rpc: getblockcount")
|
||||
|
||||
res := resGetBlockCount{}
|
||||
req := cmdGetBlockCount{Method: "getblockcount"}
|
||||
res := ResGetBlockCount{}
|
||||
req := CmdGetBlockCount{Method: "getblockcount"}
|
||||
err := b.Call(&req, &res)
|
||||
|
||||
if err != nil {
|
||||
@ -381,8 +383,8 @@ func (b *BitcoinRPC) GetBestBlockHeight() (uint32, error) {
|
||||
func (b *BitcoinRPC) GetBlockChainInfo() (string, error) {
|
||||
glog.V(1).Info("rpc: getblockchaininfo")
|
||||
|
||||
res := resGetBlockChainInfo{}
|
||||
req := cmdGetBlockChainInfo{Method: "getblockchaininfo"}
|
||||
res := ResGetBlockChainInfo{}
|
||||
req := CmdGetBlockChainInfo{Method: "getblockchaininfo"}
|
||||
err := b.Call(&req, &res)
|
||||
|
||||
if err != nil {
|
||||
@ -403,8 +405,8 @@ func isErrBlockNotFound(err *bchain.RPCError) bool {
|
||||
func (b *BitcoinRPC) GetBlockHash(height uint32) (string, error) {
|
||||
glog.V(1).Info("rpc: getblockhash ", height)
|
||||
|
||||
res := resGetBlockHash{}
|
||||
req := cmdGetBlockHash{Method: "getblockhash"}
|
||||
res := ResGetBlockHash{}
|
||||
req := CmdGetBlockHash{Method: "getblockhash"}
|
||||
req.Params.Height = height
|
||||
err := b.Call(&req, &res)
|
||||
|
||||
@ -424,8 +426,8 @@ func (b *BitcoinRPC) GetBlockHash(height uint32) (string, error) {
|
||||
func (b *BitcoinRPC) GetBlockHeader(hash string) (*bchain.BlockHeader, error) {
|
||||
glog.V(1).Info("rpc: getblockheader")
|
||||
|
||||
res := resGetBlockHeader{}
|
||||
req := cmdGetBlockHeader{Method: "getblockheader"}
|
||||
res := ResGetBlockHeader{}
|
||||
req := CmdGetBlockHeader{Method: "getblockheader"}
|
||||
req.Params.BlockHash = hash
|
||||
req.Params.Verbose = true
|
||||
err := b.Call(&req, &res)
|
||||
@ -494,8 +496,8 @@ func (b *BitcoinRPC) getBlockWithoutHeader(hash string, height uint32) (*bchain.
|
||||
func (b *BitcoinRPC) GetBlockRaw(hash string) ([]byte, error) {
|
||||
glog.V(1).Info("rpc: getblock (verbosity=0) ", hash)
|
||||
|
||||
res := resGetBlockRaw{}
|
||||
req := cmdGetBlock{Method: "getblock"}
|
||||
res := ResGetBlockRaw{}
|
||||
req := CmdGetBlock{Method: "getblock"}
|
||||
req.Params.BlockHash = hash
|
||||
req.Params.Verbosity = 0
|
||||
err := b.Call(&req, &res)
|
||||
@ -516,8 +518,8 @@ func (b *BitcoinRPC) GetBlockRaw(hash string) ([]byte, error) {
|
||||
func (b *BitcoinRPC) GetBlockFull(hash string) (*bchain.Block, error) {
|
||||
glog.V(1).Info("rpc: getblock (verbosity=2) ", hash)
|
||||
|
||||
res := resGetBlockFull{}
|
||||
req := cmdGetBlock{Method: "getblock"}
|
||||
res := ResGetBlockFull{}
|
||||
req := CmdGetBlock{Method: "getblock"}
|
||||
req.Params.BlockHash = hash
|
||||
req.Params.Verbosity = 2
|
||||
err := b.Call(&req, &res)
|
||||
@ -538,8 +540,8 @@ func (b *BitcoinRPC) GetBlockFull(hash string) (*bchain.Block, error) {
|
||||
func (b *BitcoinRPC) GetMempool() ([]string, error) {
|
||||
glog.V(1).Info("rpc: getrawmempool")
|
||||
|
||||
res := resGetMempool{}
|
||||
req := cmdGetMempool{Method: "getrawmempool"}
|
||||
res := ResGetMempool{}
|
||||
req := CmdGetMempool{Method: "getrawmempool"}
|
||||
err := b.Call(&req, &res)
|
||||
|
||||
if err != nil {
|
||||
@ -556,8 +558,8 @@ func (b *BitcoinRPC) GetMempool() ([]string, error) {
|
||||
func (b *BitcoinRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) {
|
||||
glog.V(1).Info("rpc: getrawtransaction nonverbose ", txid)
|
||||
|
||||
res := resGetRawTransactionNonverbose{}
|
||||
req := cmdGetRawTransaction{Method: "getrawtransaction"}
|
||||
res := ResGetRawTransactionNonverbose{}
|
||||
req := CmdGetRawTransaction{Method: "getrawtransaction"}
|
||||
req.Params.Txid = txid
|
||||
req.Params.Verbose = false
|
||||
err := b.Call(&req, &res)
|
||||
@ -582,8 +584,8 @@ func (b *BitcoinRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) {
|
||||
func (b *BitcoinRPC) GetTransaction(txid string) (*bchain.Tx, error) {
|
||||
glog.V(1).Info("rpc: getrawtransaction ", txid)
|
||||
|
||||
res := resGetRawTransaction{}
|
||||
req := cmdGetRawTransaction{Method: "getrawtransaction"}
|
||||
res := ResGetRawTransaction{}
|
||||
req := CmdGetRawTransaction{Method: "getrawtransaction"}
|
||||
req.Params.Txid = txid
|
||||
req.Params.Verbose = true
|
||||
err := b.Call(&req, &res)
|
||||
@ -617,8 +619,8 @@ func (b *BitcoinRPC) GetMempoolTransactions(address string) ([]string, error) {
|
||||
func (b *BitcoinRPC) EstimateSmartFee(blocks int, conservative bool) (float64, error) {
|
||||
glog.V(1).Info("rpc: estimatesmartfee ", blocks)
|
||||
|
||||
res := resEstimateSmartFee{}
|
||||
req := cmdEstimateSmartFee{Method: "estimatesmartfee"}
|
||||
res := ResEstimateSmartFee{}
|
||||
req := CmdEstimateSmartFee{Method: "estimatesmartfee"}
|
||||
req.Params.ConfTarget = blocks
|
||||
if conservative {
|
||||
req.Params.EstimateMode = "CONSERVATIVE"
|
||||
@ -640,8 +642,8 @@ func (b *BitcoinRPC) EstimateSmartFee(blocks int, conservative bool) (float64, e
|
||||
func (b *BitcoinRPC) EstimateFee(blocks int) (float64, error) {
|
||||
glog.V(1).Info("rpc: estimatefee ", blocks)
|
||||
|
||||
res := resEstimateFee{}
|
||||
req := cmdEstimateFee{Method: "estimatefee"}
|
||||
res := ResEstimateFee{}
|
||||
req := CmdEstimateFee{Method: "estimatefee"}
|
||||
req.Params.Blocks = blocks
|
||||
err := b.Call(&req, &res)
|
||||
|
||||
@ -658,8 +660,8 @@ func (b *BitcoinRPC) EstimateFee(blocks int) (float64, error) {
|
||||
func (b *BitcoinRPC) SendRawTransaction(tx string) (string, error) {
|
||||
glog.V(1).Info("rpc: sendrawtransaction")
|
||||
|
||||
res := resSendRawTransaction{}
|
||||
req := cmdSendRawTransaction{Method: "sendrawtransaction"}
|
||||
res := ResSendRawTransaction{}
|
||||
req := CmdSendRawTransaction{Method: "sendrawtransaction"}
|
||||
req.Params = []string{tx}
|
||||
err := b.Call(&req, &res)
|
||||
|
||||
@ -676,8 +678,8 @@ func (b *BitcoinRPC) SendRawTransaction(tx string) (string, error) {
|
||||
func (b *BitcoinRPC) GetMempoolEntry(txid string) (*bchain.MempoolEntry, error) {
|
||||
glog.V(1).Info("rpc: getmempoolentry")
|
||||
|
||||
res := resGetMempoolEntry{}
|
||||
req := cmdGetMempoolEntry{
|
||||
res := ResGetMempoolEntry{}
|
||||
req := CmdGetMempoolEntry{
|
||||
Method: "getmempoolentry",
|
||||
Params: []string{txid},
|
||||
}
|
||||
@ -693,7 +695,7 @@ func (b *BitcoinRPC) GetMempoolEntry(txid string) (*bchain.MempoolEntry, error)
|
||||
}
|
||||
|
||||
func (b *BitcoinRPC) Call(req interface{}, res interface{}) error {
|
||||
httpData, err := json.Marshal(req)
|
||||
httpData, err := b.RPCMarshaler.Marshal(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
79
bchain/coins/btc/codec.go
Normal file
79
bchain/coins/btc/codec.go
Normal file
@ -0,0 +1,79 @@
|
||||
package btc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type RPCMarshaler interface {
|
||||
Marshal(v interface{}) ([]byte, error)
|
||||
}
|
||||
|
||||
type JSONMarshalerV2 struct{}
|
||||
|
||||
func (JSONMarshalerV2) Marshal(v interface{}) ([]byte, error) {
|
||||
d, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
|
||||
var InvalidValue = errors.New("Invalid value to marshal")
|
||||
|
||||
type JSONMarshalerV1 struct{}
|
||||
|
||||
func (JSONMarshalerV1) Marshal(v interface{}) ([]byte, error) {
|
||||
u := cmdUntypedParams{}
|
||||
|
||||
switch v := v.(type) {
|
||||
case *CmdGetBlock:
|
||||
var t bool
|
||||
if v.Params.Verbosity > 0 {
|
||||
t = true
|
||||
}
|
||||
u.Method = v.Method
|
||||
u.Params = append(u.Params, v.Params.BlockHash)
|
||||
u.Params = append(u.Params, t)
|
||||
case *CmdGetRawTransaction:
|
||||
var n int
|
||||
if v.Params.Verbose {
|
||||
n = 1
|
||||
}
|
||||
u.Method = v.Method
|
||||
u.Params = append(u.Params, v.Params.Txid)
|
||||
u.Params = append(u.Params, n)
|
||||
default:
|
||||
{
|
||||
v := reflect.ValueOf(v).Elem()
|
||||
|
||||
f := v.FieldByName("Method")
|
||||
if !f.IsValid() || f.Kind() != reflect.String {
|
||||
return nil, InvalidValue
|
||||
}
|
||||
u.Method = f.String()
|
||||
|
||||
f = v.FieldByName("Params")
|
||||
if f.IsValid() {
|
||||
arr := make([]interface{}, f.NumField())
|
||||
for i := 0; i < f.NumField(); i++ {
|
||||
arr[i] = f.Field(i).Interface()
|
||||
}
|
||||
u.Params = arr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d, err := json.Marshal(u)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return d, nil
|
||||
}
|
||||
|
||||
type cmdUntypedParams struct {
|
||||
Method string `json:"method"`
|
||||
Params []interface{} `json:"params,omitempty"`
|
||||
}
|
||||
@ -53,7 +53,7 @@ type BGoldParser struct {
|
||||
*btc.BitcoinParser
|
||||
}
|
||||
|
||||
// NewBCashParser returns new BGoldParser instance
|
||||
// NewBGoldParser returns new BGoldParser instance
|
||||
func NewBGoldParser(params *chaincfg.Params, c *btc.Configuration) *BGoldParser {
|
||||
return &BGoldParser{BitcoinParser: btc.NewBitcoinParser(params, c)}
|
||||
}
|
||||
|
||||
78
bchain/coins/dash/dashparser.go
Normal file
78
bchain/coins/dash/dashparser.go
Normal file
@ -0,0 +1,78 @@
|
||||
package dash
|
||||
|
||||
import (
|
||||
"blockbook/bchain/coins/btc"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
||||
const (
|
||||
MainnetMagic wire.BitcoinNet = 0xbd6b0cbf
|
||||
TestnetMagic wire.BitcoinNet = 0xffcae2ce
|
||||
RegtestMagic wire.BitcoinNet = 0xdcb7c1fc
|
||||
)
|
||||
|
||||
var (
|
||||
MainNetParams chaincfg.Params
|
||||
TestNetParams chaincfg.Params
|
||||
RegtestParams chaincfg.Params
|
||||
)
|
||||
|
||||
func init() {
|
||||
MainNetParams = chaincfg.MainNetParams
|
||||
MainNetParams.Net = MainnetMagic
|
||||
|
||||
// Address encoding magics
|
||||
MainNetParams.PubKeyHashAddrID = 76 // base58 prefix: X
|
||||
MainNetParams.ScriptHashAddrID = 16 // base58 prefix: 7
|
||||
|
||||
TestNetParams = chaincfg.TestNet3Params
|
||||
TestNetParams.Net = TestnetMagic
|
||||
|
||||
// Address encoding magics
|
||||
TestNetParams.PubKeyHashAddrID = 140 // base58 prefix: y
|
||||
TestNetParams.ScriptHashAddrID = 19 // base58 prefix: 8 or 9
|
||||
|
||||
RegtestParams = chaincfg.RegressionNetParams
|
||||
RegtestParams.Net = RegtestMagic
|
||||
|
||||
// Address encoding magics
|
||||
RegtestParams.PubKeyHashAddrID = 140 // base58 prefix: y
|
||||
RegtestParams.ScriptHashAddrID = 19 // base58 prefix: 8 or 9
|
||||
|
||||
err := chaincfg.Register(&MainNetParams)
|
||||
if err == nil {
|
||||
err = chaincfg.Register(&TestNetParams)
|
||||
}
|
||||
if err == nil {
|
||||
err = chaincfg.Register(&RegtestParams)
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// DashParser handle
|
||||
type DashParser struct {
|
||||
*btc.BitcoinParser
|
||||
}
|
||||
|
||||
// NewDashParser returns new DashParser instance
|
||||
func NewDashParser(params *chaincfg.Params, c *btc.Configuration) *DashParser {
|
||||
return &DashParser{BitcoinParser: btc.NewBitcoinParser(params, c)}
|
||||
}
|
||||
|
||||
// GetChainParams contains network parameters for the main Dash network,
|
||||
// the regression test Dash network, the test Dash network and
|
||||
// the simulation test Dash network, in this order
|
||||
func GetChainParams(chain string) *chaincfg.Params {
|
||||
switch chain {
|
||||
case "test":
|
||||
return &TestNetParams
|
||||
case "regtest":
|
||||
return &RegtestParams
|
||||
default:
|
||||
return &MainNetParams
|
||||
}
|
||||
}
|
||||
55
bchain/coins/dash/dashrpc.go
Normal file
55
bchain/coins/dash/dashrpc.go
Normal file
@ -0,0 +1,55 @@
|
||||
package dash
|
||||
|
||||
import (
|
||||
"blockbook/bchain"
|
||||
"blockbook/bchain/coins/btc"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
// DashRPC is an interface to JSON-RPC bitcoind service.
|
||||
type DashRPC struct {
|
||||
*btc.BitcoinRPC
|
||||
}
|
||||
|
||||
// NewDashRPC returns new DashRPC instance.
|
||||
func NewDashRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
|
||||
b, err := btc.NewBitcoinRPC(config, pushHandler)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s := &DashRPC{
|
||||
b.(*btc.BitcoinRPC),
|
||||
}
|
||||
s.RPCMarshaler = btc.JSONMarshalerV1{}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// Initialize initializes DashRPC instance.
|
||||
func (b *DashRPC) Initialize() error {
|
||||
chainName, err := b.GetChainInfoAndInitializeMempool(b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params := GetChainParams(chainName)
|
||||
|
||||
// always create parser
|
||||
b.Parser = NewDashParser(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
|
||||
}
|
||||
@ -21,6 +21,7 @@ func NewZCashRPC(config json.RawMessage, pushHandler func(bchain.NotificationTyp
|
||||
z := &ZCashRPC{
|
||||
BitcoinRPC: b.(*btc.BitcoinRPC),
|
||||
}
|
||||
z.RPCMarshaler = btc.JSONMarshalerV1{}
|
||||
return z, nil
|
||||
}
|
||||
|
||||
@ -49,46 +50,6 @@ func (z *ZCashRPC) Initialize() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type untypedArrayParams struct {
|
||||
Method string `json:"method"`
|
||||
Params []interface{} `json:"params"`
|
||||
}
|
||||
|
||||
// getblockhash
|
||||
|
||||
type resGetBlockHash struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result string `json:"result"`
|
||||
}
|
||||
|
||||
// getblock
|
||||
|
||||
type resGetBlockThin struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result bchain.ThinBlock `json:"result"`
|
||||
}
|
||||
|
||||
// getrawtransaction
|
||||
|
||||
type resGetRawTransaction struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result json.RawMessage `json:"result"`
|
||||
}
|
||||
|
||||
// getblockheader
|
||||
|
||||
type resGetBlockHeader struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result bchain.BlockHeader `json:"result"`
|
||||
}
|
||||
|
||||
// estimatefee
|
||||
|
||||
type resEstimateFee struct {
|
||||
Error *bchain.RPCError `json:"error"`
|
||||
Result float64 `json:"result"`
|
||||
}
|
||||
|
||||
// GetBlock returns block with given hash.
|
||||
func (z *ZCashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) {
|
||||
var err error
|
||||
@ -101,10 +62,10 @@ func (z *ZCashRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) {
|
||||
|
||||
glog.V(1).Info("rpc: getblock (verbosity=1) ", hash)
|
||||
|
||||
res := resGetBlockThin{}
|
||||
req := untypedArrayParams{Method: "getblock"}
|
||||
req.Params = append(req.Params, hash)
|
||||
req.Params = append(req.Params, true)
|
||||
res := btc.ResGetBlockThin{}
|
||||
req := btc.CmdGetBlock{Method: "getblock"}
|
||||
req.Params.BlockHash = hash
|
||||
req.Params.Verbosity = 1
|
||||
err = z.Call(&req, &res)
|
||||
|
||||
if err != nil {
|
||||
@ -157,10 +118,10 @@ func (z *ZCashRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) {
|
||||
func (z *ZCashRPC) GetTransaction(txid string) (*bchain.Tx, error) {
|
||||
glog.V(1).Info("rpc: getrawtransaction ", txid)
|
||||
|
||||
res := resGetRawTransaction{}
|
||||
req := untypedArrayParams{Method: "getrawtransaction"}
|
||||
req.Params = append(req.Params, txid)
|
||||
req.Params = append(req.Params, 1)
|
||||
res := btc.ResGetRawTransaction{}
|
||||
req := btc.CmdGetRawTransaction{Method: "getrawtransaction"}
|
||||
req.Params.Txid = txid
|
||||
req.Params.Verbose = true
|
||||
err := z.Call(&req, &res)
|
||||
|
||||
if err != nil {
|
||||
@ -176,76 +137,12 @@ func (z *ZCashRPC) GetTransaction(txid string) (*bchain.Tx, error) {
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
// GetBlockHash returns hash of block in best-block-chain at given height.
|
||||
func (z *ZCashRPC) GetBlockHash(height uint32) (string, error) {
|
||||
glog.V(1).Info("rpc: getblockhash ", height)
|
||||
|
||||
res := resGetBlockHash{}
|
||||
req := untypedArrayParams{Method: "getblockhash"}
|
||||
req.Params = append(req.Params, height)
|
||||
err := z.Call(&req, &res)
|
||||
|
||||
if err != nil {
|
||||
return "", errors.Annotatef(err, "height %v", height)
|
||||
}
|
||||
if res.Error != nil {
|
||||
if isErrBlockNotFound(res.Error) {
|
||||
return "", bchain.ErrBlockNotFound
|
||||
}
|
||||
return "", errors.Annotatef(res.Error, "height %v", height)
|
||||
}
|
||||
return res.Result, nil
|
||||
}
|
||||
|
||||
// GetBlockHeader returns header of block with given hash.
|
||||
func (z *ZCashRPC) GetBlockHeader(hash string) (*bchain.BlockHeader, error) {
|
||||
glog.V(1).Info("rpc: getblockheader")
|
||||
|
||||
res := resGetBlockHeader{}
|
||||
req := untypedArrayParams{Method: "getblockheader"}
|
||||
req.Params = append(req.Params, hash)
|
||||
req.Params = append(req.Params, true)
|
||||
err := z.Call(&req, &res)
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.Annotatef(err, "hash %v", hash)
|
||||
}
|
||||
if res.Error != nil {
|
||||
if isErrBlockNotFound(res.Error) {
|
||||
return nil, bchain.ErrBlockNotFound
|
||||
}
|
||||
return nil, errors.Annotatef(res.Error, "hash %v", hash)
|
||||
}
|
||||
return &res.Result, nil
|
||||
}
|
||||
|
||||
// EstimateSmartFee returns fee estimation.
|
||||
func (z *ZCashRPC) EstimateSmartFee(blocks int, conservative bool) (float64, error) {
|
||||
glog.V(1).Info("rpc: estimatesmartfee")
|
||||
|
||||
return z.estimateFee(blocks)
|
||||
}
|
||||
|
||||
// EstimateFee returns fee estimation.
|
||||
func (z *ZCashRPC) EstimateFee(blocks int) (float64, error) {
|
||||
glog.V(1).Info("rpc: estimatefee ", blocks)
|
||||
|
||||
return z.estimateFee(blocks)
|
||||
}
|
||||
|
||||
func (z *ZCashRPC) estimateFee(blocks int) (float64, error) {
|
||||
res := resEstimateFee{}
|
||||
req := untypedArrayParams{Method: "estimatefee"}
|
||||
req.Params = append(req.Params, blocks)
|
||||
err := z.Call(&req, &res)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if res.Error != nil {
|
||||
return 0, res.Error
|
||||
}
|
||||
return res.Result, nil
|
||||
// return z.estimateFee(blocks)
|
||||
return z.EstimateFee(blocks)
|
||||
}
|
||||
|
||||
// GetMempoolEntry returns mempool data for given transaction
|
||||
|
||||
1
build/deb/debian/blockbook-dash-testnet.conffiles
Normal file
1
build/deb/debian/blockbook-dash-testnet.conffiles
Normal file
@ -0,0 +1 @@
|
||||
/opt/coins/blockbook/dash_testnet/config/blockchaincfg.json
|
||||
2
build/deb/debian/blockbook-dash-testnet.cron.daily
Normal file
2
build/deb/debian/blockbook-dash-testnet.cron.daily
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
/opt/coins/blockbook/dash_testnet/bin/logrotate.sh
|
||||
2
build/deb/debian/blockbook-dash-testnet.dirs
Normal file
2
build/deb/debian/blockbook-dash-testnet.dirs
Normal file
@ -0,0 +1,2 @@
|
||||
/opt/coins/data/dash_testnet/blockbook
|
||||
/opt/coins/blockbook/dash_testnet/logs
|
||||
6
build/deb/debian/blockbook-dash-testnet.install
Executable file
6
build/deb/debian/blockbook-dash-testnet.install
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/dh-exec
|
||||
blockbook /opt/coins/blockbook/dash_testnet/bin
|
||||
cert /opt/coins/blockbook/dash_testnet
|
||||
static /opt/coins/blockbook/dash_testnet
|
||||
configs/dash_testnet.json => /opt/coins/blockbook/dash_testnet/config/blockchaincfg.json
|
||||
logrotate.sh /opt/coins/blockbook/dash_testnet/bin
|
||||
2
build/deb/debian/blockbook-dash-testnet.links
Normal file
2
build/deb/debian/blockbook-dash-testnet.links
Normal file
@ -0,0 +1,2 @@
|
||||
/opt/coins/blockbook/dash_testnet/cert/testcert.crt /opt/coins/blockbook/dash_testnet/cert/blockbook.crt
|
||||
/opt/coins/blockbook/dash_testnet/cert/testcert.key /opt/coins/blockbook/dash_testnet/cert/blockbook.key
|
||||
23
build/deb/debian/blockbook-dash-testnet.postinst
Normal file
23
build/deb/debian/blockbook-dash-testnet.postinst
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
|
||||
configure)
|
||||
if ! id -u blockbook-dash &> /dev/null
|
||||
then
|
||||
useradd --system -M -U blockbook-dash -s /bin/false
|
||||
fi
|
||||
|
||||
for dir in /opt/coins/data/dash_testnet/blockbook /opt/coins/blockbook/dash_testnet/logs
|
||||
do
|
||||
if [ "$(stat -c '%U' $dir)" != "blockbook-dash" ]
|
||||
then
|
||||
chown -R blockbook-dash:blockbook-dash $dir
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
#DEBHELPER#
|
||||
43
build/deb/debian/blockbook-dash-testnet.service
Normal file
43
build/deb/debian/blockbook-dash-testnet.service
Normal file
@ -0,0 +1,43 @@
|
||||
# It is not recommended to modify this file in-place, because it will
|
||||
# be overwritten during package upgrades. If you want to add further
|
||||
# options or overwrite existing ones then use
|
||||
# $ systemctl edit blockbook-dash-testnet.service
|
||||
# See "man systemd.service" for details.
|
||||
|
||||
[Unit]
|
||||
Description=Blockbook daemon (Dash testnet)
|
||||
After=network.target
|
||||
Wants=dash-testnet.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/opt/coins/blockbook/dash_testnet/bin/blockbook -blockchaincfg=/opt/coins/blockbook/dash_testnet/config/blockchaincfg.json -datadir=/opt/coins/data/dash_testnet/blockbook/db -sync -httpserver=:19033 -socketio=:19133 -certfile=/opt/coins/blockbook/dash_testnet/cert/blockbook -explorer=https://dash-explorer.trezor.io/ -log_dir=/opt/coins/blockbook/dash_testnet/logs
|
||||
User=blockbook-dash
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
WorkingDirectory=/opt/coins/blockbook/dash_testnet
|
||||
|
||||
# Resource limits
|
||||
LimitNOFILE=500000
|
||||
|
||||
# Hardening measures
|
||||
####################
|
||||
|
||||
# Provide a private /tmp and /var/tmp.
|
||||
PrivateTmp=true
|
||||
|
||||
# Mount /usr, /boot/ and /etc read-only for the process.
|
||||
ProtectSystem=full
|
||||
|
||||
# Disallow the process and all of its children to gain
|
||||
# new privileges through execve().
|
||||
NoNewPrivileges=true
|
||||
|
||||
# Use a new /dev namespace only populated with API pseudo devices
|
||||
# such as /dev/null, /dev/zero and /dev/random.
|
||||
PrivateDevices=true
|
||||
|
||||
# Deny the creation of writable and executable memory mappings.
|
||||
MemoryDenyWriteExecute=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
1
build/deb/debian/blockbook-dash.conffiles
Normal file
1
build/deb/debian/blockbook-dash.conffiles
Normal file
@ -0,0 +1 @@
|
||||
/opt/coins/blockbook/dash/config/blockchaincfg.json
|
||||
2
build/deb/debian/blockbook-dash.cron.daily
Normal file
2
build/deb/debian/blockbook-dash.cron.daily
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
/opt/coins/blockbook/dash/bin/logrotate.sh
|
||||
2
build/deb/debian/blockbook-dash.dirs
Normal file
2
build/deb/debian/blockbook-dash.dirs
Normal file
@ -0,0 +1,2 @@
|
||||
/opt/coins/data/dash/blockbook
|
||||
/opt/coins/blockbook/dash/logs
|
||||
6
build/deb/debian/blockbook-dash.install
Executable file
6
build/deb/debian/blockbook-dash.install
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/dh-exec
|
||||
blockbook /opt/coins/blockbook/dash/bin
|
||||
cert /opt/coins/blockbook/dash
|
||||
static /opt/coins/blockbook/dash
|
||||
configs/dash.json => /opt/coins/blockbook/dash/config/blockchaincfg.json
|
||||
logrotate.sh /opt/coins/blockbook/dash/bin
|
||||
2
build/deb/debian/blockbook-dash.links
Normal file
2
build/deb/debian/blockbook-dash.links
Normal file
@ -0,0 +1,2 @@
|
||||
/opt/coins/blockbook/dash/cert/testcert.crt /opt/coins/blockbook/dash/cert/blockbook.crt
|
||||
/opt/coins/blockbook/dash/cert/testcert.key /opt/coins/blockbook/dash/cert/blockbook.key
|
||||
23
build/deb/debian/blockbook-dash.postinst
Normal file
23
build/deb/debian/blockbook-dash.postinst
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
|
||||
configure)
|
||||
if ! id -u blockbook-dash &> /dev/null
|
||||
then
|
||||
useradd --system -M -U blockbook-dash -s /bin/false
|
||||
fi
|
||||
|
||||
for dir in /opt/coins/data/dash/blockbook /opt/coins/blockbook/dash/logs
|
||||
do
|
||||
if [ "$(stat -c '%U' $dir)" != "blockbook-dash" ]
|
||||
then
|
||||
chown -R blockbook-dash:blockbook-dash $dir
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
#DEBHELPER#
|
||||
43
build/deb/debian/blockbook-dash.service
Normal file
43
build/deb/debian/blockbook-dash.service
Normal file
@ -0,0 +1,43 @@
|
||||
# It is not recommended to modify this file in-place, because it will
|
||||
# be overwritten during package upgrades. If you want to add further
|
||||
# options or overwrite existing ones then use
|
||||
# $ systemctl edit blockbook-dash.service
|
||||
# See "man systemd.service" for details.
|
||||
|
||||
[Unit]
|
||||
Description=Blockbook daemon (Dash mainnet)
|
||||
After=network.target
|
||||
Wants=dash.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/opt/coins/blockbook/dash/bin/blockbook -blockchaincfg=/opt/coins/blockbook/dash/config/blockchaincfg.json -datadir=/opt/coins/data/dash/blockbook/db -sync -httpserver=:9033 -socketio=:9133 -certfile=/opt/coins/blockbook/dash/cert/blockbook -explorer=https://dash-explorer.trezor.io/ -log_dir=/opt/coins/blockbook/dash/logs
|
||||
User=blockbook-dash
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
WorkingDirectory=/opt/coins/blockbook/dash
|
||||
|
||||
# Resource limits
|
||||
LimitNOFILE=500000
|
||||
|
||||
# Hardening measures
|
||||
####################
|
||||
|
||||
# Provide a private /tmp and /var/tmp.
|
||||
PrivateTmp=true
|
||||
|
||||
# Mount /usr, /boot/ and /etc read-only for the process.
|
||||
ProtectSystem=full
|
||||
|
||||
# Disallow the process and all of its children to gain
|
||||
# new privileges through execve().
|
||||
NoNewPrivileges=true
|
||||
|
||||
# Use a new /dev namespace only populated with API pseudo devices
|
||||
# such as /dev/null, /dev/zero and /dev/random.
|
||||
PrivateDevices=true
|
||||
|
||||
# Deny the creation of writable and executable memory mappings.
|
||||
MemoryDenyWriteExecute=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@ -44,3 +44,13 @@ Package: blockbook-bgold
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, bgold
|
||||
Description: Satoshilabs blockbook server (Bitcoin Gold mainnet)
|
||||
|
||||
Package: blockbook-dash
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, dash
|
||||
Description: Satoshilabs blockbook server (Dash mainnet)
|
||||
|
||||
Package: blockbook-dash-testnet
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, dash-testnet
|
||||
Description: Satoshilabs blockbook server (Dash testnet)
|
||||
|
||||
13
configs/dash.json
Normal file
13
configs/dash.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"coin_name": "Dash",
|
||||
"rpcURL": "http://127.0.0.1:8033",
|
||||
"rpcUser": "rpc",
|
||||
"rpcPass": "rpc",
|
||||
"rpcTimeout": 25,
|
||||
"parse": true,
|
||||
"zeroMQBinding": "tcp://127.0.0.1:38333",
|
||||
"subversion": "/Dash Core:0.12.2.3/",
|
||||
"mempoolWorkers": 8,
|
||||
"mempoolSubWorkers": 2,
|
||||
"blockAddressesToKeep": 300
|
||||
}
|
||||
13
configs/dash_testnet.json
Normal file
13
configs/dash_testnet.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"coin_name": "Dash Testnet",
|
||||
"rpcURL": "http://localhost:18033",
|
||||
"rpcUser": "rpc",
|
||||
"rpcPass": "rpc",
|
||||
"rpcTimeout": 25,
|
||||
"parse": true,
|
||||
"zeroMQBinding": "tcp://127.0.0.1:48333",
|
||||
"subversion": "/Dash Core:0.12.2.3/",
|
||||
"mempoolWorkers": 8,
|
||||
"mempoolSubWorkers": 2,
|
||||
"blockAddressesToKeep": 300
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
TARGETS = bitcoin zcash bcash ethereum bgold
|
||||
TARGETS = bitcoin zcash bcash ethereum bgold dash
|
||||
IMAGE = blockbook-backend-build-deb
|
||||
NO_CACHE = false
|
||||
|
||||
|
||||
14
contrib/backends/dash/Makefile
Normal file
14
contrib/backends/dash/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
DASH_VERSION := 0.12.2
|
||||
DASH_BUILD := .3
|
||||
|
||||
all:
|
||||
wget https://github.com/dashpay/dash/releases/download/v${DASH_VERSION}${DASH_BUILD}/dashcore-${DASH_VERSION}${DASH_BUILD}-linux64.tar.gz
|
||||
tar -xf dashcore-${DASH_VERSION}${DASH_BUILD}-linux64.tar.gz
|
||||
mv dashcore-${DASH_VERSION} dash
|
||||
rm dash/bin/dash-qt
|
||||
rm dash/bin/test_dash
|
||||
|
||||
|
||||
clean:
|
||||
rm -rf dash
|
||||
rm -f dashcore-${DASH_VERSION}${DASH_BUILD}-linux64.tar.gz
|
||||
20
contrib/backends/dash/dash.conf
Normal file
20
contrib/backends/dash/dash.conf
Normal file
@ -0,0 +1,20 @@
|
||||
daemon=1
|
||||
server=1
|
||||
nolisten=1
|
||||
rpcuser=rpc
|
||||
rpcpassword=rpc
|
||||
rpcport=8033
|
||||
txindex=1
|
||||
addressindex=1
|
||||
timestampindex=1
|
||||
spentindex=1
|
||||
|
||||
zmqpubhashtx=tcp://127.0.0.1:38333
|
||||
zmqpubhashblock=tcp://127.0.0.1:38333
|
||||
zmqpubrawblock=tcp://127.0.0.1:38333
|
||||
zmqpubrawtx=tcp://127.0.0.1:38333
|
||||
|
||||
mempoolexpiry=72
|
||||
rpcworkqueue=1100
|
||||
maxmempool=2000
|
||||
dbcache=1000
|
||||
20
contrib/backends/dash/dash_testnet.conf
Normal file
20
contrib/backends/dash/dash_testnet.conf
Normal file
@ -0,0 +1,20 @@
|
||||
daemon=1
|
||||
server=1
|
||||
testnet=1
|
||||
nolisten=1
|
||||
rpcuser=rpc
|
||||
rpcpassword=rpc
|
||||
rpcport=18033
|
||||
txindex=1
|
||||
addressindex=1
|
||||
timestampindex=1
|
||||
spentindex=1
|
||||
|
||||
zmqpubhashtx=tcp://127.0.0.1:48333
|
||||
zmqpubhashblock=tcp://127.0.0.1:48333
|
||||
zmqpubrawblock=tcp://127.0.0.1:48333
|
||||
zmqpubrawtx=tcp://127.0.0.1:48333
|
||||
|
||||
rpcworkqueue=1100
|
||||
maxmempool=2000
|
||||
dbcache=1000
|
||||
5
contrib/backends/dash/debian/changelog
Normal file
5
contrib/backends/dash/debian/changelog
Normal file
@ -0,0 +1,5 @@
|
||||
dash (0.12.2-satoshilabs1) unstable; urgency=medium
|
||||
|
||||
* Initial build
|
||||
|
||||
-- Jakub Matys <jakub.matys@satoshilabs.com> Fri, 08 Jun 2018 11:27:03 +0200
|
||||
1
contrib/backends/dash/debian/compat
Normal file
1
contrib/backends/dash/debian/compat
Normal file
@ -0,0 +1 @@
|
||||
9
|
||||
16
contrib/backends/dash/debian/control
Normal file
16
contrib/backends/dash/debian/control
Normal file
@ -0,0 +1,16 @@
|
||||
Source: dash
|
||||
Section: satoshilabs
|
||||
Priority: optional
|
||||
Maintainer: jakub.matys@satoshilabs.com
|
||||
Build-Depends: debhelper, wget, tar, gzip, make, dh-systemd, dh-exec
|
||||
Standards-Version: 3.9.5
|
||||
|
||||
Package: dash
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate
|
||||
Description: Satoshilabs packaged dash server
|
||||
|
||||
Package: dash-testnet
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate
|
||||
Description: Satoshilabs packaged dash server
|
||||
1
contrib/backends/dash/debian/dash-testnet.conffiles
Normal file
1
contrib/backends/dash/debian/dash-testnet.conffiles
Normal file
@ -0,0 +1 @@
|
||||
/opt/coins/nodes/dash_testnet/dash_testnet.conf
|
||||
1
contrib/backends/dash/debian/dash-testnet.dirs
Normal file
1
contrib/backends/dash/debian/dash-testnet.dirs
Normal file
@ -0,0 +1 @@
|
||||
/opt/coins/data/dash_testnet/backend
|
||||
2
contrib/backends/dash/debian/dash-testnet.install
Normal file
2
contrib/backends/dash/debian/dash-testnet.install
Normal file
@ -0,0 +1,2 @@
|
||||
dash/* /opt/coins/nodes/dash_testnet
|
||||
dash_testnet.conf /opt/coins/nodes/dash_testnet
|
||||
10
contrib/backends/dash/debian/dash-testnet.logrotate
Normal file
10
contrib/backends/dash/debian/dash-testnet.logrotate
Normal file
@ -0,0 +1,10 @@
|
||||
/opt/coins/data/dash_testnet/backend/testnet3/debug.log
|
||||
/opt/coins/data/dash_testnet/backend/testnet3/db.log
|
||||
{
|
||||
rotate 7
|
||||
daily
|
||||
compress
|
||||
missingok
|
||||
notifempty
|
||||
copytruncate
|
||||
}
|
||||
20
contrib/backends/dash/debian/dash-testnet.postinst
Normal file
20
contrib/backends/dash/debian/dash-testnet.postinst
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
|
||||
configure)
|
||||
if ! id -u dash &> /dev/null
|
||||
then
|
||||
useradd --system -M -U dash -s /bin/false
|
||||
fi
|
||||
|
||||
if [ "$(stat -c '%U' /opt/coins/data/dash_testnet/backend)" != "dash" ]
|
||||
then
|
||||
chown -R dash:dash /opt/coins/data/dash_testnet/backend
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
#DEBHELPER#
|
||||
47
contrib/backends/dash/debian/dash-testnet.service
Normal file
47
contrib/backends/dash/debian/dash-testnet.service
Normal file
@ -0,0 +1,47 @@
|
||||
# It is not recommended to modify this file in-place, because it will
|
||||
# be overwritten during package upgrades. If you want to add further
|
||||
# options or overwrite existing ones then use
|
||||
# $ systemctl edit dash-testnet.service
|
||||
# See "man systemd.service" for details.
|
||||
|
||||
# Note that almost all daemon options could be specified in
|
||||
# /opt/coins/nodes/dash_testnet/dash_testnet.conf
|
||||
|
||||
[Unit]
|
||||
Description=DASH daemon (testnet)
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/opt/coins/nodes/dash_testnet/bin/dashd -datadir=/opt/coins/data/dash_testnet/backend -conf=/opt/coins/nodes/dash_testnet/dash_testnet.conf -pid=/run/dashd/dash_testnet.pid
|
||||
# Creates /run/dashd owned by dash
|
||||
RuntimeDirectory=dashd
|
||||
User=dash
|
||||
Type=forking
|
||||
PIDFile=/run/dashd/dash_testnet.pid
|
||||
Restart=on-failure
|
||||
|
||||
# Resource limits
|
||||
LimitNOFILE=500000
|
||||
|
||||
# Hardening measures
|
||||
####################
|
||||
|
||||
# Provide a private /tmp and /var/tmp.
|
||||
PrivateTmp=true
|
||||
|
||||
# Mount /usr, /boot/ and /etc read-only for the process.
|
||||
ProtectSystem=full
|
||||
|
||||
# Disallow the process and all of its children to gain
|
||||
# new privileges through execve().
|
||||
NoNewPrivileges=true
|
||||
|
||||
# Use a new /dev namespace only populated with API pseudo devices
|
||||
# such as /dev/null, /dev/zero and /dev/random.
|
||||
PrivateDevices=true
|
||||
|
||||
# Deny the creation of writable and executable memory mappings.
|
||||
MemoryDenyWriteExecute=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
1
contrib/backends/dash/debian/dash.conffiles
Normal file
1
contrib/backends/dash/debian/dash.conffiles
Normal file
@ -0,0 +1 @@
|
||||
/opt/coins/nodes/dash/dash.conf
|
||||
1
contrib/backends/dash/debian/dash.dirs
Normal file
1
contrib/backends/dash/debian/dash.dirs
Normal file
@ -0,0 +1 @@
|
||||
/opt/coins/data/dash/backend
|
||||
2
contrib/backends/dash/debian/dash.install
Normal file
2
contrib/backends/dash/debian/dash.install
Normal file
@ -0,0 +1,2 @@
|
||||
dash/* /opt/coins/nodes/dash
|
||||
dash.conf /opt/coins/nodes/dash
|
||||
10
contrib/backends/dash/debian/dash.logrotate
Normal file
10
contrib/backends/dash/debian/dash.logrotate
Normal file
@ -0,0 +1,10 @@
|
||||
/opt/coins/data/dash/backend/debug.log
|
||||
/opt/coins/data/dash/backend/db.log
|
||||
{
|
||||
rotate 7
|
||||
daily
|
||||
compress
|
||||
missingok
|
||||
notifempty
|
||||
copytruncate
|
||||
}
|
||||
20
contrib/backends/dash/debian/dash.postinst
Normal file
20
contrib/backends/dash/debian/dash.postinst
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
|
||||
configure)
|
||||
if ! id -u dash &> /dev/null
|
||||
then
|
||||
useradd --system -M -U dash -s /bin/false
|
||||
fi
|
||||
|
||||
if [ "$(stat -c '%U' /opt/coins/data/dash/backend)" != "dash" ]
|
||||
then
|
||||
chown -R dash:dash /opt/coins/data/dash/backend
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
#DEBHELPER#
|
||||
47
contrib/backends/dash/debian/dash.service
Normal file
47
contrib/backends/dash/debian/dash.service
Normal file
@ -0,0 +1,47 @@
|
||||
# It is not recommended to modify this file in-place, because it will
|
||||
# be overwritten during package upgrades. If you want to add further
|
||||
# options or overwrite existing ones then use
|
||||
# $ systemctl edit dash.service
|
||||
# See "man systemd.service" for details.
|
||||
|
||||
# Note that almost all daemon options could be specified in
|
||||
# /opt/coins/nodes/dash/dash.conf
|
||||
|
||||
[Unit]
|
||||
Description=DASH daemon (mainnet)
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/opt/coins/nodes/dash/bin/dashd -datadir=/opt/coins/data/dash/backend -conf=/opt/coins/nodes/dash/dash.conf -pid=/run/dashd/dash.pid
|
||||
# Creates /run/dashd owned by dash
|
||||
RuntimeDirectory=dashd
|
||||
User=dash
|
||||
Type=forking
|
||||
PIDFile=/run/dashd/dash.pid
|
||||
Restart=on-failure
|
||||
|
||||
# Resource limits
|
||||
LimitNOFILE=500000
|
||||
|
||||
# Hardening measures
|
||||
####################
|
||||
|
||||
# Provide a private /tmp and /var/tmp.
|
||||
PrivateTmp=true
|
||||
|
||||
# Mount /usr, /boot/ and /etc read-only for the process.
|
||||
ProtectSystem=full
|
||||
|
||||
# Disallow the process and all of its children to gain
|
||||
# new privileges through execve().
|
||||
NoNewPrivileges=true
|
||||
|
||||
# Use a new /dev namespace only populated with API pseudo devices
|
||||
# such as /dev/null, /dev/zero and /dev/random.
|
||||
PrivateDevices=true
|
||||
|
||||
# Deny the creation of writable and executable memory mappings.
|
||||
MemoryDenyWriteExecute=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
11
contrib/backends/dash/debian/rules
Executable file
11
contrib/backends/dash/debian/rules
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
DH_VERBOSE = 1
|
||||
|
||||
%:
|
||||
dh $@ --with=systemd
|
||||
|
||||
override_dh_systemd_start:
|
||||
dh_systemd_start --no-start
|
||||
|
||||
override_dh_installinit:
|
||||
Loading…
Reference in New Issue
Block a user