How to get exact tx fee
ptc-bink opened this issue · 3 comments
ptc-bink commented
Now I am trying to get exact transaction fee.
I find psbt.getFeeRate()
But it doesn't work and occurs errors.
Seems like you didn't define this function.
When I send btc from A to B, set 1 addinputs and 2 addoutputs.
How to calc exact fee? If any missing, plz let me know.
jasonandjay commented
What error did you encounter?
ptc-bink commented
const psbt = new Bitcon.psbt({network: testwork})
/**
much code lines of psbt.addinput and psbt.addoutput
**/
const feeRate = psbt.getFeeRate()
Just in this step to get feeRate, functions doesn't work.
junderw commented
The transaction needs to be finalized to get the final feeRate.
The fee is just the input amounts minus the output amounts. You should know it already. There is no reason to ask about it to the transaction.