miniscript rename test

This commit is contained in:
scgbckbone 2025-10-10 16:18:34 +02:00
parent 4ea01f7d04
commit 89bdf2d499
4 changed files with 62 additions and 9 deletions

View File

@ -15,13 +15,15 @@ This lists the changes in the most recent EDGE firmware, for each hardware platf
- New Feature: Key Teleport
- New Feature: Spending Policy for Miniscript Wallets
- New Feature: Internal descriptor cache speeding up sequential operation with miniscript wallets.
- New Feature: Internal descriptor cache speeding up sequential operation with miniscript wallets.
To take full advantage of the feature work with miniscript wallets sequentially. First, do all operations
needed with `wallet1` before changing to `wallet2`.
- New Feature: Add ability to import/export [BIP-388](https://github.com/bitcoin/bips/blob/master/bip-0388.mediawiki) Wallet Policies.
BIP-388 policies are now also used as our wallets serialization format, which optimized our setting storage.
- New Feature: Sign with specific miniscript wallet. `Settings -> Miniscript -> <name> -> Sign PSBT`
- New Feature: Miniscript wallet name can be specified for `sign` USB command
- New Feature: Rename Miniscript wallet via UX. `Settings -> Miniscript -> <wallet> -> Rename`.
Old functionality - renaming by reimporting descriptor with different name was removed.
- Change: Everything is miniscript now. To import multisig wallets go to `Settings -> Miniscript`
- Enhancement: Slightly faster HW accelerated tagged hash
- Enhancement: PSBT class optimizations. Ability to sign bigger txn.

View File

@ -283,7 +283,7 @@ async def ux_input_text(pw, confirm_exit=True, hex_only=False, max_len=100, min_
ch = await press.wait()
if ch == 'y':
if len(pw) < min_len:
ch = await ux_show_story('Need %d characters at least. Press OK '
ch = await ux_show_story('Need %d character(s) at least. Press OK '
'to continue X to exit.' % min_len, escape="xy",
strict_escape=True)
if ch == "x": return

View File

@ -24,7 +24,7 @@ TRUST_OFFER = const(1)
TRUST_PSBT = const(2)
MAX_BIP32_IDX = (2 ** 31) - 1
MAX_NAME_LEN = 20
class WalletOutOfSpace(RuntimeError):
pass
@ -159,7 +159,7 @@ class MiniScriptWallet(WalletABC):
def __init__(self, name, desc_tmplt, keys_info, af, ik_u=None,
desc=None, m_n=None, bip67=None, chain_type=None):
assert 1 <= len(name) <= 20, "name len"
assert 1 <= len(name) <= MAX_NAME_LEN, "name len"
self.storage_idx = -1
self.name = name
@ -915,7 +915,7 @@ async def miniscript_wallet_rename(menu, label, item):
idx, msc = item.arg
new_name = await ux_input_text(msc.name, confirm_exit=False,
min_len=1, max_len=20) # TODO should be a constant
min_len=1, max_len=MAX_NAME_LEN)
if not new_name:
return
@ -1410,7 +1410,7 @@ async def multisig_640_migration(multisig_wallets):
if name in taken_names:
# name collision with miniscript
name = name + "1"
if len(name) > 20:
if len(name) > MAX_NAME_LEN:
# issue
name = name[:15] + "mig1"

View File

@ -6,7 +6,7 @@ import pytest, json, time, itertools, struct, random, os, base64
from ckcc.protocol import CCProtocolPacker
from constants import AF_P2TR
from psbt import BasicPSBT
from charcodes import KEY_QR, KEY_RIGHT, KEY_CANCEL
from charcodes import KEY_QR, KEY_RIGHT, KEY_CANCEL, KEY_DELETE
from bbqr import split_qrs
from bip32 import BIP32Node
@ -3289,7 +3289,58 @@ def test_bip388_policies(desc, way, offer_minsc_import, press_select, pick_menu_
assert usb_miniscript_get(new_name)["desc"].split("#")[0] == desc.split("#")[0].replace("'", 'h')
def test_miniscript_rename():
pass
def test_miniscript_rename(offer_minsc_import, clear_miniscript, press_select, goto_home,
pick_menu_item, enter_complex, cap_menu, cap_screen, is_q1,
need_keypress, press_cancel):
clear_miniscript()
name = "old_name"
title, story = offer_minsc_import(json.dumps(dict(name=name, desc=CHANGE_BASED_DESCS[0])))
assert "old_name" in story
assert "Create new miniscript wallet?" in story
press_select()
goto_home()
pick_menu_item("Settings")
pick_menu_item("Miniscript")
pick_menu_item(name)
pick_menu_item("Rename")
if is_q1:
# old name is filled in input field
# same for Mk4, just not possible with cap_screen, or cap_story
time.sleep(.1)
scr = cap_screen()
assert name in scr
new_name = 25 * "0"
# first delete old one
for _ in range(len(name) - (0 if is_q1 else 1)):
need_keypress(KEY_DELETE if is_q1 else "x")
if is_q1:
# attempt to use empty string as a name
# on Mk4 it is not possible to not have at least one char
press_select()
time.sleep(.1)
scr = cap_screen()
assert "Need 1" in scr
# it is not possible to input more than 20 characters
enter_complex(new_name, apply=False, b39pass=False)
real_name = new_name[:20]
# specific wallet menu has changed
time.sleep(.1)
m = cap_menu()
assert name not in m
assert real_name == m[0]
# miniscript wallets menu has changed
press_cancel() # one back
time.sleep(.1)
m = cap_menu()
assert name not in m
assert real_name == m[0]
# EOF