diff --git a/src/handler/lib/policy.c b/src/handler/lib/policy.c index 688b5c6c0..5ea589338 100644 --- a/src/handler/lib/policy.c +++ b/src/handler/lib/policy.c @@ -237,6 +237,7 @@ static const generic_processor_command_t commands_or_i[] = {{CMD_CODE_OP, OP_IF} static const generic_processor_command_t commands_a[] = {{CMD_CODE_OP, OP_TOALTSTACK}, {CMD_CODE_PROCESS_CHILD, 0}, + {CMD_CODE_OP, OP_FROMALTSTACK}, {CMD_CODE_END, 0}}; static const generic_processor_command_t commands_s[] = {{CMD_CODE_OP, OP_SWAP}, diff --git a/tests/test_e2e_miniscript.py b/tests/test_e2e_miniscript.py index fea8a971a..f23bd6b53 100644 --- a/tests/test_e2e_miniscript.py +++ b/tests/test_e2e_miniscript.py @@ -302,27 +302,32 @@ def test_e2e_miniscript_me_and_bob_or_me_and_carl_1(rpc, rpc_test_wallet, client run_test_e2e(wallet_policy, [core_wallet_name1], rpc, rpc_test_wallet, client, speculos_globals, comm) -def test_e2e_miniscript_me_and_bob_or_me_and_carl_2(rpc, rpc_test_wallet, client: Client, speculos_globals: SpeculosGlobals, comm: Union[TransportClient, SpeculosClient]): - # same as the previous example, but uses the same xpubs with two different paths for the internal keys, - # by using the //* notation instead of different internal xpubs +def test_e2e_miniscript_policy_with_a(rpc, rpc_test_wallet, client: Client, speculos_globals: SpeculosGlobals, comm: Union[TransportClient, SpeculosClient]): + # versions 2.1.0 and 2.1.1 of the app incorrectly compiled the 'a:' wrapper, producing incorrect addresses - core_wallet_name1, core_xpub_orig1 = create_new_wallet() + _, core_xpub_orig1 = create_new_wallet() _, core_xpub_orig2 = create_new_wallet() + core_wallet_name3, core_xpub_orig3 = create_new_wallet() + _, core_xpub_orig4 = create_new_wallet() + _, core_xpub_orig5 = create_new_wallet() - path = "44'/1'/0'" + path = "48'/1'/0'/2'" internal_xpub = get_internal_xpub(speculos_globals.seed, path) internal_xpub_orig = f"[{speculos_globals.master_key_fingerprint.hex()}/{path}]{internal_xpub}" wallet_policy = WalletPolicy( - name="Me and Bob or me and Carl", - descriptor_template="wsh(c:andor(pk(@0/<0;1>/*),pk_k(@1/**),and_v(v:pk(@0/<2;3>/*),pk_k(@2/**))))", + name="Policy with a:", + descriptor_template="wsh(or_i(and_v(v:pkh(@0/**),older(65535)),or_d(multi(2,@1/**,@3/**),and_v(v:thresh(1,pkh(@4/**),a:pkh(@5/**)),older(64231)))))", keys_info=[ - internal_xpub_orig, f"{core_xpub_orig1}", + internal_xpub_orig, f"{core_xpub_orig2}", + f"{core_xpub_orig3}", + f"{core_xpub_orig4}", + f"{core_xpub_orig5}", ]) - run_test_e2e(wallet_policy, [core_wallet_name1], rpc, rpc_test_wallet, client, speculos_globals, comm) + run_test_e2e(wallet_policy, [core_wallet_name3], rpc, rpc_test_wallet, client, speculos_globals, comm) def test_invalid_miniscript(rpc, client: Client, speculos_globals: SpeculosGlobals):