fee estimation – Any API to estimate the miner fee for a Bitcoin raw transaction?

Fees in Bitcoin are actually a bit simpler than ethereum, you don’t have to deal with gas costs, just a fee per byte.

Bitcoin Core includes an estimatesmartfee function. You can call it (estimatesmartfee 2, for example) and it will give you an idea of the fee rate you need to be confirmed in n blocks (2 in my example).

You can then check your tx size, which varies by number of inputs and outputs, and just multiply it by the fee rate to get your recommended fee, and subtract that from your change output.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: