@@ -197,11 +197,19 @@ BOOST_AUTO_TEST_CASE(script_standard_Solver_failure)
197
197
s << OP_RETURN << std::vector<unsigned char >({75 }) << OP_ADD;
198
198
BOOST_CHECK_EQUAL (Solver (s, solutions), TxoutType::NONSTANDARD);
199
199
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)
201
201
s.clear ();
202
202
s << OP_0 << std::vector<unsigned char >(19 , 0x01 );
203
203
BOOST_CHECK_EQUAL (Solver (s, solutions), TxoutType::NONSTANDARD);
204
204
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
+
205
213
// TxoutType::ANCHOR but wrong witness version
206
214
s.clear ();
207
215
s << OP_2 << std::vector<unsigned char >{0x4e , 0x73 };
@@ -268,12 +276,33 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
268
276
BOOST_CHECK (ExtractDestination (s, address));
269
277
BOOST_CHECK (std::get<WitnessV0ScriptHash>(address) == scripthash);
270
278
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
+
271
293
// TxoutType::WITNESS_UNKNOWN with unknown version
294
+ // -> segwit version 1 with an undefined program size (33 bytes in this test case)
272
295
s.clear ();
273
296
s << OP_1 << ToByteVector (pubkey);
274
297
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);
277
306
}
278
307
279
308
BOOST_AUTO_TEST_CASE (script_standard_GetScriptFor_)
@@ -341,6 +370,20 @@ BOOST_AUTO_TEST_CASE(script_standard_GetScriptFor_)
341
370
expected << OP_0 << ToByteVector (scriptHash);
342
371
result = GetScriptForDestination (WitnessV0ScriptHash (witnessScript));
343
372
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);
344
387
}
345
388
346
389
BOOST_AUTO_TEST_CASE (script_standard_taproot_builder)
0 commit comments