From 7005be07740463ff4a1da3a78ddb1159a26a7603 Mon Sep 17 00:00:00 2001 From: zebra-lucky Date: Mon, 1 Dec 2025 03:49:23 +0200 Subject: [PATCH] fixes related to datetime/tzinfo --- scripts/obwatch/ob-watcher.py | 5 +++-- src/jmclient/wallet.py | 6 ++---- src/jmclient/wallet_utils.py | 10 ++++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/obwatch/ob-watcher.py b/scripts/obwatch/ob-watcher.py index ce6876b..cb49fbc 100755 --- a/scripts/obwatch/ob-watcher.py +++ b/scripts/obwatch/ob-watcher.py @@ -372,8 +372,9 @@ class OrderbookPageRequestHeader(http.server.SimpleHTTPRequestHandler): 2 * bitcoin_unit_to_power(html.unescape(btc_unit))), html.unescape(btc_unit)) conf_time_str = ( - str(datetime.datetime.fromtimestamp(0, datetime.UTC) + - datetime.timedelta(seconds=conf_time))) + datetime.datetime.fromtimestamp(0, datetime.UTC) + + datetime.timedelta(seconds=conf_time) + ).strftime('%Y-%m-%d %H:%M:%S') utxo_value_str = sat_to_unit(utxo_data["value"], html.unescape(btc_unit)) bondtable += ("" + elem(bond_data.maker_nick) diff --git a/src/jmclient/wallet.py b/src/jmclient/wallet.py index c7e05c0..8f5c484 100644 --- a/src/jmclient/wallet.py +++ b/src/jmclient/wallet.py @@ -849,8 +849,7 @@ class BaseWallet(object): "storage.") if not timestamp: - timestamp = datetime.datetime.now( - datetime.UTC).strftime('%Y/%m/%d %H:%M:%S') + timestamp = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S') storage.data[b'network'] = network.encode('ascii') storage.data[b'created'] = timestamp.encode('ascii') @@ -3715,8 +3714,7 @@ class FrostWallet(BIP39WalletMixin, BIP32PurposedFrostMixin): f'recovery storage wallet type: {cls.TYPE}.') if not timestamp: - timestamp = datetime.datetime.now( - datetime.UTC).strftime('%Y/%m/%d %H:%M:%S') + timestamp = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S') dkg_storage.data[b'network'] = bnetwork dkg_storage.data[b'created'] = timestamp.encode('ascii') diff --git a/src/jmclient/wallet_utils.py b/src/jmclient/wallet_utils.py index f4c4898..2ecf627 100644 --- a/src/jmclient/wallet_utils.py +++ b/src/jmclient/wallet_utils.py @@ -480,9 +480,10 @@ async def wallet_showutxos(wallet_service: WalletService, showprivkey: bool, if showprivkey: unsp[us]['privkey'] = wallet_service.get_wif_path(av['path']) if locktime: - unsp[us]["locktime"] = str( + unsp[us]["locktime"] = ( datetime.datetime.fromtimestamp(0, datetime.UTC) + - datetime.timedelta(seconds=locktime)) + datetime.timedelta(seconds=locktime) + ).strftime('%Y-%m-%d %H:%M:%S') used_commitments, external_commitments = podle.get_podle_commitments() for u, ec in external_commitments.items(): @@ -1454,9 +1455,10 @@ async def wallet_gettimelockaddress(wallet, locktime_string): jmprint("Error: not a fidelity bond wallet", "error") return "" - lock_datetime = datetime.datetime.strptime(locktime_string, "%Y-%m") + lock_datetime = datetime.datetime.strptime( + locktime_string, "%Y-%m").replace(tzinfo=datetime.UTC) if (jm_single().config.get("BLOCKCHAIN", "network") == "mainnet" - and lock_datetime <= datetime.datetime.now()): + and lock_datetime <= datetime.datetime.now(datetime.UTC)): jmprint("Error: locktime must be a future date", "error") return ""