Implement a hard fork for extended/infinite claim expiration times #112
4 changed files with 50 additions and 0 deletions
|
@ -717,6 +717,8 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
|
||||||
nValueOut += txout.nValue;
|
nValueOut += txout.nValue;
|
||||||
if (!MoneyRange(nValueOut))
|
if (!MoneyRange(nValueOut))
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-txouttotal-toolarge");
|
return state.DoS(100, false, REJECT_INVALID, "bad-txns-txouttotal-toolarge");
|
||||||
|
if (ClaimScriptSize(txout.scriptPubKey) > MAX_CLAIM_SCRIPT_SIZE)
|
||||||
|
return state.DoS(100, false, REJECT_INVALID, "bad-txns-claimscriptsize-toolarg");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for duplicate inputs
|
// Check for duplicate inputs
|
||||||
|
|
|
@ -130,3 +130,9 @@ CScript StripClaimScriptPrefix(const CScript& scriptIn, int& op)
|
||||||
return CScript(pc, scriptIn.end());
|
return CScript(pc, scriptIn.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t ClaimScriptSize(const CScript& scriptIn)
|
||||||
|
{
|
||||||
|
CScript strippedScript = StripClaimScriptPrefix(scriptIn);
|
||||||
|
return scriptIn.size() - strippedScript.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#define MAX_CLAIM_SCRIPT_SIZE 8192
|
||||||
|
|
||||||
bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector<std::vector<unsigned char> >& vvchParams);
|
bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector<std::vector<unsigned char> >& vvchParams);
|
||||||
bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector<std::vector<unsigned char> >& vvchParams, CScript::const_iterator& pc);
|
bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector<std::vector<unsigned char> >& vvchParams, CScript::const_iterator& pc);
|
||||||
CScript StripClaimScriptPrefix(const CScript& scriptIn);
|
CScript StripClaimScriptPrefix(const CScript& scriptIn);
|
||||||
|
@ -13,5 +15,6 @@ CScript StripClaimScriptPrefix(const CScript& scriptIn, int& op);
|
||||||
uint160 ClaimIdHash(const uint256& txhash, uint32_t nOut);
|
uint160 ClaimIdHash(const uint256& txhash, uint32_t nOut);
|
||||||
std::vector<unsigned char> uint32_t_to_vch(uint32_t n);
|
std::vector<unsigned char> uint32_t_to_vch(uint32_t n);
|
||||||
uint32_t vch_to_uint32_t(std::vector<unsigned char>& vchN);
|
uint32_t vch_to_uint32_t(std::vector<unsigned char>& vchN);
|
||||||
|
size_t ClaimScriptSize(const CScript& scriptIn);
|
||||||
|
|
||||||
#endif // BITCOIN_NAMECLAIM_H
|
#endif // BITCOIN_NAMECLAIM_H
|
||||||
|
|
|
@ -408,4 +408,43 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||||
BOOST_CHECK(IsStandardTx(t, reason));
|
BOOST_CHECK(IsStandardTx(t, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(test_claimsValid)
|
||||||
|
{
|
||||||
|
LOCK(cs_main);
|
||||||
|
CBasicKeyStore keystore;
|
||||||
|
CCoinsView coinsDummy;
|
||||||
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
|
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
||||||
|
|
||||||
|
CMutableTransaction t;
|
||||||
|
t.vin.resize(1);
|
||||||
|
t.vin[0].prevout.hash = dummyTransactions[0].GetHash();
|
||||||
|
t.vin[0].prevout.n = 1;
|
||||||
|
t.vin[0].scriptSig << std::vector<unsigned char>(65, 0);
|
||||||
|
t.vout.resize(1);
|
||||||
|
t.vout[0].nValue = 90*CENT;
|
||||||
|
|
||||||
|
std::vector<unsigned char> vchName;
|
||||||
|
std::vector<unsigned char> vchValue;
|
||||||
|
|
||||||
|
vchName.resize(0);
|
||||||
|
vchValue.resize(0);
|
||||||
|
|
||||||
|
t.vout[0].scriptPubKey = CScript() << OP_CLAIM_NAME << vchName << vchValue << OP_2DROP << OP_DROP << OP_TRUE;
|
||||||
|
|
||||||
|
CValidationState state;
|
||||||
|
|
||||||
|
BOOST_CHECK(CheckTransaction(t, state));
|
||||||
|
BOOST_CHECK(state.IsValid());
|
||||||
|
|
||||||
|
vchName = std::vector<unsigned char>(2<<12, '0');
|
||||||
|
vchValue = std::vector<unsigned char>(2<<12, '0');
|
||||||
|
|
||||||
|
t.vout[0].scriptPubKey = CScript() << OP_CLAIM_NAME << vchName << vchValue << OP_2DROP << OP_DROP << OP_TRUE;
|
||||||
|
|
||||||
|
state = CValidationState();
|
||||||
|
|
||||||
|
BOOST_CHECK(!CheckTransaction(t, state));
|
||||||
|
BOOST_CHECK(!state.IsValid());
|
||||||
|
}
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
Loading…
Reference in a new issue