@@ -197,11 +197,19 @@ BOOST_AUTO_TEST_CASE(script_standard_Solver_failure)
197197 s << OP_RETURN << std::vector<unsigned char >({75 }) << OP_ADD;
198198 BOOST_CHECK_EQUAL (Solver (s, solutions), TxoutType::NONSTANDARD);
199199
200- // TxoutType::WITNESS_UNKNOWN with incorrect program size
200+ // TxoutType::WITNESS_V0_{KEY,SCRIPT}HASH with incorrect program size (-> consensus-invalid, i.e. non-standard)
201201 s.clear ();
202202 s << OP_0 << std::vector<unsigned char >(19 , 0x01 );
203203 BOOST_CHECK_EQUAL (Solver (s, solutions), TxoutType::NONSTANDARD);
204204
205+ // TxoutType::WITNESS_V1_TAPROOT with incorrect program size (-> undefined, but still policy-valid)
206+ s.clear ();
207+ s << OP_1 << std::vector<unsigned char >(31 , 0x01 );
208+ BOOST_CHECK_EQUAL (Solver (s, solutions), TxoutType::WITNESS_UNKNOWN);
209+ s.clear ();
210+ s << OP_1 << std::vector<unsigned char >(33 , 0x01 );
211+ BOOST_CHECK_EQUAL (Solver (s, solutions), TxoutType::WITNESS_UNKNOWN);
212+
205213 // TxoutType::ANCHOR but wrong witness version
206214 s.clear ();
207215 s << OP_2 << std::vector<unsigned char >{0x4e , 0x73 };
@@ -268,12 +276,33 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
268276 BOOST_CHECK (ExtractDestination (s, address));
269277 BOOST_CHECK (std::get<WitnessV0ScriptHash>(address) == scripthash);
270278
279+ // TxoutType::WITNESS_V1_TAPROOT
280+ s.clear ();
281+ auto xpk = XOnlyPubKey (pubkey);
282+ s << OP_1 << ToByteVector (xpk);
283+ BOOST_CHECK (ExtractDestination (s, address));
284+ BOOST_CHECK (std::get<WitnessV1Taproot>(address) == WitnessV1Taproot (xpk));
285+
286+ // TxoutType::ANCHOR
287+ std::vector<unsigned char > anchor_bytes{0x4e , 0x73 };
288+ s.clear ();
289+ s << OP_1 << anchor_bytes;
290+ BOOST_CHECK (ExtractDestination (s, address));
291+ BOOST_CHECK (std::get<PayToAnchor>(address) == PayToAnchor ());
292+
271293 // TxoutType::WITNESS_UNKNOWN with unknown version
294+ // -> segwit version 1 with an undefined program size (33 bytes in this test case)
272295 s.clear ();
273296 s << OP_1 << ToByteVector (pubkey);
274297 BOOST_CHECK (ExtractDestination (s, address));
275- WitnessUnknown unk{1 , ToByteVector (pubkey)};
276- BOOST_CHECK (std::get<WitnessUnknown>(address) == unk);
298+ WitnessUnknown unk_v1{1 , ToByteVector (pubkey)};
299+ BOOST_CHECK (std::get<WitnessUnknown>(address) == unk_v1);
300+ s.clear ();
301+ // -> segwit versions 2+ are not specified yet
302+ s << OP_2 << ToByteVector (xpk);
303+ BOOST_CHECK (ExtractDestination (s, address));
304+ WitnessUnknown unk_v2{2 , ToByteVector (xpk)};
305+ BOOST_CHECK (std::get<WitnessUnknown>(address) == unk_v2);
277306}
278307
279308BOOST_AUTO_TEST_CASE (script_standard_GetScriptFor_)
@@ -341,6 +370,20 @@ BOOST_AUTO_TEST_CASE(script_standard_GetScriptFor_)
341370 expected << OP_0 << ToByteVector (scriptHash);
342371 result = GetScriptForDestination (WitnessV0ScriptHash (witnessScript));
343372 BOOST_CHECK (result == expected);
373+
374+ // WitnessV1Taproot
375+ auto xpk = XOnlyPubKey (pubkeys[0 ]);
376+ expected.clear ();
377+ expected << OP_1 << ToByteVector (xpk);
378+ result = GetScriptForDestination (WitnessV1Taproot (xpk));
379+ BOOST_CHECK (result == expected);
380+
381+ // PayToAnchor
382+ std::vector<unsigned char > anchor_bytes{0x4e , 0x73 };
383+ expected.clear ();
384+ expected << OP_1 << anchor_bytes;
385+ result = GetScriptForDestination (PayToAnchor ());
386+ BOOST_CHECK (result == expected);
344387}
345388
346389BOOST_AUTO_TEST_CASE (script_standard_taproot_builder)
0 commit comments