diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 83c85e551..28091b957 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -24,7 +24,7 @@ so you can pay to a pubkey, or to its hash. or to a script's hash. the last is h all of the above are the standard bitcoin vout types and there should be plenty of materials about it Encrypted by a verified device what I did with the CC contracts is created a fourth type of vout, the CC vout. this is using the cryptoconditions standard and it is even a different signature mechanism. ed25519 instead of secp256k1. it is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script. - + but it gets more interesting each CC script has an evalcode this is just an arbitrary number. but what it does is allows to create a self-contained universe of CC utxo that all have the same evalcode and that is how a faucet CC differentiates itself from a dice CC, the eval code is different @@ -73,7 +73,7 @@ struct CC_utxo // these are the parameters stored after Verus crypto-condition vouts. new versions may change // the format -struct CC_meta +struct CC_meta { std::vector version; uint8_t evalCode; @@ -110,7 +110,7 @@ int32_t komodo_nextheight(); static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); int32_t is_hexstr(char *str,int32_t n); -bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL); +bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL, bool fSkipExpiry = false); //uint64_t myGettxout(uint256 hash,int32_t n); bool myIsutxo_spentinmempool(uint256 txid,int32_t vout); bool mytxid_inmempool(uint256 txid); diff --git a/src/cc/dapps/README.md b/src/cc/dapps/README.md index 0d8b2cac2..d59878d47 100644 --- a/src/cc/dapps/README.md +++ b/src/cc/dapps/README.md @@ -12,7 +12,7 @@ This tool converts Sprout zaddress funds into Sapling funds in a new Sapling add ### Usage - ./zmigrate zsaplingaddr + ./zmigrate COIN zsaplingaddr The above command may need to be run multiple times to complete the process. diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 84cf4b057..a857623a5 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -940,6 +940,11 @@ again: if ( amount == lastamount3 && amount == lastamount4 ) stdamount /= 10; } + if ( stdamount < COIN ) + { + stdamount = COIN; + refamount = COIN * 50; + } if ( stdamount < refamount ) refamount = stdamount; lastamount4 = lastamount3; diff --git a/src/chain.h b/src/chain.h index 95553c23c..0b6e2b046 100644 --- a/src/chain.h +++ b/src/chain.h @@ -219,7 +219,7 @@ public: CBlockIndex* pskip; //! height of the entry in the chain. The genesis block has height 0 - int64_t newcoins,zfunds; int8_t segid; // jl777 fields + int64_t newcoins,zfunds,sproutfunds; int8_t segid; // jl777 fields //! Which # file this block is stored in (blk?????.dat) int nFile; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 096590563..add4f4e7f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1851,9 +1851,9 @@ int32_t komodo_acpublic(uint32_t tiptime) return(acpublic); } -int64_t komodo_newcoins(int64_t *zfundsp,int32_t nHeight,CBlock *pblock) +int64_t komodo_newcoins(int64_t *zfundsp,int64_t *sproutfundsp,int32_t nHeight,CBlock *pblock) { - CTxDestination address; int32_t i,j,m,n,vout; uint8_t *script; uint256 txid,hashBlock; int64_t zfunds=0,vinsum=0,voutsum=0; + CTxDestination address; int32_t i,j,m,n,vout; uint8_t *script; uint256 txid,hashBlock; int64_t zfunds=0,vinsum=0,voutsum=0,sproutfunds=0; n = pblock->vtx.size(); for (i=0; i 100000*SATOSHIDEN || voutsum-vinsum+zfunds < 0 ) @@ -1904,11 +1907,11 @@ int64_t komodo_newcoins(int64_t *zfundsp,int32_t nHeight,CBlock *pblock) return(voutsum - vinsum); } -int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height) +int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height) { - CBlockIndex *pindex; CBlock block; int64_t zfunds=0,supply = 0; + CBlockIndex *pindex; CBlock block; int64_t zfunds=0,sproutfunds=0,supply = 0; //fprintf(stderr,"coinsupply %d\n",height); - *zfundsp = 0; + *zfundsp = *sproutfundsp = 0; if ( (pindex= komodo_chainactive(height)) != 0 ) { while ( pindex != 0 && pindex->GetHeight() > 0 ) @@ -1916,7 +1919,7 @@ int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height) if ( pindex->newcoins == 0 && pindex->zfunds == 0 ) { if ( komodo_blockload(block,pindex) == 0 ) - pindex->newcoins = komodo_newcoins(&pindex->zfunds,pindex->GetHeight(),&block); + pindex->newcoins = komodo_newcoins(&pindex->zfunds,&pindex->sproutfunds,pindex->GetHeight(),&block); else { fprintf(stderr,"error loading block.%d\n",pindex->GetHeight()); @@ -1925,10 +1928,12 @@ int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height) } supply += pindex->newcoins; zfunds += pindex->zfunds; + sproutfunds += pindex->sproutfunds; //printf("start ht.%d new %.8f -> supply %.8f zfunds %.8f -> %.8f\n",pindex->GetHeight(),dstr(pindex->newcoins),dstr(supply),dstr(pindex->zfunds),dstr(zfunds)); pindex = pindex->pprev; } } *zfundsp = zfunds; + *sproutfundsp = sproutfunds; return(supply); } diff --git a/src/main.cpp b/src/main.cpp index 55beec474..3cee45552 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1076,11 +1076,14 @@ bool ContextualCheckTransaction( } // Rules that apply to Overwinter or later: - if (overwinterActive) { + if (overwinterActive) + { // Reject transactions intended for Sprout - if (!tx.fOverwintered) { + if (!tx.fOverwintered) + { int32_t ht = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight; - return state.DoS((ht < 0 || nHeight < ht) ? 0 : dosLevel, error("ContextualCheckTransaction: overwinter is active"),REJECT_INVALID, "tx-overwinter-active"); + fprintf(stderr,"overwinter is active tx.%s not, ht.%d vs %d\n",tx.GetHash().ToString().c_str(),nHeight,ht); + return state.DoS((ASSETCHAINS_PRIVATE != 0 || ht < 0 || nHeight < ht) ? 0 : dosLevel, error("ContextualCheckTransaction: overwinter is active"),REJECT_INVALID, "tx-overwinter-active"); } // Check that all transactions are unexpired @@ -1596,7 +1599,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF } -bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,bool* pfMissingInputs, bool fRejectAbsurdFee, int dosLevel) +bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,bool* pfMissingInputs, bool fRejectAbsurdFee, int dosLevel, bool fSkipExpiry) { AssertLockHeld(cs_main); if (pfMissingInputs) @@ -1633,7 +1636,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } // DoS level set to 10 to be more forgiving. // Check transaction contextually against the set of consensus rules which apply in the next block to be mined. - if (!ContextualCheckTransaction(tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel)) + if (!fSkipExpiry && !ContextualCheckTransaction(tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel)) { return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); } @@ -1730,7 +1733,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (pfMissingInputs) *pfMissingInputs = true; //fprintf(stderr,"missing inputs\n"); - //return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); + return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); return(false); } } @@ -1972,14 +1975,14 @@ bool GetAddressUnspent(uint160 addressHash, int type, else return(coins.vout[n].nValue); }*/ -bool myAddtomempool(CTransaction &tx, CValidationState *pstate) +bool myAddtomempool(CTransaction &tx, CValidationState *pstate, bool fSkipExpiry) { CValidationState state; if (!pstate) pstate = &state; CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; if ( mempool.lookup(tx.GetHash(),Ltx) == 0 ) - return(AcceptToMemoryPool(mempool, *pstate, tx, false, &fMissingInputs, !fOverrideFees)); + return(AcceptToMemoryPool(mempool, *pstate, tx, false, &fMissingInputs, !fOverrideFees, -1, fSkipExpiry)); else return(true); } @@ -4683,7 +4686,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { const CTransaction &tx = e.GetTx(); const uint256 &hash = tx.GetHash(); - if ( tx.vjoinsplit.size() == 0 ) { + if ( tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { transactionsToRemove.push_back(tx); tmpmempool.addUnchecked(hash,e,true); } @@ -4702,10 +4705,10 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C CValidationState state; CTransaction Tx; const CTransaction &tx = (CTransaction)block.vtx[i]; - if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) + if (tx.IsCoinBase() || (!tx.vjoinsplit.empty() && !tx.vShieldedSpend.empty()) || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) continue; Tx = tx; - if ( myAddtomempool(Tx, &state) == false ) // happens with out of order tx in block on resync + if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync { //LogPrintf("Rejected by mempool, reason: .%s.\n", state.GetRejectReason().c_str()); // take advantage of other checks, but if we were only rejected because it is a valid staking @@ -4770,9 +4773,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C { const CTransaction &tx = e.GetTx(); const uint256 &hash = tx.GetHash(); - if ( tx.vjoinsplit.size() == 0 ) { - mempool.addUnchecked(hash,e,true); - } + mempool.addUnchecked(hash,e,true); } //fprintf(stderr, "finished adding back. mempoolsize.%ld\n",mempool.size()); // empty the temp mempool for next time. @@ -4920,7 +4921,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat *ppindex = pindex; if ( pindex != 0 && pindex->nStatus & BLOCK_FAILED_MASK ) { - if ( ASSETCHAINS_CC == 0 ) + if ( ASSETCHAINS_CC == 0 )//&& (ASSETCHAINS_PRIVATE == 0 || KOMODO_INSYNC >= Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight) ) return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate"); else { diff --git a/src/main.h b/src/main.h index 00055b39c..fdd9fcae8 100644 --- a/src/main.h +++ b/src/main.h @@ -274,7 +274,7 @@ void PruneAndFlush(); /** (try to) add transaction to memory pool **/ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, - bool* pfMissingInputs, bool fRejectAbsurdFee=false, int dosLevel=-1); + bool* pfMissingInputs, bool fRejectAbsurdFee=false, int dosLevel=-1, bool fSkipExpiry=false); struct CNodeStateStats { diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 26c273236..7bfb98f7b 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -54,7 +54,7 @@ extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); -int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); +int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); #define KOMODO_VERSION "0.3.1" #define VERUS_VERSION "0.4.0g" @@ -282,7 +282,7 @@ public: UniValue coinsupply(const UniValue& params, bool fHelp) { - int32_t height = 0; int32_t currentHeight; int64_t zfunds,supply = 0; UniValue result(UniValue::VOBJ); + int32_t height = 0; int32_t currentHeight; int64_t sproutfunds,zfunds,supply = 0; UniValue result(UniValue::VOBJ); if (fHelp || params.size() > 1) throw runtime_error("coinsupply \n" "\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n" @@ -295,7 +295,8 @@ UniValue coinsupply(const UniValue& params, bool fHelp) " \"height\" : 420, (integer) The height of this coin supply data\n" " \"supply\" : \"777.0\", (float) The transparent coin supply\n" " \"zfunds\" : \"0.777\", (float) The shielded coin supply (in zaddrs)\n" - " \"total\" : \"777.777\", (float) The total coin supply, i.e. sum of supply + zfunds\n" + " \"sprout\" : \"0.077\", (float) The sprout coin supply (in zcaddrs)\n" + " \"total\" : \"777.777\", (float) The total coin supply, i.e. sum of supply + zfunds\n" "}\n" "\nExamples:\n" + HelpExampleCli("coinsupply", "420") @@ -307,13 +308,14 @@ UniValue coinsupply(const UniValue& params, bool fHelp) currentHeight = chainActive.Height(); if (height >= 0 && height <= currentHeight) { - if ( (supply= komodo_coinsupply(&zfunds,height)) > 0 ) + if ( (supply= komodo_coinsupply(&zfunds,&sproutfunds,height)) > 0 ) { result.push_back(Pair("result", "success")); result.push_back(Pair("coin", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); result.push_back(Pair("height", (int)height)); result.push_back(Pair("supply", ValueFromAmount(supply))); result.push_back(Pair("zfunds", ValueFromAmount(zfunds))); + result.push_back(Pair("sprout", ValueFromAmount(sproutfunds))); result.push_back(Pair("total", ValueFromAmount(zfunds + supply))); } else result.push_back(Pair("error", "couldnt calculate supply")); } else {