Add middle-dots character to font, use arrows/dots in address explorer menu; tweaks.

This commit is contained in:
Peter D. Gray 2023-05-16 15:16:10 +02:00 committed by doc-hex
parent 0874324372
commit 9b2ef862cb
4 changed files with 37 additions and 24 deletions

View File

@ -9,7 +9,6 @@ font_files = {
}
# test with:
#
# ./build.py build --portable && ./testit.py --msg "hello→world←\n↳this\n•Bullet\n•Text" -f small
#
special_chars = dict(small=[
@ -65,5 +64,14 @@ special_chars = dict(small=[
xxxxx
'''),
('', dict(y=0), '''\
x x x x x
'''),
])

View File

@ -3,9 +3,9 @@
- Enhancement: change Key Origin Information export format in multisig `addresses.csv` to match
[BIP-0380](https://github.com/bitcoin/bips/blob/master/bip-0380.mediawiki#key-expressions)
`(m=0F056943)/m/48'/1'/0'/2'/0/0` --> `[0F056943/48'/1'/0'/2'/0/0]`
- Enhancement: Address explorer UX cosmetics.
- Bugfix: correct `scriptPubkey` parsing for segwit v1-v16
- Bugfix: do not infer segwit just by availability of `PSBT_IN_WITNESS_UTXO` in PSBT. Improves
compatibility with Bitcoin Core.
- Bugfix: do not infer segwit just by availability of `PSBT_IN_WITNESS_UTXO` in PSBT.
- Bugfix: remove label from Bitcoin Core `importdescriptors` export as it is no longer supported
with ranged descriptors in version `24.1`

View File

@ -18,8 +18,10 @@ from utils import addr_fmt_label
def truncate_address(addr):
# Truncates address to width of screen, replacing middle chars
# - 16 chars screen width, so show 8 prefix, dash, and 7 of end of address
return addr[0:8] + '-' + addr[-7:]
# - 16 chars screen width
# - but 2 lost at left (menu arrow, corner arrow)
# - want to show not truncated on right side
return addr[0:5] + '' + addr[-6:]
class KeypathMenu(MenuSystem):
def __init__(self, path=None, nl=0):
@ -28,14 +30,14 @@ class KeypathMenu(MenuSystem):
if path is None:
# Top level menu; useful shortcuts, and special case just "m"
items = [
MenuItem("m/..", f=self.deeper),
MenuItem("m/49'/..", f=self.deeper),
MenuItem("m/84'/..", f=self.deeper),
MenuItem("m/44'/..", f=self.deeper),
MenuItem("m/0/{idx}", menu=self.done),
MenuItem("m/{idx}", menu=self.done),
MenuItem("m", f=self.done),
]
MenuItem("m/..", f=self.deeper),
MenuItem("m/44'/..", f=self.deeper),
MenuItem("m/49'/..", f=self.deeper),
MenuItem("m/84'/..", f=self.deeper),
MenuItem("m/0/{idx}", menu=self.done),
MenuItem("m/{idx}", menu=self.done),
MenuItem("m", f=self.done),
]
else:
# drill down one layer: (nl) is the current leaf
# - hardened choice first
@ -183,12 +185,12 @@ class AddressListMenu(MenuSystem):
items = []
for i, (address, path, addr_fmt) in enumerate(choices):
axi = address[-4:] # last 4 address characters
items.append(MenuItem(" "+addr_fmt_label(addr_fmt), f=self.pick_single,
items.append(MenuItem(addr_fmt_label(addr_fmt), f=self.pick_single,
arg=(path, addr_fmt, axi)))
items.append(MenuItem(address, f=self.pick_single,
items.append(MenuItem(''+address, f=self.pick_single,
arg=(path, addr_fmt, axi)))
# some other choices
# some other choices
if self.account_num == 0:
items.append(MenuItem("Applications", menu=ApplicationsMenu(self)))
items.append(MenuItem("Account Number", f=self.change_account))
@ -374,7 +376,7 @@ def generate_address_csv(path, addr_fmt, ms_wallet, account_num, n, start=0, cha
if ms_wallet:
# For multisig, include redeem script and derivation for each signer
yield '"' + '","'.join(['Index', 'Payment Address',
'Redeem Script (%d of %d)' % (ms_wallet.M, ms_wallet.N)]
'Redeem Script (%d of %d)' % (ms_wallet.M, ms_wallet.N)]
+ (['Derivation'] * ms_wallet.N)) + '"\n'
for (idx, derivs, addr, script) in ms_wallet.yield_addresses(start, n, change_idx=change):

View File

@ -31,12 +31,13 @@ class FontBase:
class FontSmall(FontBase):
height = 14
code_range = range(32, 8627)
code_range = range(32, 8943)
_bboxes = [None, (0, -3, 7, 14, 0), (0, -3, 7, 14, 4), (0, -3, 7,
14, 5), (0, -3, 7, 14, 7), (0, -3, 7, 14, 9), (0, -3, 7, 14, 10),
(0, -3, 7, 14, 11), (0, -3, 7, 14, 12), (0, -3, 7, 14, 13), (0, -3,
7, 14, 14), (0, 0, 8, 8, 8), (0, 0, 11, 9, 18), (0, 0, 14, 10, 20)]
7, 14, 14), (0, 0, 8, 8, 8), (0, 0, 11, 8, 16), (0, 0, 11, 9, 18),
(0, 0, 14, 10, 20)]
_code_points = [
(range(32, 127), [1, 2, 14, 20, 31, 43, 55, 67, 73, 87, 101, 111, 122,
@ -51,6 +52,7 @@ class FontSmall(FontBase):
(range(8592, 8593), [1145]), # ←
(range(8594, 8595), [1166]), # →
(range(8627, 8628), [1187]), # ↳
(range(8943, 8944), [1208]), # ⋯
]
_bitmaps = b"""\
@ -116,12 +118,13 @@ class FontSmall(FontBase):
\x3a\x02\x02\x42\x3c\x07\x00\x00\x00\x00\x7e\x02\x04\x08\x10\x20\x7e\x09\
\x06\x08\x08\x08\x08\x08\x30\x08\x08\x08\x08\x08\x06\x08\x10\x10\x10\x10\
\x10\x10\x10\x10\x10\x10\x10\x10\x09\x60\x10\x10\x10\x10\x10\x0c\x10\x10\
\x10\x10\x10\x60\x03\x00\x00\x32\x4a\x44\x0c\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x03\x80\x03\x80\x03\x80\x00\x00\x0d\x00\x00\x00\x00\x00\x00\
\x00\x00\x08\x00\x18\x00\x3f\xf8\x18\x00\x08\x00\x00\x00\x0d\x00\x00\x00\
\x00\x00\x00\x00\x00\x00\x20\x00\x30\x3f\xf8\x00\x30\x00\x20\x00\x00\x0d\
\x10\x10\x10\x60\x03\x00\x00\x32\x4a\x44\x0d\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x03\x80\x03\x80\x03\x80\x00\x00\x0e\x00\x00\x00\x00\x00\x00\
\x00\x00\x08\x00\x18\x00\x3f\xf8\x18\x00\x08\x00\x00\x00\x0e\x00\x00\x00\
\x00\x00\x00\x00\x00\x00\x20\x00\x30\x3f\xf8\x00\x30\x00\x20\x00\x00\x0e\
\x00\x00\x10\x00\x10\x00\x10\x00\x10\x20\x10\x30\x1f\xf8\x00\x30\x00\x20\
\x00\x00\
\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2a\xa0\x00\
\x00\
"""