@@ -40,6 +40,9 @@ typedef std::vector<unsigned char> valtype;
40
40
// In script_tests.cpp
41
41
UniValue read_json (const std::string& jsondata);
42
42
43
+ static CFeeRate g_dust{DUST_RELAY_TX_FEE};
44
+ static bool g_bare_multi{DEFAULT_PERMIT_BAREMULTISIG};
45
+
43
46
static std::map<std::string, unsigned int > mapFlagNames = {
44
47
{std::string (" P2SH" ), (unsigned int )SCRIPT_VERIFY_P2SH},
45
48
{std::string (" STRICTENC" ), (unsigned int )SCRIPT_VERIFY_STRICTENC},
@@ -764,19 +767,19 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
764
767
765
768
constexpr auto CheckIsStandard = [](const auto & t) {
766
769
std::string reason;
767
- BOOST_CHECK (IsStandardTx (CTransaction (t) , reason));
770
+ BOOST_CHECK (IsStandardTx (CTransaction{t}, g_bare_multi, g_dust , reason));
768
771
BOOST_CHECK (reason.empty ());
769
772
};
770
773
constexpr auto CheckIsNotStandard = [](const auto & t, const std::string& reason_in) {
771
774
std::string reason;
772
- BOOST_CHECK (!IsStandardTx (CTransaction (t) , reason));
775
+ BOOST_CHECK (!IsStandardTx (CTransaction{t}, g_bare_multi, g_dust , reason));
773
776
BOOST_CHECK_EQUAL (reason_in, reason);
774
777
};
775
778
776
779
CheckIsStandard (t);
777
780
778
781
// Check dust with default relay fee:
779
- CAmount nDustThreshold = 182 * dustRelayFee .GetFeePerK () / 1000 ;
782
+ CAmount nDustThreshold = 182 * g_dust .GetFeePerK () / 1000 ;
780
783
BOOST_CHECK_EQUAL (nDustThreshold, 546 );
781
784
// dust:
782
785
t.vout [0 ].nValue = nDustThreshold - 1 ;
@@ -804,14 +807,14 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
804
807
805
808
// Check dust with odd relay fee to verify rounding:
806
809
// nDustThreshold = 182 * 3702 / 1000
807
- dustRelayFee = CFeeRate (3702 );
810
+ g_dust = CFeeRate (3702 );
808
811
// dust:
809
812
t.vout [0 ].nValue = 674 - 1 ;
810
813
CheckIsNotStandard (t, " dust" );
811
814
// not dust:
812
815
t.vout [0 ].nValue = 674 ;
813
816
CheckIsStandard (t);
814
- dustRelayFee = CFeeRate ( DUST_RELAY_TX_FEE) ;
817
+ g_dust = CFeeRate{ DUST_RELAY_TX_FEE} ;
815
818
816
819
t.vout [0 ].scriptPubKey = CScript () << OP_1;
817
820
CheckIsNotStandard (t, " scriptpubkey" );
@@ -923,16 +926,16 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
923
926
BOOST_CHECK_EQUAL (GetTransactionWeight (CTransaction (t)), 400004 );
924
927
CheckIsNotStandard (t, " tx-size" );
925
928
926
- // Check bare multisig (standard if policy flag fIsBareMultisigStd is set)
927
- fIsBareMultisigStd = true ;
929
+ // Check bare multisig (standard if policy flag g_bare_multi is set)
930
+ g_bare_multi = true ;
928
931
t.vout [0 ].scriptPubKey = GetScriptForMultisig (1 , {key.GetPubKey ()}); // simple 1-of-1
929
932
t.vin .resize (1 );
930
933
t.vin [0 ].scriptSig = CScript () << std::vector<unsigned char >(65 , 0 );
931
934
CheckIsStandard (t);
932
935
933
- fIsBareMultisigStd = false ;
936
+ g_bare_multi = false ;
934
937
CheckIsNotStandard (t, " bare-multisig" );
935
- fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
938
+ g_bare_multi = DEFAULT_PERMIT_BAREMULTISIG;
936
939
937
940
// Check P2WPKH outputs dust threshold
938
941
t.vout [0 ].scriptPubKey = CScript () << OP_0 << ParseHex (" ffffffffffffffffffffffffffffffffffffffff" );
0 commit comments