Fix bcash EstimateFee after interface change in backend v0.19.1

pull/141/head
Martin Boehm 2019-03-27 14:25:36 +01:00
parent 713f928a57
commit 8c471ed20d
2 changed files with 34 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"blockbook/bchain/coins/btc"
"encoding/hex"
"encoding/json"
"math/big"
"github.com/golang/glog"
"github.com/juju/errors"
@ -161,3 +162,35 @@ func isErrBlockNotFound(err *bchain.RPCError) bool {
return err.Message == "Block not found" ||
err.Message == "Block height out of range"
}
// EstimateFee returns fee estimation
func (b *BCashRPC) EstimateFee(blocks int) (big.Int, error) {
// from version BitcoinABC version 0.19.1 EstimateFee does not support parameter Blocks
if b.ChainConfig.CoinShortcut == "BCHSV" {
return b.BitcoinRPC.EstimateFee(blocks)
}
glog.V(1).Info("rpc: estimatefee ", blocks)
res := btc.ResEstimateFee{}
req := struct {
Method string `json:"method"`
}{
Method: "estimatefee",
}
err := b.Call(&req, &res)
var r big.Int
if err != nil {
return r, err
}
if res.Error != nil {
return r, res.Error
}
r, err = b.Parser.AmountToBigInt(res.Result)
if err != nil {
return r, err
}
return r, nil
}

View File

@ -49,7 +49,7 @@
"additional_params": "",
"block_chain": {
"parse": true,
"subversion": "/Bitcoin ABC:0.17.1/",
"subversion": "/Bitcoin ABC:0.19.1/",
"address_format": "cashaddr",
"mempool_workers": 8,
"mempool_sub_workers": 2,