Take sats as whole numbers in validate_sats

This commit is contained in:
ai-bot committed 2026-11-14 18:01:12 +00:00
1 parent a016d31cc5
commit d89b474eda
1 file changed
+4 -6
+4 -6
View File
@@ -90,15 +90,13 @@ def validate_date(value):
def validate_sats(value, optional=False): def validate_sats(value, optional=False):
"""Return an amount of sats from a BTC amount written by the user.""" """Return a whole number of sats from what the owner typed."""
if _blank(value): if _blank(value):
return (None, None) if optional else (None, "Antal må fyllast ut.") return (None, None) if optional else (None, "Antal må fyllast ut.")
try: try:
sats = rates.parse_btc_to_sats(value) sats = rates.parse_sats(value)
except ValueError as error: except ValueError:
if "8 decimals" in str(error): return None, "Antal må vere eit heiltal i sats."
return None, "Antal kan ha høgst 8 desimalar."
return None, "Antal må vere eit tal, t.d. 0,5."
if sats <= 0: if sats <= 0:
return None, "Antal må vere større enn null." return None, "Antal må vere større enn null."
return sats, None return sats, None