@@ -937,23 +937,58 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
937
937
CheckIsNotStandard (t, " bare-multisig" );
938
938
g_bare_multi = DEFAULT_PERMIT_BAREMULTISIG;
939
939
940
+ // Check compressed P2PK outputs dust threshold (must have leading 02 or 03)
941
+ t.vout [0 ].scriptPubKey = CScript () << std::vector<unsigned char >(33 , 0x02 ) << OP_CHECKSIG;
942
+ t.vout [0 ].nValue = 576 ;
943
+ CheckIsStandard (t);
944
+ t.vout [0 ].nValue = 575 ;
945
+ CheckIsNotStandard (t, " dust" );
946
+
947
+ // Check uncompressed P2PK outputs dust threshold (must have leading 04/06/07)
948
+ t.vout [0 ].scriptPubKey = CScript () << std::vector<unsigned char >(65 , 0x04 ) << OP_CHECKSIG;
949
+ t.vout [0 ].nValue = 672 ;
950
+ CheckIsStandard (t);
951
+ t.vout [0 ].nValue = 671 ;
952
+ CheckIsNotStandard (t, " dust" );
953
+
954
+ // Check P2PKH outputs dust threshold
955
+ t.vout [0 ].scriptPubKey = CScript () << OP_DUP << OP_HASH160 << std::vector<unsigned char >(20 , 0 ) << OP_EQUALVERIFY << OP_CHECKSIG;
956
+ t.vout [0 ].nValue = 546 ;
957
+ CheckIsStandard (t);
958
+ t.vout [0 ].nValue = 545 ;
959
+ CheckIsNotStandard (t, " dust" );
960
+
961
+ // Check P2SH outputs dust threshold
962
+ t.vout [0 ].scriptPubKey = CScript () << OP_HASH160 << std::vector<unsigned char >(20 , 0 ) << OP_EQUAL;
963
+ t.vout [0 ].nValue = 540 ;
964
+ CheckIsStandard (t);
965
+ t.vout [0 ].nValue = 539 ;
966
+ CheckIsNotStandard (t, " dust" );
967
+
940
968
// Check P2WPKH outputs dust threshold
941
- t.vout [0 ].scriptPubKey = CScript () << OP_0 << ParseHex ( " ffffffffffffffffffffffffffffffffffffffff " );
969
+ t.vout [0 ].scriptPubKey = CScript () << OP_0 << std::vector< unsigned char >( 20 , 0 );
942
970
t.vout [0 ].nValue = 294 ;
943
971
CheckIsStandard (t);
944
972
t.vout [0 ].nValue = 293 ;
945
973
CheckIsNotStandard (t, " dust" );
946
974
947
975
// Check P2WSH outputs dust threshold
948
- t.vout [0 ].scriptPubKey = CScript () << OP_0 << ParseHex (" ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" );
976
+ t.vout [0 ].scriptPubKey = CScript () << OP_0 << std::vector<unsigned char >(32 , 0 );
977
+ t.vout [0 ].nValue = 330 ;
978
+ CheckIsStandard (t);
979
+ t.vout [0 ].nValue = 329 ;
980
+ CheckIsNotStandard (t, " dust" );
981
+
982
+ // Check P2TR outputs dust threshold (Invalid xonly key ok!)
983
+ t.vout [0 ].scriptPubKey = CScript () << OP_1 << std::vector<unsigned char >(32 , 0 );
949
984
t.vout [0 ].nValue = 330 ;
950
985
CheckIsStandard (t);
951
986
t.vout [0 ].nValue = 329 ;
952
987
CheckIsNotStandard (t, " dust" );
953
988
954
- // Check future Witness Program versions dust threshold
955
- for (int op = OP_2 ; op <= OP_16; op += 1 ) {
956
- t.vout [0 ].scriptPubKey = CScript () << (opcodetype)op << ParseHex ( " ffff " );
989
+ // Check future Witness Program versions dust threshold (non-32-byte pushes are undefined for version 1)
990
+ for (int op = OP_1 ; op <= OP_16; op += 1 ) {
991
+ t.vout [0 ].scriptPubKey = CScript () << (opcodetype)op << std::vector< unsigned char >( 2 , 0 );
957
992
t.vout [0 ].nValue = 240 ;
958
993
CheckIsStandard (t);
959
994
0 commit comments