Merge pull request #46 from StakedChain/master

merge master updates to test branch
This commit is contained in:
blackjok3rtt
2018-11-11 17:05:37 +08:00
committed by GitHub
10 changed files with 43 additions and 28 deletions

View File

@@ -9,6 +9,7 @@
#define IGUANA_MAXSCRIPTSIZE 10001
#define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus
#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9"
#define KOMODO_FIRSTFUNGIBLEID 100
extern uint8_t ASSETCHAINS_TXPOW;

View File

@@ -1636,6 +1636,8 @@ void komodo_args(char *argv0)
MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN;
else MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN + ASSETCHAINS_REWARD * (ASSETCHAINS_ENDSUBSIDY==0 ? 10000000 : ASSETCHAINS_ENDSUBSIDY);
MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN;
if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN )
MAX_MONEY = 1000000LL*SATOSHIDEN;
//printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN);
ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 )

View File

@@ -3188,7 +3188,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
else fprintf(stderr,"checktoshis %.8f numvouts %d\n",dstr(checktoshis),(int32_t)block.vtx[0].vout.size());
}
}
if ( block.vtx[0].GetValueOut() > blockReward+1 )
if ( ( block.vtx[0].GetValueOut() > blockReward+1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) || ( block.vtx[0].GetValueOut() > blockReward ) )
{
if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward )
{

View File

@@ -979,20 +979,20 @@ void static BitcoinMiner()
HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
if ( ASSETCHAINS_STAKED < 100 )
{
for (z=31; z>=0; z--)
fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]);
fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%%\n",percPoS,(int32_t)ASSETCHAINS_STAKED);
//for (z=31; z>=0; z--)
// fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]);
LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED);
}
}
while (true)
{
/*if ( KOMODO_INSYNC == 0 && Mining_height > ASSETCHAINS_MINHEIGHT )
if ( KOMODO_INSYNC == 0 && KOMODO_LONGESTCHAIN != 0 )
{
fprintf(stderr,"Mining when blockchain might not be in sync longest.%d vs %d\n",KOMODO_LONGESTCHAIN,Mining_height);
if ( KOMODO_LONGESTCHAIN != 0 && Mining_height >= KOMODO_LONGESTCHAIN )
KOMODO_INSYNC = 1;
sleep(3);
} */
}
// Hash state
KOMODO_CHOSEN_ONE = 0;
crypto_generichash_blake2b_state state;

View File

@@ -22,7 +22,7 @@ const char *notaries_STAKED1[][2] =
{"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev
{"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6
{"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL
{"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2
{"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t
{"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu
{"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx
{"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca

View File

@@ -7,9 +7,9 @@
static const int STAKED_ERA_GAP = 777;
static const int STAKED_NOTARIES_TIMESTAMP1 = 1541498901;
static const int STAKED_NOTARIES_TIMESTAMP2 = 1541500201;
static const int STAKED_NOTARIES_TIMESTAMP3 = 1541501501;
static const int STAKED_NOTARIES_TIMESTAMP1 = 1604211111;
static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222;
static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333;
static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444;
extern const char *notaries_STAKED1[][2];

View File

@@ -175,6 +175,8 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp)
CAmount burnAmount = AmountFromValue(params[2]);
if (burnAmount <= 0)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export");
if (burnAmount > 1000000LL*COIN)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export, cannot export more than 1 million coins per export.");
{
CAmount needed = 0;
for (int i=0; i<tx.vout.size(); i++) needed += tx.vout[i].nValue;

View File

@@ -518,10 +518,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
#endif
}
std::string strMode = "template";
UniValue lpval = NullUniValue;
// TODO: Re-enable coinbasevalue once a specification has been written
bool coinbasetxn = true;
std::string strMode;
if (params.size() > 0)
{
const UniValue& oparam = params[0].get_obj();
@@ -530,12 +530,15 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
strMode = modeval.get_str();
else if (modeval.isNull())
{
/* Do nothing */
strMode = "template";
}
else
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
lpval = find_value(oparam, "longpollid");
if (strMode == "disablecb")
coinbasetxn = false;
if (strMode == "proposal")
{
const UniValue& dataval = find_value(oparam, "data");
@@ -567,9 +570,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
}
}
if (strMode != "template")
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
if (vNodes.empty())
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!");
@@ -673,8 +673,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
uint256 txHash = tx.GetHash();
setTxIndex[txHash] = i++;
if (tx.IsCoinBase() && !coinbasetxn)
continue;
//if (tx.IsCoinBase() && !coinbasetxn)
// continue;
UniValue entry(UniValue::VOBJ);
@@ -694,7 +694,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template]));
entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template]));
if (tx.IsCoinBase()) {
if (tx.IsCoinBase() && coinbasetxn == true ) {
// Show founders' reward if it is required
//if (pblock->vtx[0].vout.size() > 1) {
// Correct this if GetBlockTemplate changes the order
@@ -729,10 +729,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
if (coinbasetxn) {
assert(txCoinbase.isObject());
result.push_back(Pair("coinbasetxn", txCoinbase));
} else {
result.push_back(Pair("coinbaseaux", aux));
result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
}
} // else {
// result.push_back(Pair("coinbaseaux", aux));
// result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
//}
result.push_back(Pair("longpollid", chainActive.LastTip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast)));
if ( ASSETCHAINS_STAKED != 0 )
{

View File

@@ -1064,7 +1064,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp)
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 50 )
if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 )
continue;
CCoins coins;
@@ -1080,12 +1080,19 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp)
}
if ( spents == mine )
{
TxToRemove.push_back(wtx.GetHash());
for (unsigned int n = 0; n < wtx.vin.size() ; n++)
{
if ( pwalletMain->IsMine(wtx.vin[n]) )
TxToRemove.push_back(wtx.vin[n].prevout.hash);
CTransaction vintx; uint256 hashBlock;
if ( GetTransaction(wtx.vin[n].prevout.hash,vintx,hashBlock,false) != 0 )
{
for (unsigned int z = 0; z < vintx.vin.size() ; z++)
{
TxToRemove.push_back(vintx.vin[z].prevout.hash);
}
}
TxToRemove.push_back(wtx.vin[n].prevout.hash);
}
TxToRemove.push_back(wtx.GetHash());
}
}
@@ -1108,7 +1115,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp)
if ( SpentHash == tx.vin[n].prevout.hash )
{
pwalletMain->EraseFromWallet(tx.GetHash());
//fprintf(stderr, "ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str());
LogPrintf("ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str());
}
}
}
@@ -1119,7 +1126,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp)
BOOST_FOREACH (uint256& hash, TxToRemove)
{
pwalletMain->EraseFromWallet(hash);
//fprintf(stderr, "ERASED spent Tx: %s\n",hash.ToString().c_str());
LogPrintf("ERASED spent Tx: %s\n",hash.ToString().c_str());
}
// build return JSON for stats.

View File

@@ -1209,6 +1209,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
{
{
AssertLockHeld(cs_wallet);
if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 )
return false;
bool fExisted = mapWallet.count(tx.GetHash()) != 0;
if (fExisted && !fUpdate) return false;
auto noteData = FindMyNotes(tx);