Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Setting:
'stake': Setting('validator', None, 'Stake amount'),
'stakePercent': Setting('validator', 99, 'Stake percent if `stake` is null'),
'isSlashing': Setting('validator', None, 'Create complaints to validators'),
'validatorWalletName': Setting('validator', 'wallet_001', 'Validator\'s wallet name'),
'maxFactor': Setting('validator', None, 'Param send to Elector. if null will be taken from 17 config param'),
'participateBeforeEnd': Setting('validator', None, 'Amount of seconds before start of round to participate'),
'liquid_pool_addr': Setting('liquid-staking', None, 'Liquid staking pool address'),
Expand Down
2 changes: 2 additions & 0 deletions modules/nominator_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def do_activate_pool(self, pool, ex=True):
elif account.status == "active":
self.local.add_log("do_activate_pool warning: account status is active", "warning")
else:
validator_wallet = self.ton.GetValidatorWallet()
self.ton.check_account_active(validator_wallet.addrB64)
self.ton.SendFile(pool.bocFilePath, pool, timeout=False, remove=False)
#end define

Expand Down
1 change: 1 addition & 0 deletions modules/single_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def do_activate_single_pool(self, pool):
self.local.add_log("start activate_single_pool function", "debug")
boc_mode = "--with-init"
validator_wallet = self.ton.GetValidatorWallet()
self.ton.check_account_active(validator_wallet.addrB64)
result_file_path = self.ton.SignBocWithWallet(validator_wallet, pool.bocFilePath, pool.addrB64_init, 1, boc_mode=boc_mode)
self.ton.SendFile(result_file_path, validator_wallet)

Expand Down
30 changes: 22 additions & 8 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,7 @@ def SignBocWithWallet(self, wallet, boc_path, dest, coins, **kwargs):

# Balance checking
account = self.GetAccount(wallet.addrB64)
if account.balance < coins + 0.1:
raise Exception("Wallet balance is less than requested coins")
#end if
self.check_account_balance(account, coins + 0.1)

# Bounceable checking
destAccount = self.GetAccount(dest)
Expand Down Expand Up @@ -1864,6 +1862,25 @@ def GetWalletId(self, wallet):
return subwallet
#end define

def check_account_balance(self, account, coins):
if not isinstance(account, Account):
account = self.GetAccount(account)
if account.balance < coins:
raise Exception(f"Account {account.addrB64} balance is less than requested coins. Balance: {account.balance}, requested amount: {coins} (need {coins - account.balance} more)")
# end if
# end define

def check_account_active(self, account):
if not isinstance(account, Account):
address = account
account = self.GetAccount(account)
else:
address = account.addrB64
if account.status != "active":
raise Exception(f"Account {address} account is uninitialized")
# end if
# end define

def MoveCoins(self, wallet, dest, coins, **kwargs):
self.local.add_log("start MoveCoins function", "debug")
flags = kwargs.get("flags", list())
Expand All @@ -1884,11 +1901,8 @@ def MoveCoins(self, wallet, dest, coins, **kwargs):

# Balance checking
account = self.GetAccount(wallet.addrB64)
if account.balance < coins + 0.1:
raise Exception("Wallet balance is less than requested coins")
if account.status != "active":
raise Exception("Wallet account is uninitialized")
#end if
self.check_account_balance(account, coins + 0.1)
self.check_account_active(account)

# Bounceable checking
destAccount = self.GetAccount(dest)
Expand Down