diff --git a/bchain/coins/bch/bcashrpc.go b/bchain/coins/bch/bcashrpc.go index 36a955c1..a57154bb 100644 --- a/bchain/coins/bch/bcashrpc.go +++ b/bchain/coins/bch/bcashrpc.go @@ -5,6 +5,7 @@ import ( "blockbook/bchain/coins/btc" "encoding/hex" "encoding/json" + "math/big" "github.com/golang/glog" "github.com/juju/errors" @@ -162,3 +163,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 +} diff --git a/configs/coins/bcash.json b/configs/coins/bcash.json index 84c22b34..efe85e93 100644 --- a/configs/coins/bcash.json +++ b/configs/coins/bcash.json @@ -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,