From 1a7b62efa225b0c31ba43abf3f1701d86decf1d7 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Tue, 4 Jun 2024 15:17:17 +1000 Subject: [PATCH] fix: Balance should return hide domain value and fix send max --- hsd.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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)