post launch release readiness

This commit is contained in:
Michael Toutonghi
2018-05-27 19:59:23 -07:00
parent bcb23c06e7
commit c6e2184378
9 changed files with 1493 additions and 32 deletions

View File

@@ -92,7 +92,7 @@ public:
{
strNetworkID = "main";
strCurrencyUnits = "KMD";
consensus.fCoinbaseMustBeProtected = true; // this is only enforced after block 12800 on Verus
consensus.fCoinbaseMustBeProtected = false; // true this is only true wuth Verus and enforced after block 12800
consensus.nSubsidySlowStartInterval = 20000;
consensus.nSubsidyHalvingInterval = 840000;
consensus.nMajorityEnforceBlockUpgrade = 750;
@@ -232,6 +232,12 @@ void *chainparams_commandline(void *ptr)
mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff;
fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY);
// only require coinbase protection on Verus from the Komodo family of coins
if (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0)
{
mainParams.consensus.fCoinbaseMustBeProtected = true;
}
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH)
{
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:

View File

@@ -391,7 +391,11 @@ const CScript &CCoinsViewCache::GetSpendFor(const CCoins *coins, const CTxIn& in
std::string hc = input.prevout.hash.ToString();
if (LaunchMap().lmap.count(hc))
{
return LaunchMap().lmap[hc];
CTransactionExceptionData &txData = LaunchMap().lmap[hc];
if ((txData.voutMask & (((uint64_t)1) << (uint64_t)input.prevout.n)) != 0)
{
return txData.scriptPubKey;
}
}
}
return coins->vout[input.prevout.n].scriptPubKey;

View File

@@ -441,23 +441,31 @@ public:
friend class CCoinsViewCache;
};
class CTransactionExceptionData
{
public:
CScript scriptPubKey;
uint64_t voutMask;
CTransactionExceptionData() : scriptPubKey(), voutMask() {}
};
class CLaunchMap
{
public:
std::unordered_map<std::string, CScript> lmap;
std::unordered_map<std::string, CTransactionExceptionData> lmap;
CLaunchMap() : lmap()
{
for (int i = 0; i < WHITELIST_COUNT; i++)
//printf("txid: %s -> addr: %s\n", whitelist_ids[i], whitelist_addrs[i]);
CBitcoinAddress bcaddr(whitelist_address);
CKeyID key;
if (bcaddr.GetKeyID_NoCheck(key))
{
printf("txid: %s -> addr: %s", whitelist_ids[i], whitelist_addrs[i]);
CBitcoinAddress address(whitelist_addrs[i]);
CKeyID key;
if (address.GetKeyID_NoCheck(key))
std::vector<unsigned char> address = std::vector<unsigned char>(key.begin(), key.end());
for (int i = 0; i < WHITELIST_COUNT; i++)
{
std::vector<unsigned char> adr = std::vector<unsigned char>(key.begin(), key.end());
std::string hash = uint256S(whitelist_ids[i]).ToString();
lmap[hash] = CScript();
lmap[hash] << OP_DUP << OP_HASH160 << adr << OP_EQUALVERIFY << OP_CHECKSIG;
lmap[hash].scriptPubKey << OP_DUP << OP_HASH160 << address << OP_EQUALVERIFY << OP_CHECKSIG;
lmap[hash].voutMask = whitelist_masks[i];
}
}
}

View File

@@ -73,3 +73,8 @@ CVerusHash &CVerusHash::Write(const unsigned char *data, size_t len)
return *this;
}
// to be declared and accessed from C
void verus_hash(void *result, const void *data, size_t len)
{
return CVerusHash::Hash(result, data, len);
}

View File

@@ -51,4 +51,6 @@ class CVerusHash
size_t curPos = 0;
};
extern void verus_hash(void *result, const void *data, size_t len);
#endif

View File

@@ -28,6 +28,8 @@
#define portable_mutex_lock pthread_mutex_lock
#define portable_mutex_unlock pthread_mutex_unlock
extern void verus_hash(void *result, const void *data, size_t len);
struct allocitem { uint32_t allocsize,type; };
struct queueitem { struct queueitem *next,*prev; uint32_t allocsize,type; };
@@ -1022,23 +1024,45 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_
// from all other blocks. the sequence is extremely likely, but not guaranteed to be unique for each block chain
uint64_t komodo_block_prg(uint32_t nHeight)
{
int i;
uint8_t hashSrc[8];
uint64_t result, hashSrc64 = (uint64_t)ASSETCHAINS_MAGIC << 32 + nHeight;
bits256 hashResult;
for ( i = 0; i < sizeof(hashSrc); i++ )
if (strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 || nHeight >= 12800)
{
hashSrc[i] = hashSrc64 & 0xff;
hashSrc64 >>= 8;
}
vcalc_sha256(0, hashResult.bytes, hashSrc, sizeof(hashSrc));
uint64_t i, result = 0, hashSrc64 = ((uint64_t)ASSETCHAINS_MAGIC << 32) | (uint64_t)nHeight;
uint8_t hashSrc[8];
bits256 hashResult;
for ( i = 0; i < 8; i++ )
{
result = (result << 8) + hashResult.bytes[i];
for ( i = 0; i < sizeof(hashSrc); i++ )
{
uint64_t x = hashSrc64 >> (i * 8);
hashSrc[i] = (uint8_t)(x & 0xff);
}
verus_hash(hashResult.bytes, hashSrc, sizeof(hashSrc));
for ( i = 0; i < 8; i++ )
{
result = (result << 8) | hashResult.bytes[i];
}
return result;
}
else
{
int i;
uint8_t hashSrc[8];
uint64_t result, hashSrc64 = (uint64_t)ASSETCHAINS_MAGIC << 32 + nHeight;
bits256 hashResult;
for ( i = 0; i < sizeof(hashSrc); i++ )
{
hashSrc[i] = hashSrc64 & 0xff;
hashSrc64 >>= 8;
int8_t b = hashSrc[i];
}
vcalc_sha256(0, hashResult.bytes, hashSrc, sizeof(hashSrc));
for ( i = 0; i < 8; i++ )
{
result = (result << 8) + hashResult.bytes[i];
}
return result;
}
return(result);
}
// given a block height, this returns the unlock time for that block height, derived from
@@ -1055,8 +1079,7 @@ int64_t komodo_block_unlocktime(uint32_t nHeight)
if (strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 || nHeight >= 12800)
{
unlocktime = komodo_block_prg(nHeight) % (ASSETCHAINS_TIMEUNLOCKTO - ASSETCHAINS_TIMEUNLOCKFROM);
// boundary and power of 2 can make it exceed to time by 1
unlocktime = unlocktime + ASSETCHAINS_TIMEUNLOCKFROM;
unlocktime += ASSETCHAINS_TIMEUNLOCKFROM;
}
else
{

View File

@@ -1041,7 +1041,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
TxInErrorToJSON(txin, vErrors, "Input not found or already spent");
continue;
}
const CScript& prevPubKey = coins->vout[txin.prevout.n].scriptPubKey;
const CScript& prevPubKey = CCoinsViewCache::GetSpendFor(coins, txin);
const CAmount& amount = coins->vout[txin.prevout.n].nValue;
SignatureData sigdata;

File diff suppressed because it is too large Load Diff

View File

@@ -8,9 +8,10 @@
#include <string>
#define WHITELIST_COUNT 0
#define WHITELIST_COUNT 704
extern const char *whitelist_ids[WHITELIST_COUNT];
extern const char *whitelist_addrs[WHITELIST_COUNT];
extern const char *whitelist_address;
extern uint64_t whitelist_masks[WHITELIST_COUNT];
#endif