diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 9d0719441..67fc9a99d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1151,22 +1151,6 @@ int64_t komodo_coinbase_ouputscript(uint8_t *script, uint8_t *p2sh160, uint8_t * } } -// validate that a time lock script has the correct time lock -int32_t komodo_coinbase_timelockverify(const CTransaction &tx, uint32_t nHeight) -{ - int i; - uint64_t total = 0; - uint64_t timelock = komodo_pr_unlocktime(nHeight, ASSETCHAINS_TIMEUNLOCKFROM, ASSETCHAINS_TIMEUNLOCKTO); - - for (i = 0; total += tx.vout[i].IsNull() ? 0 : tx.vout[i].nValue, i < tx.vout.size(); i++); - - for (int i = 0; i < tx.vout.size(); i++) - { - const CScript *script = &(tx.vout[i].scriptPubKey); - // if there should be a timelock, get the time lock from the script and return it - } -} - long _stripwhite(char *buf,int accept) { int32_t i,j,c; diff --git a/src/main.cpp b/src/main.cpp index 55071a198..b478bc851 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -894,6 +894,29 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in return nSigOps; } +/** + * Check that a P2SH coinbase transaction follows consensus rules valid at a given block height. + * + * Notes: + * 1. AcceptToMemoryPool calls CheckTransaction and this function. + * 2. ProcessNewBlock calls AcceptBlock, which calls CheckBlock (which calls CheckTransaction) + * and ContextualCheckBlock (which calls this function). + */ +int32_t ContextualCheckCoinbaseTx(const CTransaction &tx, uint32_t nHeight) +{ + int i; + uint64_t total = 0; + uint64_t timelock = komodo_pr_unlocktime(nHeight, ASSETCHAINS_TIMEUNLOCKFROM, ASSETCHAINS_TIMEUNLOCKTO); + + for (i = 0; total += tx.vout[i].IsNull() ? 0 : tx.vout[i].nValue, i < tx.vout.size(); i++); + + for (int i = 0; i < tx.vout.size(); i++) + { + const CScript *script = &(tx.vout[i].scriptPubKey); + // if there should be a timelock, get the time lock from the script and return it + } +} + /** * Check a transaction contextually against a set of consensus rules valid at a given block height. *