Skip to content

Commit 0a130ee

Browse files
committed
fix GetValidatorKey()
1 parent 6b257e5 commit 0a130ee

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mytoncore/mytoncore.py

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

19121912
def GetValidatorKey(self):
19131913
vconfig = self.GetValidatorConfig()
1914-
for validator in vconfig["validators"]:
1914+
validators = sorted(vconfig["validators"], key=lambda i: i['election_date'], reverse=True)
1915+
for validator in validators:
19151916
validatorId = validator["id"]
19161917
key_bytes = base64.b64decode(validatorId)
19171918
validatorKey = key_bytes.hex().upper()
19181919
timestamp = get_timestamp()
1919-
if timestamp > validator["election_date"]:
1920+
if validator["election_date"] < timestamp < validator["expire_at"]:
19201921
return validatorKey
19211922
raise Exception("GetValidatorKey error: validator key not found. Are you sure you are a validator?")
19221923
#end define

0 commit comments

Comments
 (0)