@@ -821,9 +821,29 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
821
821
BOOST_CHECK (!IsStandardTx (CTransaction (t), reason));
822
822
BOOST_CHECK_EQUAL (reason, " scriptsig-size" );
823
823
824
+ // Check tx-size (non-standard if transaction weight is > MAX_STANDARD_TX_WEIGHT)
825
+ t.vin .clear ();
826
+ t.vin .resize (2438 ); // size per input (empty scriptSig): 41 bytes
827
+ t.vout [0 ].scriptPubKey = CScript () << OP_RETURN << std::vector<unsigned char >(19 , 0 ); // output size: 30 bytes
828
+ // tx header: 12 bytes => 48 vbytes
829
+ // 2438 inputs: 2438*41 = 99958 bytes => 399832 vbytes
830
+ // 1 output: 30 bytes => 120 vbytes
831
+ // ===============================
832
+ // total: 400000 vbytes
833
+ BOOST_CHECK_EQUAL (GetTransactionWeight (CTransaction (t)), 400000 );
834
+ BOOST_CHECK (IsStandardTx (CTransaction (t), reason));
835
+
836
+ // increase output size by one byte, so we end up with 400004 vbytes
837
+ t.vout [0 ].scriptPubKey = CScript () << OP_RETURN << std::vector<unsigned char >(20 , 0 ); // output size: 31 bytes
838
+ BOOST_CHECK_EQUAL (GetTransactionWeight (CTransaction (t)), 400004 );
839
+ reason.clear ();
840
+ BOOST_CHECK (!IsStandardTx (CTransaction (t), reason));
841
+ BOOST_CHECK_EQUAL (reason, " tx-size" );
842
+
824
843
// Check bare multisig (standard if policy flag fIsBareMultisigStd is set)
825
844
fIsBareMultisigStd = true ;
826
845
t.vout [0 ].scriptPubKey = GetScriptForMultisig (1 , {key.GetPubKey ()}); // simple 1-of-1
846
+ t.vin .resize (1 );
827
847
t.vin [0 ].scriptSig = CScript () << std::vector<unsigned char >(65 , 0 );
828
848
BOOST_CHECK (IsStandardTx (CTransaction (t), reason));
829
849
0 commit comments