From 1d74222c3720e172334b7e2e09c288aa65864ab9 Mon Sep 17 00:00:00 2001 From: chris-belcher Date: Mon, 19 Apr 2021 16:10:19 +0100 Subject: [PATCH] Fix year 2038 problem in fidelity bond wallets Only showed up on 32 bit architectures. See issue #798 --- jmclient/jmclient/wallet.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jmclient/jmclient/wallet.py b/jmclient/jmclient/wallet.py index f653ba2..8c24e59 100644 --- a/jmclient/jmclient/wallet.py +++ b/jmclient/jmclient/wallet.py @@ -9,7 +9,7 @@ import copy import base64 import json from binascii import hexlify, unhexlify -from datetime import datetime +from datetime import datetime, timedelta from calendar import timegm from copy import deepcopy from mnemonic import Mnemonic as MnemonicParent @@ -2231,7 +2231,9 @@ class FidelityBondMixin(object): """ 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: raise ValueError() day_and_shorter_tuple = (dt.day, dt.hour, dt.minute, dt.second, dt.microsecond)