diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index aff64285..48f8647a 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -1316,7 +1316,6 @@ def GetStake(self, account, args=None): # Limit stake to maximum available amount minus 10 (for transaction fees) if stake > account.balance - 10: stake = account.balance - 10 - #end if pool_version = self.GetVersionFromCodeHash(account.codeHash) is_single_nominator = pool_version is not None and 'spool' in pool_version @@ -1331,9 +1330,10 @@ def GetStake(self, account, args=None): self.local.add_log("Wrong stakePercent value. Using default stake.", "warning") elif len(vconfig.validators) == 0: stake = int(account.balance*sp/2) + if stake < config17["minStake"]: # not enough funds to divide them by 2 + stake = int(account.balance*sp) elif len(vconfig.validators) > 0: stake = int(account.balance*sp) - #end if # Check if we have enough coins if stake > config17["maxStake"]: @@ -1348,10 +1348,8 @@ def GetStake(self, account, args=None): text = "Don't have enough coins. stake: {stake}, account balance: {balance}".format(stake=stake, balance=account.balance) # self.local.add_log(text, "error") raise Exception(text) - #end if return stake - #end define def GetMaxFactor(self): # Either use defined maxFactor, or set maximal allowed by config17 diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index 6628a5a9..4a8c0f92 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -176,20 +176,38 @@ def inject_globals(func): local.db.config.logLevel = "debug" if console.debug else "info" local.db.config.isLocaldbSaving = False local.run() + + +def check_installer_user(): + args = ["whoami"] + process = subprocess.run(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3) + username = process.stdout.decode("utf-8").strip() + + args = ["ls", "-lh", "/var/ton-work/keys/"] + process = subprocess.run(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3) + output = process.stdout.decode("utf-8") + actual_user = output.split('\n')[1].split()[2] + + if username != actual_user: + raise Exception(f'mytonctrl was installed by another user. Probably you need to launch mtc with `{actual_user}` user.') #end define + def PreUp(local, ton): CheckMytonctrlUpdate(local) + check_installer_user() check_vport(local, ton) # CheckTonUpdate() #end define + def Installer(args): # args = ["python3", "/usr/src/mytonctrl/mytoninstaller.py"] args = ["python3", "-m", "mytoninstaller"] subprocess.run(args) #end define + def GetAuthorRepoBranchFromArgs(args): data = dict() arg1 = GetItemFromList(args, 0) @@ -210,6 +228,7 @@ def GetAuthorRepoBranchFromArgs(args): return data #end define + def check_vport(local, ton): try: vconfig = ton.GetValidatorConfig() @@ -245,7 +264,8 @@ def check_git(input_args, default_repo, text): git_path = f"{src_dir}/{default_repo}" fix_git_config(git_path) default_author = "ton-blockchain" - default_branch = "master" + # default_branch = "master" + default_branch = "mytonctrl2" # Get author, repo, branch local_author, local_repo = get_git_author_and_repo(git_path)