@@ -488,6 +488,88 @@ BOOST_AUTO_TEST_CASE(script_standard_IsMine)
488
488
BOOST_CHECK_EQUAL (result, ISMINE_SPENDABLE);
489
489
}
490
490
491
+ // (P2PKH inside) P2SH inside P2SH (invalid)
492
+ {
493
+ CBasicKeyStore keystore;
494
+
495
+ CScript redeemscript, redeemscript_inner;
496
+ redeemscript_inner << OP_DUP << OP_HASH160 << ToByteVector (pubkeys[0 ].GetID ()) << OP_EQUALVERIFY << OP_CHECKSIG;
497
+ redeemscript << OP_HASH160 << ToByteVector (CScriptID (redeemscript_inner)) << OP_EQUAL;
498
+
499
+ scriptPubKey.clear ();
500
+ scriptPubKey << OP_HASH160 << ToByteVector (CScriptID (redeemscript)) << OP_EQUAL;
501
+
502
+ keystore.AddCScript (redeemscript);
503
+ keystore.AddCScript (redeemscript_inner);
504
+ keystore.AddCScript (scriptPubKey);
505
+ keystore.AddKey (keys[0 ]);
506
+ result = IsMine (keystore, scriptPubKey);
507
+ BOOST_CHECK_EQUAL (result, ISMINE_NO);
508
+ }
509
+
510
+ // (P2PKH inside) P2SH inside P2WSH (invalid)
511
+ {
512
+ CBasicKeyStore keystore;
513
+
514
+ CScript witnessscript, redeemscript;
515
+ redeemscript << OP_DUP << OP_HASH160 << ToByteVector (pubkeys[0 ].GetID ()) << OP_EQUALVERIFY << OP_CHECKSIG;
516
+ witnessscript << OP_HASH160 << ToByteVector (CScriptID (redeemscript)) << OP_EQUAL;
517
+
518
+ uint256 scripthash;
519
+ CSHA256 ().Write (witnessscript.data (), witnessscript.size ()).Finalize (scripthash.begin ());
520
+ scriptPubKey.clear ();
521
+ scriptPubKey << OP_0 << ToByteVector (scripthash);
522
+
523
+ keystore.AddCScript (witnessscript);
524
+ keystore.AddCScript (redeemscript);
525
+ keystore.AddCScript (scriptPubKey);
526
+ keystore.AddKey (keys[0 ]);
527
+ result = IsMine (keystore, scriptPubKey);
528
+ BOOST_CHECK_EQUAL (result, ISMINE_NO);
529
+ }
530
+
531
+ // P2WPKH inside P2WSH (invalid)
532
+ {
533
+ CBasicKeyStore keystore;
534
+
535
+ CScript witnessscript;
536
+ witnessscript << OP_0 << ToByteVector (pubkeys[0 ].GetID ());
537
+
538
+ scriptPubKey.clear ();
539
+ uint256 scripthash;
540
+ CSHA256 ().Write (witnessscript.data (), witnessscript.size ()).Finalize (scripthash.begin ());
541
+ scriptPubKey << OP_0 << ToByteVector (scripthash);
542
+
543
+ keystore.AddCScript (witnessscript);
544
+ keystore.AddCScript (scriptPubKey);
545
+ keystore.AddKey (keys[0 ]);
546
+ result = IsMine (keystore, scriptPubKey);
547
+ BOOST_CHECK_EQUAL (result, ISMINE_NO);
548
+ }
549
+
550
+ // (P2PKH inside) P2WSH inside P2WSH (invalid)
551
+ {
552
+ CBasicKeyStore keystore;
553
+
554
+ CScript witnessscript_inner;
555
+ witnessscript_inner << OP_DUP << OP_HASH160 << ToByteVector (pubkeys[0 ].GetID ()) << OP_EQUALVERIFY << OP_CHECKSIG;
556
+ uint256 scripthash;
557
+ CSHA256 ().Write (witnessscript_inner.data (), witnessscript_inner.size ()).Finalize (scripthash.begin ());
558
+ CScript witnessscript;
559
+ witnessscript << OP_0 << ToByteVector (scripthash);
560
+
561
+ scriptPubKey.clear ();
562
+ CSHA256 ().Write (witnessscript.data (), witnessscript.size ()).Finalize (scripthash.begin ());
563
+ scriptPubKey << OP_0 << ToByteVector (scripthash);
564
+
565
+ keystore.AddCScript (witnessscript_inner);
566
+ keystore.AddCScript (witnessscript);
567
+ keystore.AddCScript (scriptPubKey);
568
+ keystore.AddKey (keys[0 ]);
569
+ result = IsMine (keystore, scriptPubKey);
570
+ BOOST_CHECK_EQUAL (result, ISMINE_NO);
571
+ }
572
+
491
573
// P2WPKH compressed
492
574
{
493
575
CBasicKeyStore keystore;
0 commit comments