Skip to content
Permalink
Browse files

qtum feerate check

it seems there is an issue with qtum core rpc that "estimatesmartfee" can return feerate lower than minFeeRate sometimes
  • Loading branch information...
icodeface authored and martinboehm committed Jun 27, 2019
1 parent 5b2b7ce commit 4eaeb25a5e954de100e47c8bad2716a42a089cb9
Showing with 14 additions and 0 deletions.
  1. +14 −0 bchain/coins/qtum/qtumrpc.go
@@ -4,13 +4,15 @@ import (
"blockbook/bchain"
"blockbook/bchain/coins/btc"
"encoding/json"
"math/big"

"github.com/golang/glog"
)

// QtumRPC is an interface to JSON-RPC bitcoind service.
type QtumRPC struct {
*btc.BitcoinRPC
minFeeRate *big.Int // satoshi per kb
}

// NewQtumRPC returns new QtumRPC instance.
@@ -22,6 +24,7 @@ func NewQtumRPC(config json.RawMessage, pushHandler func(bchain.NotificationType

s := &QtumRPC{
b.(*btc.BitcoinRPC),
big.NewInt(400000),
}
s.RPCMarshaler = btc.JSONMarshalerV1{}
s.ChainConfig.SupportsEstimateSmartFee = true
@@ -61,3 +64,14 @@ func (b *QtumRPC) Initialize() error {
func (b *QtumRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) {
return b.GetTransaction(txid)
}

// EstimateSmartFee returns fee estimation
func (b *QtumRPC) EstimateSmartFee(blocks int, conservative bool) (big.Int, error) {
feeRate, err := b.BitcoinRPC.EstimateSmartFee(blocks, conservative)
if err != nil {
if b.minFeeRate.Cmp(&feeRate) == 1 {
feeRate = *b.minFeeRate
}
}
return feeRate, err
}

0 comments on commit 4eaeb25

Please sign in to comment.
You can’t perform that action at this time.