mirror of
https://git.wownero.com/lza_menace/wownero-python.git
synced 2024-08-15 03:25:25 +00:00
Check type of amounts passed to conversion, avoid MemoryError when a string is being concatenated 10^12 times. Close#48
This commit is contained in:
parent
3358e5a30a
commit
a7c8579b13
2 changed files with 12 additions and 0 deletions
|
@ -13,6 +13,9 @@ else: # pragma: no cover
|
|||
|
||||
def to_atomic(amount):
|
||||
"""Convert Monero decimal to atomic integer of piconero."""
|
||||
if not isinstance(amount, (Decimal, float) + _integer_types):
|
||||
raise ValueError("Amount '{}' doesn't have numeric type. Only Decimal, int, long and "
|
||||
"float (not recommended) are accepted as amounts.")
|
||||
return int(amount * 10**12)
|
||||
|
||||
def from_atomic(amount):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue