Skip to content

Commit 5f839f5

Browse files
committed
fix GetValidatorKey
1 parent a12dd8d commit 5f839f5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mytoncore.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,12 +2078,13 @@ def MoveCoinsFromHW(self, wallet, destList, **kwargs):
20782078

20792079
def GetValidatorKey(self):
20802080
vconfig = self.GetValidatorConfig()
2081-
for validator in vconfig.validators:
2081+
validators = sorted(vconfig["validators"], key=lambda i: i['election_date'], reverse=True)
2082+
for validator in validators:
20822083
validatorId = validator["id"]
20832084
key_bytes = base64.b64decode(validatorId)
20842085
validatorKey = key_bytes.hex().upper()
20852086
timestamp = get_timestamp()
2086-
if timestamp > validator["election_date"]:
2087+
if validator["election_date"] < timestamp < validator["expire_at"]:
20872088
return validatorKey
20882089
raise Exception("GetValidatorKey error: validator key not found. Are you sure you are a validator?")
20892090
#end define

0 commit comments

Comments
 (0)