bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.67k stars 2.1k forks source link

Rounded value of feeRate, no public virtualSize property #1500

Closed JosipSylo closed 4 years ago

JosipSylo commented 4 years ago

More of a question than an issue report.

I was wondering why the feeRate was rounded here: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/psbt.js#L1143

It could also be useful to have a getter for the virtualSize. Similar to getFeeRate.

junderw commented 4 years ago
  1. Bitcoin Core rounds fee rate down. It is better to under-measure your rate and pay an extra 0.0023 satoshi/byte than be over-measuring and miss some cut off for some miner etc.
  2. Using psbt.extractTransaction().virtualSize() is sufficient. Creating a proxy for it will just create a cached Transaction internally anyways, so why bother?
JosipSylo commented 4 years ago

Thank you for a great and detailed explanation once again.