diff --git a/hsd.py b/hsd.py index ab3a53f..aa92f9a 100644 --- a/hsd.py +++ b/hsd.py @@ -230,10 +230,10 @@ def get_balance(userID:str, name:str) -> dict: # Convert to human readable return_json = { - 'available': balance['confirmed']/10**6, - 'available_small': balance['confirmed'], - 'locked': (balance['lockedConfirmed']-domains_value)/10**6, - 'locked_small': balance['lockedConfirmed']-domains_value, + 'available': (balance['confirmed']-domains_value)/10**6, + 'available_small': balance['confirmed']-domains_value, + 'locked': balance['lockedConfirmed']/10**6, + 'locked_small': balance['lockedConfirmed'], } return return_json @@ -328,6 +328,10 @@ def send_to_address(userID:str, name:str, address:str, amount:str) -> dict: 'error': 'Insufficient funds' } + subtractFee = False + if balance['available'] - amount < 0.03: + subtractFee = True + amount = balance['available'] data = { 'outputs': [ @@ -336,7 +340,8 @@ def send_to_address(userID:str, name:str, address:str, amount:str) -> dict: 'value': hns.to_small(amount) } ], - 'sign': False + 'sign': False, + 'subtractFee': subtractFee } response = requests.post(url(True)+'wallet/'+walletID+'/create', json=data)