From 116ab15a20a9b72862f85e4a9cfb7e34d32c79ce Mon Sep 17 00:00:00 2001 From: Alexander Kolotov Date: Fri, 1 Jun 2018 18:44:42 +0300 Subject: [PATCH] check if the actor has enough funds to deposit added --- .../token/token_withdraw.py => foreign_withdraw.py} | 0 erc20/home_deposit.py | 7 +++++-- 2 files changed, 5 insertions(+), 2 deletions(-) rename erc20/{bridge/token/token_withdraw.py => foreign_withdraw.py} (100%) diff --git a/erc20/bridge/token/token_withdraw.py b/erc20/foreign_withdraw.py similarity index 100% rename from erc20/bridge/token/token_withdraw.py rename to erc20/foreign_withdraw.py diff --git a/erc20/home_deposit.py b/erc20/home_deposit.py index f7cafb7..0c0c310 100755 --- a/erc20/home_deposit.py +++ b/erc20/home_deposit.py @@ -29,8 +29,6 @@ gas_price = b.home_bridge.functions.gasPrice().call() gas_limit = 50000 net_id = int(web3.version.network) -op_num = web3.eth.getTransactionCount(b.actor_address) - tx_templ = { 'to': b.home_bridge_address, 'gas': gas_limit, @@ -44,6 +42,11 @@ op_num = web3.eth.getTransactionCount(actor.address) if tx_value == None: tx_value = b.home_bridge.functions.minPerTx().call() +balance_needed = ((gas_price * gas_limit + tx_value) * tx_num) +balance_current = web3.eth.getBalance(actor.address) +if balance_needed > balance_current: + exit(f'{actor.address} balance is lower than needed ({balance_needed} > {balance_current})') + ################################################################################ # Preparing batch of transactions to the bridge contract with ether sending ################################################################################