Bitcoin Forum
May 07, 2024, 11:52:03 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Network fee estimation  (Read 220 times)
bitgamerz (OP)
Newbie
*
Offline Offline

Activity: 51
Merit: 0


View Profile
January 31, 2018, 04:56:13 PM
 #1

Hello,

How does electrum (or any other wallet) compute the optimal network fee for a bitcoin transaction ?
Or how does this website https://bitcoinfees.earn.com/ compute the appropriate estimate fee ?


I know that you need to take in consideration the number of input/output, and you need to consider the number of unconfirmed transaction, however I want a technical way to compute it myself.



Please do not reply with an API link or any third party service, I would like to do it using opensource tools only.
1715082723
Hero Member
*
Offline Offline

Posts: 1715082723

View Profile Personal Message (Offline)

Ignore
1715082723
Reply with quote  #2

1715082723
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715082723
Hero Member
*
Offline Offline

Posts: 1715082723

View Profile Personal Message (Offline)

Ignore
1715082723
Reply with quote  #2

1715082723
Report to moderator
1715082723
Hero Member
*
Offline Offline

Posts: 1715082723

View Profile Personal Message (Offline)

Ignore
1715082723
Reply with quote  #2

1715082723
Report to moderator
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
January 31, 2018, 06:01:17 PM
Merited by LoyceV (2)
 #2

Step 1:
Keep track of all the transactions that have been broadcast to the Bitcoin network which are not yet in a block. Keep a record of the size of the transactions, and the fee that each transaction is offering.

Step 2:
Keep track of the recent blocks that have been solved.  Keep a record of the number of transactions included in the block and the fees that made it into the block.

Step 3: Perform a statistical analysis of the unconfirmed transactions that have been broadcast to the Bitcoin network, and (using your statistical model) attempt to predict the rates, quantities, sizes, and fees of the transactions that are likely to be created in the next few hours.

Step 4:  Assume that the typical miner will make rational profit driven decisions and that they are not receiving any revenue outside of the transaction fees and block subsidy.

Step 5: Using your predictions of future transactions along with your knowledge of the current backlog, calculate the minimum fee that would make it into each of the blocks over the next few hours.

Step 6: Publish (or use) your results as a guideline on how big of a fee you'll need to pay if you want your transaction confirmed quickly.

Extra credit:  You can improve your model if you can predict which transactions the typical mining pool is likely to drop from its mempool.
bitgamerz (OP)
Newbie
*
Offline Offline

Activity: 51
Merit: 0


View Profile
January 31, 2018, 07:11:44 PM
 #3

Step 1:
Keep track of all the transactions that have been broadcast to the Bitcoin network which are not yet in a block. Keep a record of the size of the transactions, and the fee that each transaction is offering.

Step 2:
Keep track of the recent blocks that have been solved.  Keep a record of the number of transactions included in the block and the fees that made it into the block.

Step 3: Perform a statistical analysis of the unconfirmed transactions that have been broadcast to the Bitcoin network, and (using your statistical model) attempt to predict the rates, quantities, sizes, and fees of the transactions that are likely to be created in the next few hours.

Step 4:  Assume that the typical miner will make rational profit driven decisions and that they are not receiving any revenue outside of the transaction fees and block subsidy.

Step 5: Using your predictions of future transactions along with your knowledge of the current backlog, calculate the minimum fee that would make it into each of the blocks over the next few hours.

Step 6: Publish (or use) your results as a guideline on how big of a fee you'll need to pay if you want your transaction confirmed quickly.

Extra credit:  You can improve your model if you can predict which transactions the typical mining pool is likely to drop from its mempool.

Thank you, however, I doubt this is how electrum (or bitcoin wallets) get the fees for Sending btc.

I am sure there is a simpler way
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
January 31, 2018, 07:34:01 PM
 #4

how does this website https://bitcoinfees.earn.com/ compute the appropriate estimate fee ?

Thank you, however, I doubt this is how electrum (or bitcoin wallets) get the fees for Sending btc.

I'm not sure how Electrum calculates it (perhaps ask in the Electrum forum?)  I suspect they do some (if not all) of those steps.

It is probably a pretty good description of what bitcoinfees.earn.com is doing.

I am sure there is a simpler way

Sorry, I thought you wanted accurate.  If you just want simple...

Step 1. Look at the most recent block in the blockchain.

Step 2. Add up all the values of all the inputs in the block.

Step 3. Subtract the values of all the outputs in the block (skip the coinbase transaction)

Step 4. Divide by the number of bytes in the block.

The result will be the AVERAGE fee per byte paid by transactions in the block.  Adjust higher or lower as you see fit to increase or reduce your risk of waiting.
Thirdspace
Hero Member
*****
Offline Offline

Activity: 1232
Merit: 738


Mixing reinvented for your privacy | chipmixer.com


View Profile
January 31, 2018, 11:49:56 PM
 #5

just for comparison how other services calculate recommended fee
btc.com seems to use the tx fee from the last tx in the latest found block
there is no written explanation on the site, but I checked it manually and the number seems pretty close

and coinb.in does similarly but using from recent block (2 previous block) and use it for minimum Recommended Fee
latest block is 507015 and coinb.in uses tx in block 507013 for estimation
last txid e83c174722c6e766b45502251805a015b5e1cdfa521363fa130e0622c73c2247 in block 507013

Blockchain Data
This is based on us comparing your transaction against a very recent transaction found in a very recent block
Block Height: 507013
Block #: 0000000000000000003b19530456fbdff45dd9d698c79154bc865326cf9f0a1b
Block Time: 1517441134 31/01/2018 23:25:34
Transaction ID: e83c174722c6e766b45502251805a015b5e1cdfa521363fa130e0622c73c2247
Transaction Size: 216 bytes
Transaction Fee: 0.00021016
Satoshi per Byte: 97

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!