Introduce utility functions satToBtc
and btcToSat
to simplify and standardize conversions between satoshis and bitcoins in functional tests
#closes #31345
This PR implements the solution proposed in the issue. The goal is to simplify conversions between satoshis and bitcoins in the functional tests by using utility functions. For example, code like fee_rate=Decimal(feerate * 1000) / COIN
could become fee_rate=satToBtc(feerate * 1000)
in the proposed solution.
An additional benefit of satToBtc() is that it ensures the use of Decimal.
This issue was briefly mentioned in this discussion, where the conversion Decimal(value) / COIN
was noted to be repetitive.
While some may prefer to continue using the / COIN
and * COIN
conversions, I donβt have a strong preference either way. Iβd like to hear your opinions and, if needed, implement the approach that works best.