feat(bal): Group A (timestamps + statuses + anticipate docs) and Group B (auto-sign) v0.3.4

Bump plugin version to 0.3.4 (manifest, __init__, plugin_base, VERSION).

GROUP A
- A1: remove block-height locktimes; the plugin now uses UNIX timestamps
  only. The NLOCKTIME_BLOCKHEIGHT_MAX guard is kept on purpose (it forces
  every locktime to be a timestamp). chk_locktime is now 2-arg; int_locktime
  and anticipate_locktime no longer accept blocks; RAW input only accepts d/y.
  Two now-dormant configs (LOCKTIME_BLOCKS, LOCKTIMEDELTA_BLOCKS) are kept with
  comments to avoid touching persisted keys.
- A2: rename PENDING -> MEMPOOL everywhere (label 'Mempool', yellow #ffce30);
  add new UPDATED status; ANTICIPATED & UPDATED keep VALID; documented
  set_status rules; backward-compat migration (old PENDING -> MEMPOOL).
- A3: clarify that anticipating to a future date only rebuilds (never
  invalidates), while only a past locktime invalidates (WillExpired). Code was
  already correct; only the comment and docs were fixed.

Colour follow-up: UPDATED lightened from #800080 to #b266b2 (more readable),
updated in theme.py, docs and the theme test.

GROUP B
- B1: verified the 'Create your will' button already opens the guided wizard
  (no code change needed).
- B2: new persisted AUTO_SIGN setting (default ON) with an 'Auto-sign on Check'
  checkbox in the settings dialog. When enabled, Check signs and broadcasts
  automatically; the wallet password is requested only for encrypted wallets.

B2 follow-up (fixes reported after testing):
- Remove the duplicate sign/broadcast cycle in lists.check(); build_will_task()
  already signs and broadcasts.
- Suppress the manual 'press Sign/Broadcast' hint and its popup when AUTO_SIGN
  is ON (kept when OFF).
- Make broadcast one-shot: removed the retry flag and the Exception('retry');
  failed will-executors stay PUSH_FAIL and are skipped (no endless retry).
  PUSHED transactions are already excluded from re-collection.

Docs: inheritance-options.md/.html and inheritance-flow.svg updated to v0.3.4.
Tests: 206 passing (new test_anticipate_manual_locktime, test_anticipate_past_locktime,
test_group_b_auto_sign; updated core/util, core/will_extra, gui/theme, gui/widgets).
CHANGELOG.md added with one numbered entry per task.
This commit is contained in:
2026-06-28 23:00:23 -04:00
parent 10d0b85779
commit dc166d04ff
23 changed files with 1374 additions and 205 deletions

View File

@@ -24,7 +24,13 @@ from electrum.transaction import PartialTxOutput
# Bitcoin consensus rule: an nLockTime value strictly below this threshold is
# interpreted as a *block height*, otherwise it is interpreted as a *UNIX
# timestamp*. This single constant drives most of the locktime handling below.
# timestamp*.
#
# The plugin now uses ONLY timestamp-based locktimes (block-height locktimes
# were removed so that every locktime can be compared and ordered consistently).
# This constant is kept as a guard: it is the boundary that lets us reject any
# value that would fall in the block-height range and force every locktime to be
# a timestamp.
LOCKTIME_THRESHOLD = 500000000
@@ -56,11 +62,16 @@ class Util:
def str_to_locktime(locktime):
"""Parse a user-entered locktime string into its stored form.
Relative values keep their suffix (``"30d"``, ``"1y"``, ``"144b"``);
absolute ISO dates are converted to an integer UNIX timestamp.
Relative values keep their suffix (``"30d"``, ``"1y"``); absolute ISO
dates are converted to an integer UNIX timestamp.
Note: only timestamp-based locktimes are supported. The legacy
block-height suffix ``"b"`` has been removed on purpose, so that every
locktime in the plugin is a UNIX timestamp and can always be compared
and ordered consistently.
"""
try:
if locktime[-1] in ("y", "d", "b"):
if locktime[-1] in ("y", "d"):
return locktime
else:
return int(locktime)
@@ -78,8 +89,12 @@ class Util:
* plain int / timestamp -> returned unchanged
* ``"<n>y"`` -> n years from now (as a timestamp)
* ``"<n>d"`` -> n days from now (as a timestamp)
* ``"<n>b"`` -> current block height + n (needs wallet
``w`` to read the chain height)
Note: the legacy block-height form ``"<n>b"`` has been removed on
purpose. Every locktime is now a UNIX timestamp, so locktimes can
always be compared and ordered consistently. The optional ``w``
(wallet) argument is kept only for backward call-site compatibility and
is no longer used.
"""
try:
return int(locktime)
@@ -96,26 +111,23 @@ class Util:
.replace(hour=0, minute=0, second=0, microsecond=0)
.timestamp()
)
if locktime[-1] == "b":
locktime = int(locktime[:-1])
height = 0
if w:
height = Util.get_current_height(w.network)
locktime += int(height)
return int(locktime)
except Exception:
pass
return 0
@staticmethod
def int_locktime(seconds=0, minutes=0, hours=0, days=0, blocks=0):
"""Convert a human duration into seconds (blocks counted as 600s each)."""
def int_locktime(seconds=0, minutes=0, hours=0, days=0):
"""Convert a human duration into seconds.
Note: the ``blocks`` argument was removed together with block-height
support; every duration is now expressed in plain time units.
"""
return int(
seconds
+ minutes * 60
+ hours * 60 * 60
+ days * 60 * 60 * 24
+ blocks * 600
)
# ------------------------------------------------------------------ #
@@ -337,43 +349,35 @@ class Util:
# Locktime arithmetic
# ------------------------------------------------------------------ #
@staticmethod
def chk_locktime(timestamp_to_check, block_height_to_check, locktime):
"""Return True if ``locktime`` is still in the future.
def chk_locktime(timestamp_to_check, locktime):
"""Return True if ``locktime`` (a UNIX timestamp) is still in the future.
Timestamp-style and block-height-style locktimes are compared against
the respective "to_check" reference value.
Only timestamp-based locktimes are supported now; the previous
block-height branch was removed together with block-height support.
"""
# TODO BUG: WHAT HAPPEN AT THRESHOLD?
locktime = int(locktime)
if locktime > LOCKTIME_THRESHOLD and locktime > timestamp_to_check:
return True
elif locktime < LOCKTIME_THRESHOLD and locktime > block_height_to_check:
return True
else:
return False
return locktime > int(timestamp_to_check)
@staticmethod
def anticipate_locktime(locktime, blocks=0, hours=0, days=0):
"""Move a locktime earlier by the given amount.
def anticipate_locktime(locktime, hours=0, days=0):
"""Move a timestamp locktime earlier by the given amount.
Works on both timestamp and block-height locktimes; never returns a
value below 1.
Every locktime is a UNIX timestamp now, so this simply subtracts the
requested time span. The result is never allowed to drop below 1.
Note: the legacy ``blocks`` argument and the block-height branch were
removed; only timestamp arithmetic remains.
"""
locktime = int(locktime)
out = 0
if locktime > LOCKTIME_THRESHOLD:
seconds = blocks * 600 + hours * 3600 + days * 86400
# On Windows datetime.fromtimestamp raises OverflowError past 2038
# (e.g. NLOCKTIME_MAX); clamp to INT32_MAX (Electrum issue #6170).
try:
dt = datetime.fromtimestamp(locktime)
except (OverflowError, OSError, ValueError):
dt = datetime.fromtimestamp(min(locktime, 2 ** 31 - 1))
dt -= timedelta(seconds=seconds)
out = dt.timestamp()
else:
blocks -= hours * 6 + days * 144
out = locktime + blocks
seconds = hours * 3600 + days * 86400
# On Windows datetime.fromtimestamp raises OverflowError past 2038
# (e.g. NLOCKTIME_MAX); clamp to INT32_MAX (Electrum issue #6170).
try:
dt = datetime.fromtimestamp(locktime)
except (OverflowError, OSError, ValueError):
dt = datetime.fromtimestamp(min(locktime, 2 ** 31 - 1))
dt -= timedelta(seconds=seconds)
out = dt.timestamp()
if out < 1:
out = 1