From 65098812f2cf78c023cedd05f8a52682b7ba4206 Mon Sep 17 00:00:00 2001 From: Michael Toutonghi Date: Sun, 15 Apr 2018 01:20:40 -0700 Subject: [PATCH] More time lock checking... not finished --- src/komodo_utils.h | 1 + src/main.cpp | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e86df91d6..792b5f475 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1104,6 +1104,7 @@ uint64_t blockPRG(uint32_t nHeight) // create a CLTV output script and return the script and its P2SH address // funds will be locked a pseudo random time between specified from and to time, with entropy taken from the parameters used // to setup the chain and the specified block height. this can be used to create, validate, or spend a time locked coin base transaction +// returns locktime int64_t komodo_block_timelockscript(uint8_t *script, uint8_t p2sh160[20], uint8_t taddrrmd160[20], uint32_t nHeight, uint64_t fromTime, uint64_t toTime) { uint32_t locktime, i, n = 0; diff --git a/src/main.cpp b/src/main.cpp index a779bc89d..c1f199d15 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -964,11 +964,24 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state, } } - if (tx.IsCoinBase() && tx.vout[0].nValue >= ASSETCHAINS_TIMELOCKGTE) + if (tx.IsCoinBase()) { - // if time locks are on, ensure that this coin base is time locked exactly as it should be + int total = 0, int i; + uint8_t script[256], scriptHash160[20]; + for (i = 0; total += tx.vout[i].IsNull() ? 0 : tx.vout[i].nValue, i < tx.vout.size; i++); + + // if time locks are on, ensure that this coin base is time locked exactly as it should be + if (total >= ASSETCHAINS_TIMELOCKGTE) + { + for (i = 0; i < tx.vout.size; i++) + { + // validate that the outputs are locked by the proper time lock script + //uint64_t i = komodo_block_timelockscript(script, scriptHash160, tx.addr/*need address*/) + } + } } + return true; }