bcoin-org / bcoin

Javascript bitcoin library for node.js and browsers
https://bcoin.io
Other
3.01k stars 809 forks source link

rpc estimatesmartfee divergent from core, units unclear #691

Open pinheadmz opened 5 years ago

pinheadmz commented 5 years ago

A user asked me on slack if estimatefee returns BTC per Byte or BTC per Kilobyte... honestly I don't know and it's a bit hard to tell. I compared mainnet full nodes bcoin vs Bitcoin Core and observed a wild divergence (outputs below).

From Bitcoin Core help:

Estimates the approximate fee per kilobyte needed for a transaction to begin
confirmation within conf_target blocks if possible and return the number of blocks
for which the estimate is valid. Uses virtual transaction size as defined
in BIP 141 (witness data is discounted).
bcoin Bitcoin Core
$ bcoin-cli rpc estimatesmartfee 1
{
"fee": 0.00296501,
"blocks": 1
}
$ bitcoin-cli estimatesmartfee 1
{
"feerate": 0.00009759,
"blocks": 2
}
$ bcoin-cli rpc estimatesmartfee 2
{
"fee": 0.0001383,
"blocks": 2
}
$ bitcoin-cli estimatesmartfee 2
{
"feerate": 0.00009759,
"blocks": 2
}
$ bcoin-cli rpc estimatesmartfee 3
{
"fee": 0.00010208,
"blocks": 3
}
$ bitcoin-cli estimatesmartfee 3
{
"feerate": 0.00009759,
"blocks": 3
}
$ bcoin-cli rpc estimatesmartfee 4
{
"fee": 0.00010208,
"blocks": 4
}
$ bitcoin-cli estimatesmartfee 4
{
"feerate": 0.00005639,
"blocks": 4
}
$ bcoin-cli rpc estimatesmartfee 5
{
"fee": 0.00009605,
"blocks": 5
}
$ bitcoin-cli estimatesmartfee 5
{
"feerate": 0.00005639,
"blocks": 5
}
bcoin-cli rpc estimatesmartfee 6
{
"fee": 0.00009605,
"blocks": 6
}
$ bitcoin-cli estimatesmartfee 6
{
"feerate": 0.00005639,
"blocks": 6
}
$ bcoin-cli rpc estimatesmartfee 10
{
"fee": 0.0000252,
"blocks": 10
}
$ bitcoin-cli estimatesmartfee 10
{
"feerate": 0.00003820,
"blocks": 10
}
$ bcoin-cli rpc estimatesmartfee 20
Too many confirmations for estimate.
$ bitcoin-cli estimatesmartfee 20
{
"feerate": 0.00001059,
"blocks": 20
}
xraid commented 4 years ago

bcoin-cli rpc estimatesmartfee 3 { "fee": 0.00161134, "blocks": 3 }

BTC 0.00161134 as of today 17,82 USD

is this correct ?

pinheadmz commented 4 years ago

First of all keep in mind the values returned by this API are a rate not a hard value. So just converting the BTC to USD is not correct. Despite the confusion in the issue title, I'm pretty sure fee rates are returned in BTC per kilobyte. With segwit activation, this is better described as BTC per vbyte (witness data bytes are 1/4 byte).

Another factor at play here is your own nodes mempool. The fee estimator relies on an active mempool with good uptime to watch fee activity on the network. Mempool settings on your node like RBF and minrelay could affect fee estimator.

And finally, although there have been recent spikes in fees recently: https://jochen-hoenicke.de/queue/#0,1w Your value seems a little high. Admittedly, the fee estimation algorithm on bcoin is not exactly the same as bitcoin core and needs improvement.

xraid commented 4 years ago

so You say that 0.00161134 is an acceptable estimated fee ?

or have the BCoin seedlist randomly chosen only relays and miners with a SCAM high fee ?

I se referenced for a standard size tx of 224 bytes * 216 satoshis per byte = 0.00048384 bitcoins

BCoin estimatesmartfee effort is 100 000+ satoshis higher

how come ?

ahhh . so estimatesmartfee returns estimated fee per KB and if wallet size tx 224 bytes - we do (0.00161134 / 1000) * 224 = 0.00036094 bitcoins would equal around 161 satoshis per byte estimated transaction fee

** I vote for returning estimated wallet size tx bytes (satoshis) presented in BTC

returning estimated fee per KB don't make sense

thanks

pinheadmz commented 4 years ago

so You say that 0.00161134 is an acceptable estimated fee ?

I didn't offer any opinions about acceptable fees. I do not know your use case or time preferences.

or have the BCoin seedlist randomly chosen only relays and miners with a SCAM high fee ?

This makes no sense.

I se referenced for a standard size tx of 224 bytes 0.00048384

BCoin estimatesmartfee effort is 100 000+ satoshis higher

how come ?

Like I said :

Another factor at play here is your own nodes mempool. The fee estimator relies on an active mempool with good uptime to watch fee activity on the network. Mempool settings on your node like RBF and minrelay could affect fee estimator.

And finally, although there have been recent spikes in fees recently: https://jochen-hoenicke.de/queue/#0,1w Your value seems a little high. Admittedly, the fee estimation algorithm on bcoin is not exactly the same as bitcoin core and needs improvement.

xraid commented 4 years ago

I thank You for your patience and time in repeating what You just said.

and thank You for the link, I will share these links that I find educational regarding fee stats in the network now :

https://bitcoinfees.earn.com https://bitcoinfees.earn.com/api

https://bitcoinfees.earn.com/api/v1/fees/recommended (is from stats derived and showing "best bang for buck") => {"fastestFee":216,"halfHourFee":216,"hourFee":188} => satoshis per byte

again thanks