fix: Balance should return hide domain value and fix send max
All checks were successful
Build Docker / BuildImage (push) Successful in 33s

This commit is contained in:
Nathan Woodburn 2024-06-04 15:17:17 +10:00
parent 7b2a25592e
commit 1a7b62efa2
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

15
hsd.py
View File

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