Browse Source

fixes related to datetime/tzinfo

add_frost
zebra-lucky 2 weeks ago
parent
commit
7005be0774
  1. 5
      scripts/obwatch/ob-watcher.py
  2. 6
      src/jmclient/wallet.py
  3. 10
      src/jmclient/wallet_utils.py

5
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 += ("<tr>"
+ elem(bond_data.maker_nick)

6
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')

10
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 ""

Loading…
Cancel
Save