Enable time locked coin bases to be used as normal coinbase transactions with longer maturity, fix max_money

This commit is contained in:
miketout
2018-05-04 16:33:34 -07:00
parent 061f1a8ec5
commit e980a26ddd
16 changed files with 121 additions and 92 deletions

View File

@@ -284,6 +284,37 @@ bool CScript::IsPushOnly() const
return true;
}
// if the front of the script has check lock time verify. this is a fairly simple check.
// accepts NULL as parameter if unlockTime is not needed.
bool CScript::IsCheckLockTimeVerify(int64_t *unlockTime) const
{
opcodetype op;
std::vector<unsigned char> unlockTimeParam = std::vector<unsigned char>();
CScript::const_iterator it = this->begin();
if (this->GetOp2(it, op, &unlockTimeParam))
{
if (unlockTimeParam.size() >= 0 && unlockTimeParam.size() < 6 &&
*(this->data() + unlockTimeParam.size() + 1) == OP_CHECKLOCKTIMEVERIFY)
{
int i = unlockTimeParam.size() - 1;
for (*unlockTime = 0; i >= 0; i--)
{
*unlockTime <<= 8;
*unlockTime |= *((unsigned char *)unlockTimeParam.data() + i);
}
return true;
}
}
return false;
}
bool CScript::IsCheckLockTimeVerify() const
{
int64_t ult;
return this->IsCheckLockTimeVerify(&ult);
}
std::string CScript::ToString() const
{
std::string str;

View File

@@ -17,6 +17,8 @@
#include <string>
#include <vector>
#define OPRETTYPE_TIMELOCK 1
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
// Max size of pushdata in a CC sig in bytes
@@ -575,6 +577,13 @@ public:
/** Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical). */
bool IsPushOnly() const;
/** if the front of the script has check lock time verify. this is a fairly simple check.
* accepts NULL as parameter if unlockTime is not needed.
*/
bool IsCheckLockTimeVerify(int64_t *unlockTime) const;
bool IsCheckLockTimeVerify() const;
/**
* Returns whether the script is guaranteed to fail at execution,
* regardless of the initial stack. This allows outputs to be pruned

View File

@@ -74,34 +74,3 @@ const CScriptExt &CScriptExt::TimeLockSpend(const CKeyID &key, int64_t unlocktim
return *this;
}
// if the front of the script has check lock time verify. this is a fairly simple check.
// accepts NULL as parameter if unlockTime is not needed.
bool CScriptExt::IsCheckLockTimeVerify(int64_t *unlockTime) const
{
opcodetype op;
std::vector<unsigned char> unlockTimeParam = std::vector<unsigned char>();
CScript::const_iterator it = this->begin();
if (this->GetOp2(it, op, &unlockTimeParam))
{
if (unlockTimeParam.size() >= 0 && unlockTimeParam.size() < 6 &&
*(this->data() + unlockTimeParam.size() + 1) == OP_CHECKLOCKTIMEVERIFY)
{
int i = unlockTimeParam.size() - 1;
for (*unlockTime = 0; i >= 0; i--)
{
*unlockTime <<= 8;
*unlockTime |= *((unsigned char *)unlockTimeParam.data() + i);
}
return true;
}
}
return false;
}
bool CScriptExt::IsCheckLockTimeVerify() const
{
int64_t ult;
return this->IsCheckLockTimeVerify(&ult);
}

View File

@@ -11,8 +11,6 @@
#include "standard.h"
#include "pubkey.h"
#define OPRETTYPE_TIMELOCK 1
class CScriptExt : public CScript
{
public:
@@ -38,12 +36,6 @@ class CScriptExt : public CScript
// combined CLTV script and P2PKH
const CScriptExt &TimeLockSpend(const CKeyID &key, int64_t unlocktime) const;
// if the front of the script has check lock time verify. this is a fairly simple check.
// accepts NULL as parameter if unlockTime is not needed.
bool IsCheckLockTimeVerify(int64_t *unlockTime) const;
bool IsCheckLockTimeVerify() const;
};
#endif