ofek / bit

Bitcoin made easy.
https://ofek.dev/bit/
MIT License
1.25k stars 216 forks source link

input and output for estimate_tx_fee() function #150

Open Freditansari opened 3 years ago

Freditansari commented 3 years ago

How do I find the input and output for the estimate_tx_fee() function?

reza-khalafi commented 1 year ago

@Freditansari Did you find any usefull answer? I need to estimate transaction fee before key.send() or key.create_transaction(). I have find this formula:

Get fee_rate from here:

https://bitcoinfees.earn.com/api/v1/fees/recommended 
=> {"fastestFee":102,"halfHourFee":102,"hourFee":88}

Then:

transaction_size_as_byte = (number_of_inputs * 180) + (number_of_output * 34)
transaction_fee = transaction_size_as_byte * fee_rate

And i don't know how to get number_of_inputs and number_of_output.

Let me know if you have any solution for it.