|
|
|
@ -5,7 +5,6 @@ import operator
|
|
|
|
|
import config
|
|
|
|
|
from decimal import Decimal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PICOWOW = Decimal('0.00000000001')
|
|
|
|
|
|
|
|
|
|
class Wallet(object):
|
|
|
|
@ -102,12 +101,25 @@ class Wallet(object):
|
|
|
|
|
transfer = self.make_wallet_rpc('transfer', data)
|
|
|
|
|
return transfer
|
|
|
|
|
|
|
|
|
|
def sweepall(self, dest_address, priority, account):
|
|
|
|
|
data = {
|
|
|
|
|
'account_index': account,
|
|
|
|
|
'address': dest_address,
|
|
|
|
|
'priority': priority,
|
|
|
|
|
'unlock_time': 0,
|
|
|
|
|
'get_tx_key': True,
|
|
|
|
|
'get_tx_hex': True,
|
|
|
|
|
'new_algorithm': True,
|
|
|
|
|
'do_not_relay': False,
|
|
|
|
|
}
|
|
|
|
|
sweepall = self.make_wallet_rpc('sweep_all', data)
|
|
|
|
|
return sweepall
|
|
|
|
|
|
|
|
|
|
def to_atomic(amount):
|
|
|
|
|
if not isinstance(amount, (Decimal, float) + six.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**11)
|
|
|
|
|
return int(amount / PICOWOW)
|
|
|
|
|
|
|
|
|
|
def from_atomic(amount):
|
|
|
|
|
return (Decimal(amount) * PICOWOW).quantize(PICOWOW)
|
|
|
|
|