@@ -1302,8 +1302,8 @@ def GetStake(self, account, args=None):
1302
1302
useController = self .using_liquid_staking ()
1303
1303
stakePercent = self .local .db .get ("stakePercent" , 99 )
1304
1304
vconfig = self .GetValidatorConfig ()
1305
- validators = vconfig .get ("validators" )
1306
1305
config17 = self .GetConfig17 ()
1306
+ config15 = self .GetConfig15 ()
1307
1307
1308
1308
# Check if optional arguments have been passed to us
1309
1309
if args :
@@ -1331,14 +1331,21 @@ def GetStake(self, account, args=None):
1331
1331
stake = account .balance - 50
1332
1332
if stake is None :
1333
1333
sp = stakePercent / 100
1334
+
1334
1335
if sp > 1 or sp < 0 :
1335
1336
self .local .add_log ("Wrong stakePercent value. Using default stake." , "warning" )
1336
- elif len (vconfig .validators ) == 0 :
1337
- stake = int (account .balance * sp / 2 )
1338
- if stake < config17 ["minStake" ]: # not enough funds to divide them by 2
1339
- stake = int (account .balance * sp )
1340
- elif len (vconfig .validators ) > 0 :
1341
- stake = int (account .balance * sp )
1337
+ else :
1338
+ for validator in vconfig .validators :
1339
+ # Check validator is in active period
1340
+ if validator .election_date - config15 ["elections_end_before" ] < get_timestamp () < validator .expire_at :
1341
+ # Check validator is elected
1342
+ if self .GetAdnlAddr () in self .GetValidatorsList ():
1343
+ stake = int (account .balance * sp )
1344
+ break
1345
+ else :
1346
+ stake = int (account .balance * sp / 2 )
1347
+ if stake < config17 ["minStake" ]: # not enough funds to divide them by 2
1348
+ stake = int (account .balance * sp )
1342
1349
1343
1350
# Check if we have enough coins
1344
1351
if stake > config17 ["maxStake" ]:
@@ -1662,7 +1669,7 @@ def CreateWallet(self, name, workchain=0, version="v1", **kwargs):
1662
1669
if os .path .isfile (wallet_path + ".pk" ) and "v3" not in version :
1663
1670
self .local .add_log ("CreateWallet error: Wallet already exists: " + name , "warning" )
1664
1671
else :
1665
- fift_args = self .get_new_wallet_fift_args (version , workchain = workchain ,
1672
+ fift_args = self .get_new_wallet_fift_args (version , workchain = workchain ,
1666
1673
wallet_path = wallet_path , subwallet = subwallet )
1667
1674
result = self .fift .Run (fift_args )
1668
1675
if "Creating new" not in result :
@@ -1731,7 +1738,7 @@ def import_wallet_with_version(self, key, version, **kwargs):
1731
1738
wallet_path = self .walletsDir + wallet_name
1732
1739
with open (wallet_path + ".pk" , 'wb' ) as file :
1733
1740
file .write (pk_bytes )
1734
- fift_args = self .get_new_wallet_fift_args (version , workchain = workchain ,
1741
+ fift_args = self .get_new_wallet_fift_args (version , workchain = workchain ,
1735
1742
wallet_path = wallet_path , subwallet = subwallet )
1736
1743
result = self .fift .Run (fift_args )
1737
1744
if "Creating new" not in result :
@@ -2577,7 +2584,10 @@ def GetValidatorsList(self, past=False):
2577
2584
start = config .get ("startWorkTime" )
2578
2585
end = config .get ("endWorkTime" ) - 60
2579
2586
#end if
2580
- validatorsLoad = self .GetValidatorsLoad (start , end )
2587
+ if self .GetNetworkName () != "testnet" :
2588
+ validatorsLoad = self .GetValidatorsLoad (start , end )
2589
+ else :
2590
+ validatorsLoad = []
2581
2591
validators = config ["validators" ]
2582
2592
electionId = config .get ("startWorkTime" )
2583
2593
saveElectionEntries = self .GetSaveElectionEntries (electionId )
0 commit comments