diff --git a/shared/ccc.py b/shared/ccc.py index 20db8652..0a7ec236 100644 --- a/shared/ccc.py +++ b/shared/ccc.py @@ -635,7 +635,7 @@ class CCCPolicyMenu(MenuSystem): self.policy = CCCFeature.update_policy_key(**args) - await ux_show_story(msg, title="Txn Magnitude") + await ux_show_story(msg, title="TX Magnitude") async def set_velocity(self, *a): mag = self.policy.get('mag', 0) or 0 @@ -828,7 +828,7 @@ async def modify_ccc_settings(): # directly into menu (super helpful for debug/setup/testing time). We do warn tho. await ux_show_story('''You have a copy of the CCC key C in the Seed Vault, so \ you may proceed to change settings now.\n\nYou must delete that key from the vault once \ -setup and debug is finished, or all benefit of this feature is lost!''') +setup and debug is finished, or all benefit of this feature is lost!''', title='REMINDER') bypass = True @@ -836,13 +836,9 @@ setup and debug is finished, or all benefit of this feature is lost!''') ch = await ux_show_story( "Spending policy cannot be viewed, changed nor disabled, " "unless you have the seed words for key C.", - title="CCC Enabled", escape='6') + title="CCC Enabled") - if ch == '6' and version.is_devmode: - # debug hack: skip word entry - bypass = True - - elif ch != 'y': return + if ch != 'y': return if bypass: # doing full decode cycle here for better testing diff --git a/shared/chains.py b/shared/chains.py index f3d9675a..87385711 100644 --- a/shared/chains.py +++ b/shared/chains.py @@ -274,13 +274,17 @@ class ChainsBase: # Given a text (serialized) address, return what # address format applies to the address, but # for AF_P2SH case, could be: AF_P2SH, AF_P2WPKH_P2SH, AF_P2WSH_P2SH. .. we don't know - if addr.startswith(cls.bech32_hrp): - if addr.startswith(cls.bech32_hrp+'1p'): - # really any ver=1 script or address, but for now... + hrp = cls.bech32_hrp + "1" + if addr.startswith(hrp): + if addr.startswith(hrp+'p'): + # segwit v1 (any ver=1 script or address, but for now just taproot...) return AF_P2TR - else: + elif addr.startswith(hrp+'q'): + # segwit v0 return AF_P2WPKH if len(addr) < 55 else AF_P2WSH + return 0 + try: raw = ngu.codecs.b58_decode(addr) except ValueError: diff --git a/testing/test_ownership.py b/testing/test_ownership.py index 35db83df..9f4203b1 100644 --- a/testing/test_ownership.py +++ b/testing/test_ownership.py @@ -315,4 +315,44 @@ def test_address_explorer_saver(af, wipe_cache, settings_set, goto_address_explo else: assert af in story + +def test_regtest_addr_on_mainnet(goto_home, is_q1, pick_menu_item, scan_a_qr, nfc_write, cap_story, + need_keypress, load_shared_mod, use_mainnet): + # testing bug in chains.possible_address_fmt + # allowed regtest addresses to be allowed on main chain + goto_home() + use_mainnet() + addr = "bcrt1qmff7njttlp6tqtj0nq7svcj2p9takyqm3mfl06" + if is_q1: + pick_menu_item('Scan Any QR Code') + scan_a_qr(addr) + time.sleep(1) + + title, story = cap_story() + + assert addr == addr_from_display_format(story.split("\n\n")[0]) + assert '(1) to verify ownership' in story + need_keypress('1') + + else: + cc_ndef = load_shared_mod('cc_ndef', '../shared/ndef.py') + n = cc_ndef.ndefMaker() + n.add_text(addr) + ccfile = n.bytes() + + # run simulator w/ --set nfc=1 --eff + pick_menu_item('Advanced/Tools') + pick_menu_item('NFC Tools') + pick_menu_item('Verify Address') + open('debug/nfc-addr.ndef', 'wb').write(ccfile) + nfc_write(ccfile) + # press_select() + + time.sleep(1) + title, story = cap_story() + assert addr == addr_from_display_format(story.split("\n\n")[0]) + + assert title == 'Unknown Address' + assert "not valid on Bitcoin Mainnet" in story + # EOF