Convert BTC decimals to satoshis without floating-point rounding
Python example
from decimal import Decimal, InvalidOperation
def btc_to_sats(value: str) -> int:
btc = Decimal(value)
sats = btc * Decimal(100_000_000)
if btc < 0 or sats != sats.to_integral_value():
raise ValueError('BTC amount must be nonnegative and precise to 1 sat')
return int(sats)
print(btc_to_sats('0.00025000')) # 25000
This conversion belongs at an integration boundary; WAB Engine SEND inputs should stay in integer satoshis. Avoid float for monetary amounts.
Related ASK questions
How many satoshis are in 0.00025000 BTC?
https://thamer.org/ask/ask-wab-engine-000025-btc-in-sats
