diff --git a/kisstron.py b/kisstron.py index 2f2129c..4437dcc 100755 --- a/kisstron.py +++ b/kisstron.py @@ -288,6 +288,9 @@ def sendtrx(network: str, pk: str, toaddr: str, amt: float, except ValidationError as e: res['message'] = str(e) return res + except TransactionError as e: + res['message'] = str(e) + return res res['success'] = True res['message'] = 'Sent %f TRX to %s\nTransaction ID %s' % (amt, toaddr, receipt['id']) @@ -332,10 +335,10 @@ def sendtrc20(network: str, pk: str, ticker: str, toaddr: str, except ValidationError as e: res['message'] = str(e) return res - res['result'] = receipt - if receipt['receipt']['result'] == 'OUT_OF_ENERGY': - res['message'] = 'Not enough energy for transaction!' + except TransactionError as e: + res['message'] = str(e) return res + res['result'] = receipt res['success'] = True res['message'] = 'Sent %f %s to %s\nTransaction ID %s' % (amt, KT_TRC20_TOKENS[network][ticker]['ticker'], @@ -370,6 +373,9 @@ def freezetrx(network: str, pk: str, amt: float, offline: bool = False): except ValidationError as e: res['message'] = str(e) return res + except TransactionError as e: + res['message'] = str(e) + return res res['success'] = True res['message'] = 'Frozen %f TRX at %s\nTransaction ID %s' % (amt, myaddr, receipt['id']) @@ -405,6 +411,9 @@ def unfreezetrx(network: str, pk: str, amt: float, offline: bool = False): except ValidationError as e: res['message'] = str(e) return res + except TransactionError as e: + res['message'] = str(e) + return res res['success'] = True res['message'] = 'Unfrozen %f TRX at %s\nTransaction ID %s' % (amt, myaddr, receipt['id']) @@ -435,10 +444,6 @@ def broadcastjson(network, tjson): res['message'] = str(e) return res res['result'] = receipt - if ('receipt' in receipt and 'result' in receipt['receipt'] - and receipt['receipt']['result'] == 'OUT_OF_ENERGY'): - res['message'] = 'Not enough energy for transaction!' - return res res['success'] = True res['message'] = 'Transaction sent\nTransaction ID %s' % receipt['id'] return res