Browse Source

Merge #857: Fix year 2038 problem in fidelity bond wallets

1d74222 Fix year 2038 problem in fidelity bond wallets (chris-belcher)

Tree-SHA512: 1a975818aa01f90ce132e0a7761965fcb67ea6fe22f29d38609ebe2900217b9125458714f195d731bc5c8919c6ed6b1827ddf7fd201ca6c25b67235eb7088ce5
master
chris-belcher 5 years ago
parent
commit
12cdea317a
No known key found for this signature in database
GPG Key ID: EF734EA677F31129
  1. 6
      jmclient/jmclient/wallet.py

6
jmclient/jmclient/wallet.py

@ -9,7 +9,7 @@ import copy
import base64 import base64
import json import json
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from datetime import datetime from datetime import datetime, timedelta
from calendar import timegm from calendar import timegm
from copy import deepcopy from copy import deepcopy
from mnemonic import Mnemonic as MnemonicParent from mnemonic import Mnemonic as MnemonicParent
@ -2231,7 +2231,9 @@ class FidelityBondMixin(object):
""" """
converts a datetime object to a time number converts a datetime object to a time number
""" """
dt = datetime.utcfromtimestamp(timestamp) #workaround for the year 2038 problem on 32 bit systems
#see https://stackoverflow.com/questions/10588027/converting-timestamps-larger-than-maxint-into-datetime-objects
dt = datetime.utcfromtimestamp(0) + timedelta(seconds=timestamp)
if (dt.month - cls.TIMELOCK_EPOCH_MONTH) % cls.TIMENUMBER_UNIT != 0: if (dt.month - cls.TIMELOCK_EPOCH_MONTH) % cls.TIMENUMBER_UNIT != 0:
raise ValueError() raise ValueError()
day_and_shorter_tuple = (dt.day, dt.hour, dt.minute, dt.second, dt.microsecond) day_and_shorter_tuple = (dt.day, dt.hour, dt.minute, dt.second, dt.microsecond)

Loading…
Cancel
Save