From 8adaa3641fe3d7e28db8c4563fb182dc464f5104 Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 17 Sep 2024 11:29:24 -0400 Subject: [PATCH 01/17] Exit out of TLSManager::waitFor() loop if shutdown requested --- src/hush/tlsmanager.cpp | 6 ++++++ src/net.cpp | 1 + 2 files changed, 7 insertions(+) diff --git a/src/hush/tlsmanager.cpp b/src/hush/tlsmanager.cpp index ee1329dd7..8b03445ce 100644 --- a/src/hush/tlsmanager.cpp +++ b/src/hush/tlsmanager.cpp @@ -10,6 +10,8 @@ #include "tlsmanager.h" #include "utiltls.h" +extern bool ShutdownRequested(); + using namespace std; // store our preferred cipherlist so we can use it for debug/etc later on std::string TLS_CIPHERLIST; @@ -85,6 +87,10 @@ int TLSManager::waitFor(SSLConnectionRoutine eRoutine, SOCKET hSocket, WOLFSSL* while (true) { + if(ShutdownRequested()) { + LogPrintf("%s: shutdown requested, exiting\n", __func__); + return retOp; + } // clear the current thread's error queue wolfSSL_ERR_clear_error(); diff --git a/src/net.cpp b/src/net.cpp index fd6ec86fe..f6893a54e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2927,6 +2927,7 @@ void SetNetworkActive(bool active) if (!fNetworkActive) { LOCK(cs_vNodes); // Close sockets to all nodes + LogPrint("net", "%s: closing sockets to all nodes\n", __func__); for (CNode* pnode : vNodes) { pnode->CloseSocketDisconnect(); } From f3995fa1b7e0a65d7ea3c871f2d2352cee6f22fa Mon Sep 17 00:00:00 2001 From: Duke Date: Wed, 18 Sep 2024 18:12:01 -0400 Subject: [PATCH 02/17] Cleanup MAX_BLOCK_SIZE --- src/chainparams.cpp | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 1d70612a1..18ad10cb0 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -222,24 +222,6 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat CChainParams::checkpointData = checkpointData; } -/* - To change the max block size, all that needs to be updated is the #define _MAX_BLOCK_SIZE in utils.h - - However, doing that without any other changes will allow forking non-updated nodes by creating a larger block. So, make sure to height activate the new blocksize properly. - - Assuming it is 8MB, then: - #define _OLD_MAX_BLOCK_SIZE (4096 * 1024) - #define _MAX_BLOCK_SIZE (2 * 4096 * 1024) - - change the body of if: - { - if ( height < saplinght+1000000 ) // activates 8MB blocks 1 million blocks after saplinght - return(_OLD_MAX_BLOCK_SIZE); - else return(_MAX_BLOCK_SIZE); - } - -*/ - // Unused Testnet, for completeness. We make testcoins instead. class CTestNetParams : public CChainParams { public: @@ -490,16 +472,27 @@ void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivation regTestParams.UpdateNetworkUpgradeParameters(idx, nActivationHeight); } +/* + To change the max block size, all that needs to be updated is the #define _MAX_BLOCK_SIZE in utils.h + + However, doing that without any other changes will allow forking non-updated nodes by creating a larger block. So, make sure to height activate the new blocksize properly. + + Assuming it is 8MB, then: + #define _OLD_MAX_BLOCK_SIZE (4096 * 1024) + #define _MAX_BLOCK_SIZE (2 * 4096 * 1024) + + change the body of MAX_BLOCK_SIZE() function to + { + if ( height < saplinght+1000000 ) // activates 8MB blocks 1 million blocks after saplinght + return(_OLD_MAX_BLOCK_SIZE); + else return(_MAX_BLOCK_SIZE); + } + +*/ + int32_t MAX_BLOCK_SIZE(int32_t height) { - // this codebase requires sapling activation at height=1 - int32_t saplinght = 1; // pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight; - //fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight); - //if ( height <= 0 || (saplinght > 0 && height >= saplinght) ) - //{ - return(_MAX_BLOCK_SIZE); - //} - //else return(2000000); + return(_MAX_BLOCK_SIZE); } // Change the Hush blocktime at run-time(!) From 5a3c06e53921e4b6654d1b71d7a1b4d3ad0b999f Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 20 Sep 2024 11:17:16 -0400 Subject: [PATCH 03/17] MAX_BLOCK_SIZE ignores height argument The function no longer looks at this argument so don't waste resources calculating a height. --- src/miner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 1bc0e984d..5cc09776c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -200,9 +200,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //fprintf(stderr,"%s: added dummy coinbase\n", __func__); // Largest block you're willing to create: - unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1)); + unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE(1)); // MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1)); // Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity: - nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1)-1000), nBlockMaxSize)); + nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE(1)-1000), nBlockMaxSize)); + //nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1)-1000), nBlockMaxSize)); // How much of the block should be dedicated to high-priority transactions, // included regardless of the fees they pay From dfeccf6ce488ebe7875dddb371de1464cc89a62a Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 20 Sep 2024 11:24:59 -0400 Subject: [PATCH 04/17] Make nBlockPrioritySize and nBlockMinSize consts --- src/miner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5cc09776c..ab5f8251c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -207,13 +207,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // How much of the block should be dedicated to high-priority transactions, // included regardless of the fees they pay - unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", DEFAULT_BLOCK_PRIORITY_SIZE); - nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); + const unsigned int nBlockPrioritySize = std::min( nBlockMaxSize, GetArg("-blockprioritysize", DEFAULT_BLOCK_PRIORITY_SIZE) ); + // nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); // Minimum block size you want to create; block will be filled with free transactions // until there are no more or the block reaches this size: - unsigned int nBlockMinSize = GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE); - nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); + const unsigned int nBlockMinSize = std::min(nBlockMaxSize, GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE)); + // nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); //fprintf(stderr,"%s: nBlockMaxSize=%u, nBlockPrioritySize=%u, nBlockMinSize=%u\n", __func__, nBlockMaxSize, nBlockPrioritySize, nBlockMinSize); From 792fec7689d606b1bc261afd155ee1ae494a2857 Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 20 Sep 2024 13:35:38 -0400 Subject: [PATCH 05/17] Do not lock cs_main in mining code Technically we should take this lock but it has never been there before and it leads to potentially large slow downs when mining with multiple cores. We see basically the same hashrate for a single core if we have the lock or not and that makes sense, since there is only one core, there are no other mining threads that have to wait. But on one particular CPU I saw a 6% slower hashing when mining with 2 threads and 35% slower with 3 threads. This change also means debug builds will coredump if mining is enabled. --- src/miner.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 1bc0e984d..2b5c7c033 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1320,8 +1320,7 @@ void static RandomXMiner() } CValidationState state; - { LOCK(cs_main); - + //{ LOCK(cs_main); if ( !TestBlockValidity(state,B, chainActive.LastTip(), true, false)) { h = UintToArith256(B.GetHash()); @@ -1332,8 +1331,7 @@ void static RandomXMiner() fprintf(stderr,"\n"); return(false); } - - } + //} SetThreadPriority(THREAD_PRIORITY_NORMAL); LogPrintf("HushRandomXMiner:\n"); LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", B.GetHash().GetHex(), HASHTarget.GetHex()); @@ -1692,8 +1690,8 @@ void static BitcoinMiner() fprintf(stderr," mined %s block %d!\n",SMART_CHAIN_SYMBOL,Mining_height); } CValidationState state; - { LOCK(cs_main); + //{ LOCK(cs_main); if ( !TestBlockValidity(state,B, chainActive.LastTip(), true, false)) { h = UintToArith256(B.GetHash()); @@ -1704,7 +1702,7 @@ void static BitcoinMiner() return(false); } - } + //} HUSH_CHOSEN_ONE = 1; // Found a solution SetThreadPriority(THREAD_PRIORITY_NORMAL); From 40cf90b4ff2c1edd9833f4eb0dc1b7b0aed42028 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 21 Sep 2024 11:03:49 -0400 Subject: [PATCH 06/17] Fix compile issue with missing cast to unsigned int --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 466533ebb..7aedb7a34 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -207,12 +207,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // How much of the block should be dedicated to high-priority transactions, // included regardless of the fees they pay - const unsigned int nBlockPrioritySize = std::min( nBlockMaxSize, GetArg("-blockprioritysize", DEFAULT_BLOCK_PRIORITY_SIZE) ); + const unsigned int nBlockPrioritySize = std::min( nBlockMaxSize, (unsigned int) GetArg("-blockprioritysize", DEFAULT_BLOCK_PRIORITY_SIZE) ); // nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); // Minimum block size you want to create; block will be filled with free transactions // until there are no more or the block reaches this size: - const unsigned int nBlockMinSize = std::min(nBlockMaxSize, GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE)); + const unsigned int nBlockMinSize = std::min(nBlockMaxSize, (unsigned int) GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE)); // nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); //fprintf(stderr,"%s: nBlockMaxSize=%u, nBlockPrioritySize=%u, nBlockMinSize=%u\n", __func__, nBlockMaxSize, nBlockPrioritySize, nBlockMinSize); From 3fba035c01a8bc370402559a2c43fdfd64fab0a1 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 21 Sep 2024 11:04:25 -0400 Subject: [PATCH 07/17] const some stuff --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 7aedb7a34..96ea06236 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -786,7 +786,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& hashPrevBlock = pblock->hashPrevBlock; } ++nExtraNonce; - unsigned int nHeight = pindexPrev->GetHeight()+1; // Height first in coinbase required for block.version=2 + const unsigned int nHeight = pindexPrev->GetHeight()+1; // Height first in coinbase required for block.version=2 CMutableTransaction txCoinbase(pblock->vtx[0]); txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS; assert(txCoinbase.vin[0].scriptSig.size() <= 100); @@ -1152,7 +1152,7 @@ void static RandomXMiner() } else { rxdebug("%s: calculating keyHeight with randomxInterval=%d\n", randomxInterval); // At heights between intervals, we use the same block key and wait randomxBlockLag blocks until changing - int keyHeight = ((Mining_height - randomxBlockLag) / randomxInterval) * randomxInterval; + const int keyHeight = ((Mining_height - randomxBlockLag) / randomxInterval) * randomxInterval; uint256 randomxBlockKey = chainActive[keyHeight]->GetBlockHash(); randomx_init_cache(randomxCache, &randomxBlockKey, sizeof randomxBlockKey); From 45de2584b92707ef4489fa907af0139725ba54c6 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 21 Sep 2024 11:25:48 -0400 Subject: [PATCH 08/17] ASSETCHAINS_STAKED is always zero --- src/miner.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 96ea06236..3f393d2c0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -736,7 +736,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 pblock->hashFinalSaplingRoot = sapling_tree.root(); // all PoS chains need this data in the block at all times - if ( ASSETCHAINS_LWMAPOS || ASSETCHAINS_STAKED == 0 || HUSH_MININGTHREADS > 0 ) + if ( ASSETCHAINS_LWMAPOS || HUSH_MININGTHREADS > 0 ) { UpdateTime(pblock, Params().GetConsensus(), pindexPrev); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); @@ -744,7 +744,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 pblock->nSolution.clear(); pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); - if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (IS_HUSH_NOTARY == 0 || My_notaryid < 0) ) + if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && (IS_HUSH_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; //fprintf(stderr,"%s: check validity\n", __func__); @@ -1206,7 +1206,7 @@ void static RandomXMiner() return; } static uint32_t counter; - if ( counter++ < 10 && ASSETCHAINS_STAKED == 0 ) + if ( counter++ < 10 ) fprintf(stderr,"RandomXMiner: created illegal blockB, retry with counter=%u\n", counter); sleep(1); continue; From 986d0d8b7da89b95dfd355156aa48278cf8d1e18 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 22 Sep 2024 08:51:48 -0400 Subject: [PATCH 09/17] isStake is always zero --- src/miner.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3f393d2c0..ca3341fb7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -762,11 +762,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //fprintf(stderr,"valid\n"); } } - if ( !isStake ) - { - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); - } + + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + // fprintf(stderr,"%s: done\n", __func__); return pblocktemplate.release(); } From 26a341983ae02d8a72211b2fb7e2e3441d55a14f Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 22 Sep 2024 08:57:23 -0400 Subject: [PATCH 10/17] const some stuff --- src/miner.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index ca3341fb7..b27e68161 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1163,10 +1163,10 @@ void static RandomXMiner() rxdebug("%s: initializing dataset with %d threads\n", initThreadCount); std::vector threads; uint32_t startItem = 0; - auto perThread = datasetItemCount / initThreadCount; - auto remainder = datasetItemCount % initThreadCount; + const auto perThread = datasetItemCount / initThreadCount; + const auto remainder = datasetItemCount % initThreadCount; for (int i = 0; i < initThreadCount; ++i) { - auto count = perThread + (i == initThreadCount - 1 ? remainder : 0); + const auto count = perThread + (i == initThreadCount - 1 ? remainder : 0); threads.push_back(std::thread(&randomx_init_dataset, randomxDataset, randomxCache, startItem, count)); startItem += count; } @@ -1399,10 +1399,8 @@ void static RandomXMiner() rxdebug("%s: going to destroy rx VM\n"); randomx_destroy_vm(myVM); rxdebug("%s: destroyed VM\n"); - } - } catch (const boost::thread_interrupted&) { miningTimer.stop(); c.disconnect(); From 380875906dcc7ce634eadc6cb3945ea8751fed0d Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 22 Sep 2024 09:40:37 -0400 Subject: [PATCH 11/17] Remove more CC stuff --- src/main.cpp | 4 -- src/script/interpreter.cpp | 79 +------------------------------------- src/script/interpreter.h | 14 ------- src/script/standard.cpp | 74 +---------------------------------- src/txdb.cpp | 16 +------- src/wallet/wallet.cpp | 11 ------ 6 files changed, 4 insertions(+), 194 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3ddf5bb54..6f99a51e7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2899,10 +2899,6 @@ int8_t GetAddressType(const CScript &scriptPubKey, CTxDestination &vDest, txnout { keyType = 2; } - else if (txType == TX_CRYPTOCONDITION ) - { - keyType = 3; - } } return keyType; } diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index a8d5fa6ce..68930a5b5 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -957,37 +957,6 @@ bool EvalScript( } break; - /* - case OP_CHECKCRYPTOCONDITION: - case OP_CHECKCRYPTOCONDITIONVERIFY: - { - if (!IsCryptoConditionsEnabled()) { - goto INTERPRETER_DEFAULT; - } - - if (stack.size() < 2) - return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); - //fprintf(stderr,"check cryptocondition\n"); - int fResult = checker.CheckCryptoCondition(stacktop(-1), stacktop(-2), script, consensusBranchId); - if (fResult == -1) { - return set_error(serror, SCRIPT_ERR_CRYPTOCONDITION_INVALID_FULFILLMENT); - } - - popstack(stack); - popstack(stack); - - stack.push_back(fResult == 1 ? vchTrue : vchFalse); - - if (opcode == OP_CHECKCRYPTOCONDITIONVERIFY) - { - if (fResult == 1) - popstack(stack); - else - return set_error(serror, SCRIPT_ERR_CRYPTOCONDITION_VERIFY); - } - } - break; - */ INTERPRETER_DEFAULT: default: @@ -1356,15 +1325,6 @@ bool TransactionSignatureChecker::CheckSig( } -int TransactionSignatureChecker::CheckCryptoCondition( - const std::vector& condBin, - const std::vector& ffillBin, - const CScript& scriptCode, - uint32_t consensusBranchId) const -{ - return 0; -} - bool TransactionSignatureChecker::CheckLockTime(const CScriptNum& nLockTime) const { // There are two times of nLockTime: lock-by-blockheight @@ -1407,38 +1367,6 @@ bool TransactionSignatureChecker::CheckLockTime(const CScriptNum& nLockTime) con return true; } - -/* - * Allow larger opcode in case of crypto condition scriptSig - */ -bool EvalCryptoConditionSig( - vector >& stack, - const CScript& scriptSig, - ScriptError* serror) -{ - CScript::const_iterator pc = scriptSig.begin(); - opcodetype opcode; - valtype vchPushValue; - set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); - - if (!scriptSig.GetOp(pc, opcode, vchPushValue)) - return set_error(serror, SCRIPT_ERR_BAD_OPCODE); - - if (opcode == 0 || opcode > OP_PUSHDATA4) - return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); - - if (pc != scriptSig.end()) - return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); - - if (vchPushValue.size() > MAX_SCRIPT_CRYPTOCONDITION_FULFILLMENT_SIZE) - return set_error(serror, SCRIPT_ERR_PUSH_SIZE); - - stack.push_back(vchPushValue); - - return true; -} - - bool VerifyScript( const CScript& scriptSig, const CScript& scriptPubKey, @@ -1454,12 +1382,7 @@ bool VerifyScript( } vector > stack, stackCopy; - if (IsCryptoConditionsEnabled() && scriptPubKey.IsPayToCryptoCondition()) { - if (!EvalCryptoConditionSig(stack, scriptSig, serror)) - // serror is set - return false; - } - else if (!EvalScript(stack, scriptSig, flags, checker, consensusBranchId, serror)) + if (!EvalScript(stack, scriptSig, flags, checker, consensusBranchId, serror)) // serror is set return false; if (flags & SCRIPT_VERIFY_P2SH) diff --git a/src/script/interpreter.h b/src/script/interpreter.h index a1be175ac..2c110a57e 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -147,15 +147,6 @@ public: return false; } - virtual int CheckCryptoCondition( - const std::vector& condBin, - const std::vector& ffillBin, - const CScript& scriptCode, - uint32_t consensusBranchId) const - { - return false; - } - virtual ~BaseSignatureChecker() {} }; @@ -174,11 +165,6 @@ public: TransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, const PrecomputedTransactionData& txdataIn) : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {} bool CheckSig(const std::vector& scriptSig, const std::vector& vchPubKey, const CScript& scriptCode, uint32_t consensusBranchId) const; bool CheckLockTime(const CScriptNum& nLockTime) const; - int CheckCryptoCondition( - const std::vector& condBin, - const std::vector& ffillBin, - const CScript& scriptCode, - uint32_t consensusBranchId) const; }; class MutableTransactionSignatureChecker : public TransactionSignatureChecker diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 1ace50bc1..23ffc0ff9 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -183,40 +183,6 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector> vParams; - if (scriptPubKey.IsPayToCryptoCondition(&ccSubScript, vParams)) - { - if (scriptPubKey.MayAcceptCryptoCondition()) - { - typeRet = TX_CRYPTOCONDITION; - vector hashBytes; uint160 x; int32_t i; uint8_t hash20[20],*ptr;; - x = Hash160(ccSubScript); - memcpy(hash20,&x,20); - hashBytes.resize(20); - ptr = hashBytes.data(); - for (i=0; i<20; i++) - ptr[i] = hash20[i]; - vSolutionsRet.push_back(hashBytes); - if (vParams.size()) - { - COptCCParams cp = COptCCParams(vParams[0]); - if (cp.IsValid()) - { - for (auto k : cp.vKeys) - { - vSolutionsRet.push_back(std::vector(k.begin(), k.end())); - } - } - } - return true; - } - return false; - } - } - // Scan templates const CScript& script1 = scriptPubKey; BOOST_FOREACH(const PAIRTYPE(txnouttype, CScript)& tplate, mTemplates) @@ -404,21 +370,6 @@ bool ExtractDestination(const CScript& _scriptPubKey, CTxDestination& addressRet addressRet = CScriptID(uint160(vSolutions[0])); return true; } - - else if (IsCryptoConditionsEnabled() != 0 && whichType == TX_CRYPTOCONDITION) - { - if (vSolutions.size() > 1) - { - CPubKey pk = CPubKey((vSolutions[1])); - addressRet = pk; - return pk.IsValid(); - } - else - { - addressRet = CKeyID(uint160(vSolutions[0])); - } - return true; - } // Multisig txns have more than one address... return false; } @@ -464,30 +415,7 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto if (addressRet.empty()) return false; - } - // Removed to get CC address printed in getrawtransaction and decoderawtransaction - // else if (IsCryptoConditionsEnabled() != 0 && typeRet == TX_CRYPTOCONDITION) - // { - // nRequiredRet = vSolutions.front()[0]; - // for (unsigned int i = 1; i < vSolutions.size()-1; i++) - // { - // CTxDestination address; - // if (vSolutions[i].size() == 20) - // { - // address = CKeyID(uint160(vSolutions[i])); - // } - // else - // { - // address = CPubKey(vSolutions[i]); - // } - // addressRet.push_back(address); - // } - - // if (addressRet.empty()) - // return false; - // } - else - { + } else { nRequiredRet = 1; CTxDestination address; if (!ExtractDestination(scriptPubKey, address)) diff --git a/src/txdb.cpp b/src/txdb.cpp index 286919bb7..6a6f7c086 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -456,7 +456,7 @@ uint32_t hush_segid32(char *coinaddr); bool CBlockTreeDB::Snapshot2(std::map &addressAmounts, UniValue *ret) { int64_t total = 0; int64_t totalAddresses = 0; std::string address; - int64_t utxos = 0; int64_t ignoredAddresses = 0, cryptoConditionsUTXOs = 0, cryptoConditionsTotals = 0; + int64_t utxos = 0; int64_t ignoredAddresses = 0; DECLARE_IGNORELIST boost::scoped_ptr iter(NewIterator()); //std::map addressAmounts; @@ -479,13 +479,7 @@ bool CBlockTreeDB::Snapshot2(std::map &addressAmounts, Un if ( nValue == 0 ) continue; getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); - if ( indexKey.type == 3 ) - { - cryptoConditionsUTXOs++; - cryptoConditionsTotals += nValue; - total += nValue; - continue; - } + std::map ::iterator ignored = ignoredMap.find(address); if (ignored != ignoredMap.end()) { @@ -540,12 +534,6 @@ bool CBlockTreeDB::Snapshot2(std::map &addressAmounts, Un ret->push_back(make_pair("total_addresses", totalAddresses )); // Total number of ignored addresses in this snaphot ret->push_back(make_pair("ignored_addresses", ignoredAddresses)); - // Total number of crypto condition utxos we skipped - ret->push_back(make_pair("skipped_cc_utxos", cryptoConditionsUTXOs)); - // Total value of skipped crypto condition utxos - ret->push_back(make_pair("cc_utxo_value", (double) cryptoConditionsTotals / COIN)); - // total of all the address's, does not count coins in CC vouts. - ret->push_back(make_pair("total_includeCCvouts", (double) (total+cryptoConditionsTotals)/ COIN )); // The snapshot finished at this block height ret->push_back(make_pair("ending_height", chainActive.Height())); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 01af7b78e..b4bb6ded9 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1977,17 +1977,6 @@ isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum) case TX_NULL_DATA: break; - case TX_CRYPTOCONDITION: - // for now, default is that the first value returned will be the script, subsequent values will be - // pubkeys. if we have the first pub key in our wallet, we consider this spendable - if (vSolutions.size() > 1) - { - keyID = CPubKey(vSolutions[1]).GetID(); - if (this->HaveKey(keyID)) - return ISMINE_SPENDABLE; - } - break; - case TX_PUBKEY: keyID = CPubKey(vSolutions[0]).GetID(); if (this->HaveKey(keyID)) From 148ea35a985443ea8a142b760015e1e2205ed1b8 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 22 Sep 2024 11:56:12 -0400 Subject: [PATCH 12/17] Remove dead sprout code --- src/main.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6f99a51e7..f76da499b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1223,16 +1223,6 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde { const bool overwinterActive = nHeight >=1 ? true : false; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); const bool saplingActive = nHeight >=1 ? true : false; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); - const bool isSprout = false; //!overwinterActive; - - /* - // If Sprout rules apply, reject transactions which are intended for Overwinter and beyond - if (isSprout && tx.fOverwintered) { - int32_t ht = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight; - return state.DoS((ht < 0 || nHeight < ht) ? 0 : dosLevel,error("ContextualCheckTransaction(): ht.%d activates.%d dosLevel.%d overwinter is not active yet",nHeight, Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight, dosLevel),REJECT_INVALID, "tx-overwinter-not-active"); - //return state.DoS(isInitBlockDownload() ? 0 : dosLevel,error("ContextualCheckTransaction(): ht.%d activates.%d dosLevel.%d overwinter is not active yet",nHeight, Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight, dosLevel),REJECT_INVALID, "tx-overwinter-not-active"); - } - */ if (saplingActive) { // Reject transactions with valid version but missing overwintered flag From f6b42fe3a34085f1770ac3973378ad2ee87c7d1b Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 22 Sep 2024 12:12:22 -0400 Subject: [PATCH 13/17] We do not support coin imports --- src/primitives/transaction.h | 5 +++-- src/rpc/rawtransaction.cpp | 26 +------------------------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 3741e0d96..a2584ca64 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -693,7 +693,7 @@ public: bool IsMint() const { - return IsCoinImport() || IsCoinBase(); + return IsCoinBase(); // || IsCoinImport(); } bool IsCoinBase() const @@ -705,7 +705,8 @@ public: bool IsCoinImport() const { - return (vin.size() == 1 && vin[0].prevout.n == 10e8); + return false; + //return (vin.size() == 1 && vin[0].prevout.n == 10e8); } bool IsPegsImport() const diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 4de29bd4c..4c9de7c95 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -146,31 +146,7 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& UniValue in(UniValue::VOBJ); if (tx.IsCoinBase()) { in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); - } - /* else if (tx.IsCoinImport() && txin.prevout.n==10e8) { - in.push_back(Pair("is_import", "1")); - ImportProof proof; CTransaction burnTx; std::vector payouts; CTxDestination importaddress; - if (UnmarshalImportTx(tx, proof, burnTx, payouts)) - { - if (burnTx.vout.size() == 0) - continue; - in.push_back(Pair("txid", burnTx.GetHash().ToString())); - in.push_back(Pair("value", ValueFromAmount(burnTx.vout.back().nValue))); - in.push_back(Pair("valueSat", burnTx.vout.back().nValue)); - // extract op_return to get burn source chain. - std::vector burnOpret; std::string targetSymbol; uint32_t targetCCid; uint256 payoutsHash; std::vectorrawproof; - if (UnmarshalBurnTx(burnTx, targetSymbol, &targetCCid, payoutsHash, rawproof)) - { - if (rawproof.size() > 0) - { - std::string sourceSymbol; - E_UNMARSHAL(rawproof, ss >> sourceSymbol); - in.push_back(Pair("address", "IMP-" + sourceSymbol + "-" + burnTx.GetHash().ToString())); - } - } - } - } */ - else { + } else { in.push_back(Pair("txid", txin.prevout.hash.GetHex())); in.push_back(Pair("vout", (int64_t)txin.prevout.n)); { From b6bcacad206000e83f3f564e6412c4f26dc30483 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 22 Sep 2024 12:16:21 -0400 Subject: [PATCH 14/17] We do not support coin imports --- src/main.cpp | 6 +++--- src/script/script.cpp | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f76da499b..4e7321130 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1103,8 +1103,8 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, if (tx.IsCoinBase()) return true; // Coinbases don't use vin normally - if (tx.IsCoinImport()) - return tx.vin[0].scriptSig.IsCoinImport(); + //if (tx.IsCoinImport()) + // return tx.vin[0].scriptSig.IsCoinImport(); for (unsigned int i = 0; i < tx.vin.size(); i++) { @@ -1950,7 +1950,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa dFreeCount += nSize; } - if (!tx.IsCoinImport() && fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000 && nFees > nValueOut/19) + if ( fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000 && nFees > nValueOut/19) { string errmsg = strprintf("absurdly high fees %s, %d > %d", hash.ToString(), diff --git a/src/script/script.cpp b/src/script/script.cpp index afae6f1d6..532227741 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -382,12 +382,6 @@ bool CScript::MayAcceptCryptoCondition() const bool CScript::IsCoinImport() const { - const_iterator pc = this->begin(); - vector data; - opcodetype opcode; - if (this->GetOp(pc, opcode, data)) - if (opcode > OP_0 && opcode <= OP_PUSHDATA4) - return data.begin()[0] == EVAL_IMPORTCOIN; return false; } From bd5f0103a8bbdd9846629adc33d02b31cfd8dd27 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 22 Sep 2024 12:19:12 -0400 Subject: [PATCH 15/17] Remove more cc code --- src/hush_nSPV_fullnode.h | 58 ---------------------------------------- src/rpc/blockchain.cpp | 2 +- 2 files changed, 1 insertion(+), 59 deletions(-) diff --git a/src/hush_nSPV_fullnode.h b/src/hush_nSPV_fullnode.h index 2cf9cc9f5..57a3dd67a 100644 --- a/src/hush_nSPV_fullnode.h +++ b/src/hush_nSPV_fullnode.h @@ -233,64 +233,6 @@ public: DefaultCCChecker() { } virtual bool checkCC(uint256 txid, const std::vector &vouts, int32_t nvout, uint8_t evalcode, std::string funcids, uint256 filtertxid) { - CScript opret, dummy; - std::vector< vscript_t > vParams; - vscript_t vopret; - - if (nvout < vouts.size()) - { - // first check if it is cc vout - if (vouts[nvout].scriptPubKey.IsPayToCryptoCondition(&dummy, vParams)) - { - // try to find cc opret - if (vParams.size() > 0) - { - COptCCParams p(vParams[0]); // parse vout data - if (p.vData.size() > 0) - { - vopret = p.vData[0]; // get opret data - } - } - // if no cc opret check last vout opret - if (vopret.size() == 0) - { - GetOpReturnData(vouts.back().scriptPubKey, vopret); - } - if (vopret.size() > 2) - { - uint8_t opretEvalcode, opretFuncid; - uint256 opretTxid; - bool isEof = true; - bool isCreateTx = false; - - // parse opret first 3 fields: - bool parseOk = E_UNMARSHAL(vopret, - ss >> opretEvalcode; - ss >> opretFuncid; - if (funcids.size() > 0 && opretFuncid == funcids[0]) // this means that we check txid only for second+ funcid in array (considering that the first funcid is the creation txid itself like tokens) - { - isCreateTx = true; - } - else - { - ss >> opretTxid; - isCreateTx = false; - } - isEof = ss.eof(); ); - - opretTxid = revuint256(opretTxid); - std::cerr << __func__ << " " << "opretEvalcode=" << opretEvalcode << " opretFuncid=" << (char)opretFuncid << " isCreateTx=" << isCreateTx << " opretTxid=" << opretTxid.GetHex() << std::endl; - if( parseOk /*parseOk=true if eof reached*/|| !isEof /*more data means okay*/) - { - if (evalcode == opretEvalcode && std::find(funcids.begin(), funcids.end(), (char)opretFuncid) != funcids.end() && - (isCreateTx && filtertxid == txid || !isCreateTx && filtertxid == opretTxid)) - { - return true; - } - } - } - } - } return false; } }; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index dbd0da9ed..7a26b2b03 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -242,7 +242,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) vector hashBytes(out.scriptPubKey.begin()+3, out.scriptPubKey.begin()+23); delta.push_back(Pair("address", CBitcoinAddress(CKeyID(uint160(hashBytes))).ToString())); } - else if (out.scriptPubKey.IsPayToPublicKey() || out.scriptPubKey.IsPayToCryptoCondition()) { + else if (out.scriptPubKey.IsPayToPublicKey()) { CTxDestination address; if (ExtractDestination(out.scriptPubKey, address)) { From 01f0c346619cd98fdeb9bc8ab5f1518a7d61aca5 Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 24 Sep 2024 09:35:20 -0400 Subject: [PATCH 16/17] We do not support coin imports --- src/coins.cpp | 4 +--- src/main.cpp | 36 ++++++++++++++++-------------------- src/txmempool.cpp | 11 +++++------ 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index 8801b397c..1e5bff4e3 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -557,8 +557,6 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr CAmount value,nResult = 0; if ( interestp != 0 ) *interestp = 0; - //if ( tx.IsCoinImport() ) - // return GetCoinImportValue(tx); if ( tx.IsCoinBase() != 0 ) return 0; for (unsigned int i = 0; i < tx.vin.size(); i++) @@ -616,7 +614,7 @@ double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight) const // use the maximum priority for all (partially or fully) shielded transactions. // (Note that coinbase transactions cannot contain Sapling shielded Spends or Outputs.) - if (tx.vShieldedSpend.size() > 0 || tx.vShieldedOutput.size() > 0 || tx.IsCoinImport() ) { // || tx.IsPegsImport()) { + if (tx.vShieldedSpend.size() > 0 || tx.vShieldedOutput.size() > 0 ) { return MAX_PRIORITY; } diff --git a/src/main.cpp b/src/main.cpp index 4e7321130..307801fd3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -817,7 +817,7 @@ bool hush_dailysnapshot(int32_t height) { uint256 blockhash; CTransaction txin; //if (tx.IsPegsImport() && j==0) continue; - if ( !tx.IsCoinImport() && !tx.IsCoinBase() && myGetTransaction(tx.vin[j].prevout.hash,txin,blockhash) ) + if ( !tx.IsCoinBase() && myGetTransaction(tx.vin[j].prevout.hash,txin,blockhash) ) { int vout = tx.vin[j].prevout.n; if ( ExtractDestination(txin.vout[vout].scriptPubKey, vDest) ) @@ -1180,7 +1180,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx) unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& inputs) { - if (tx.IsCoinBase() || tx.IsCoinImport()) + if (tx.IsCoinBase()) return 0; unsigned int nSigOps = 0; @@ -1889,13 +1889,11 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Keep track of transactions that spend a coinbase, which we re-scan // during reorgs to ensure COINBASE_MATURITY is still met. bool fSpendsCoinbase = false; - if (!tx.IsCoinImport()) { // && !tx.IsPegsImport()) { - BOOST_FOREACH(const CTxIn &txin, tx.vin) { - const CCoins *coins = view.AccessCoins(txin.prevout.hash); - if (coins->IsCoinBase()) { - fSpendsCoinbase = true; - break; - } + BOOST_FOREACH(const CTxIn &txin, tx.vin) { + const CCoins *coins = view.AccessCoins(txin.prevout.hash); + if (coins->IsCoinBase()) { + fSpendsCoinbase = true; + break; } } // Grab the branch ID we expect this transaction to commit to. We don't @@ -1927,7 +1925,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Continuously rate-limit free (really, very-low-fee) transactions // This mitigates 'penny-flooding' -- sending thousands of free transactions just to // be annoying or make others' transactions take longer to confirm. - if (fLimitFree && nFees < ::minRelayTxFee.GetFee(nSize) && !tx.IsCoinImport() ) + if (fLimitFree && nFees < ::minRelayTxFee.GetFee(nSize) ) { static CCriticalSection csFreeLimiter; static double dFreeCount; @@ -1998,17 +1996,15 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa LOCK(pool.cs); // Store transaction in memory pool.addUnchecked(hash, entry, !IsInitialBlockDownload()); - if (!tx.IsCoinImport()) - { - // Add memory address index - if (fAddressIndex) { - pool.addAddressIndex(entry, view); - } - // Add memory spent index - if (fSpentIndex) { - pool.addSpentIndex(entry, view); - } + // Add memory address index + if (fAddressIndex) { + pool.addAddressIndex(entry, view); + } + + // Add memory spent index + if (fSpentIndex) { + pool.addSpentIndex(entry, view); } } } diff --git a/src/txmempool.cpp b/src/txmempool.cpp index da4e0bd59..a6be3752d 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -120,13 +120,12 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, const CTransaction& tx = mapTx.find(hash)->GetTx(); mapRecentlyAddedTx[tx.GetHash()] = &tx; nRecentlyAddedSequence += 1; - if (!tx.IsCoinImport()) { - for (unsigned int i = 0; i < tx.vin.size(); i++) - { - //if (tx.IsPegsImport() && i==0) continue; - mapNextTx[tx.vin[i].prevout] = CInPoint(&tx, i); - } + + for (unsigned int i = 0; i < tx.vin.size(); i++) + { + mapNextTx[tx.vin[i].prevout] = CInPoint(&tx, i); } + for (const SpendDescription &spendDescription : tx.vShieldedSpend) { mapSaplingNullifiers[spendDescription.nullifier] = &tx; } From 18e4ca070efc19566d564a16daa6fae6defa1d11 Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 1 Oct 2024 10:49:13 -0400 Subject: [PATCH 17/17] Remove more cc stuff --- src/hush_nSPV_wallet.h | 27 +++++---------------------- src/main.cpp | 5 ++--- src/script/script.cpp | 3 --- src/script/script.h | 6 ------ src/script/script_error.cpp | 2 -- src/script/script_error.h | 3 --- src/script/sign.cpp | 31 ------------------------------- src/script/standard.cpp | 3 --- src/script/standard.h | 1 - src/txmempool.cpp | 13 ------------- src/wallet/wallet_ismine.cpp | 10 ---------- 11 files changed, 7 insertions(+), 97 deletions(-) diff --git a/src/hush_nSPV_wallet.h b/src/hush_nSPV_wallet.h index 5e329aa2a..85075e29f 100644 --- a/src/hush_nSPV_wallet.h +++ b/src/hush_nSPV_wallet.h @@ -322,31 +322,14 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a } else if ( bitcoin_base58decode(rmd160,destaddr) != 25 ) { - if ( (len= is_hexstr(destaddr,0)) > 0 ) - { - len >>= 1; - data.resize(len); - decode_hex(&data[0],len,destaddr); - if ( data[len-1] == OP_CHECKCRYPTOCONDITION ) - { - data.resize(--len); - scriptPubKey = CScript() << data << OP_CHECKCRYPTOCONDITION; - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","only CC hex allowed for now")); - return(result); } - } - else - { + if ( (len= is_hexstr(destaddr,0)) > 0 ) { + result.push_back(Pair("result","error")); + return(result); + } else { result.push_back(Pair("result","error")); - result.push_back(Pair("error","invalid destaddr/CCvout hex")); return(result); } - } - else - { + } else { data.resize(20); memcpy(&data[0],&rmd160[1],20); scriptPubKey = (CScript() << OP_DUP << OP_HASH160 << ParseHex(HexStr(data)) << OP_EQUALVERIFY << OP_CHECKSIG); diff --git a/src/main.cpp b/src/main.cpp index c2df1a3e5..a60821d03 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -994,11 +994,10 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) } nDataOut++; //fprintf(stderr,"is OP_RETURN\n"); - } - else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { + } else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { reason = "bare-multisig"; return false; - } else if (whichType != TX_CRYPTOCONDITION && txout.IsDust(::minRelayTxFee)) { + } else if (txout.IsDust(::minRelayTxFee)) { reason = "dust"; return false; } diff --git a/src/script/script.cpp b/src/script/script.cpp index 532227741..09b876ed9 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -156,9 +156,6 @@ const char* GetOpName(opcodetype opcode) case OP_CHECKSIGVERIFY : return "OP_CHECKSIGVERIFY"; case OP_CHECKMULTISIG : return "OP_CHECKMULTISIG"; case OP_CHECKMULTISIGVERIFY : return "OP_CHECKMULTISIGVERIFY"; - case OP_CHECKCRYPTOCONDITION : return "OP_CHECKCRYPTOCONDITION"; - case OP_CHECKCRYPTOCONDITIONVERIFY - : return "OP_CHECKCRYPTOCONDITIONVERIFY"; // expansion case OP_NOP1 : return "OP_NOP1"; diff --git a/src/script/script.h b/src/script/script.h index cc35f0364..b3d1d203f 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -40,9 +40,6 @@ static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes -// Max size of pushdata in a CC sig in bytes -static const unsigned int MAX_SCRIPT_CRYPTOCONDITION_FULFILLMENT_SIZE = 2048; - // Maximum script length in bytes static const int MAX_SCRIPT_SIZE = 10000; @@ -178,8 +175,6 @@ enum opcodetype OP_CHECKSIGVERIFY = 0xad, OP_CHECKMULTISIG = 0xae, OP_CHECKMULTISIGVERIFY = 0xaf, - OP_CHECKCRYPTOCONDITION = 0xcc, - OP_CHECKCRYPTOCONDITIONVERIFY = 0xcd, // expansion OP_NOP1 = 0xb0, @@ -200,7 +195,6 @@ enum opcodetype OP_PUBKEYS = 0xfb, OP_PUBKEYHASH = 0xfd, OP_PUBKEY = 0xfe, - OP_CRYPTOCONDITION = 0xfc, OP_INVALIDOPCODE = 0xff, }; diff --git a/src/script/script_error.cpp b/src/script/script_error.cpp index cd1989e44..5529362d6 100644 --- a/src/script/script_error.cpp +++ b/src/script/script_error.cpp @@ -83,8 +83,6 @@ const char* ScriptErrorString(const ScriptError serror) return "NOPx reserved for soft-fork upgrades"; case SCRIPT_ERR_PUBKEYTYPE: return "Public key is neither compressed or uncompressed"; - case SCRIPT_ERR_CRYPTOCONDITION_INVALID_FULFILLMENT: - return "Crypto-Condition payload is invalid"; case SCRIPT_ERR_UNKNOWN_ERROR: case SCRIPT_ERR_ERROR_COUNT: default: break; diff --git a/src/script/script_error.h b/src/script/script_error.h index d34e715a6..278852f6e 100644 --- a/src/script/script_error.h +++ b/src/script/script_error.h @@ -70,9 +70,6 @@ typedef enum ScriptError_t SCRIPT_ERR_ERROR_COUNT, - /* crypto-condition script errors */ - SCRIPT_ERR_CRYPTOCONDITION_VERIFY, - SCRIPT_ERR_CRYPTOCONDITION_INVALID_FULFILLMENT } ScriptError; #define SCRIPT_ERR_LAST SCRIPT_ERR_ERROR_COUNT diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 245806733..afc778d4b 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -128,29 +128,6 @@ static bool SignN(const vector& multisigdata, const BaseSignatureCreato return nSigned==nRequired; } -std::vector &GetCryptoConditions() -{ - static bool initialized = false; - static std::vector vCC = std::vector(); - CCcontract_info C; - - if (!initialized) - { - // this should initialize any desired auto-signed crypto-conditions - } - return vCC; -} - -bool GetCCByUnspendableAddress(struct CCcontract_info *cp, char *addrstr) -{ - return false; -} - -bool CCinitLite(struct CCcontract_info *cp, uint8_t evalcode) -{ - return false; -} - bool _Getscriptaddress(char *destaddr, const CScript &scriptPubKey) { CTxDestination address; @@ -239,9 +216,6 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP } return false; - case TX_CRYPTOCONDITION: - return SignStepCC(creator, scriptPubKey, vSolutions, ret, consensusBranchId); - case TX_MULTISIG: ret.push_back(valtype()); // workaround CHECKMULTISIG bug return (SignN(vSolutions, creator, scriptPubKey, ret, consensusBranchId)); @@ -429,11 +403,6 @@ static Stacks CombineSignatures(const CScript& scriptPubKey, const BaseSignature return sigs2; case TX_PUBKEY: case TX_PUBKEYHASH: - case TX_CRYPTOCONDITION: - // Signatures are bigger than placeholders or empty scripts: - if (sigs1.script.empty() || sigs1.script[0].empty()) - return sigs2; - return sigs1; case TX_SCRIPTHASH: if (sigs1.script.empty() || sigs1.script.back().empty()) return sigs2; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 23ffc0ff9..637da08ec 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -143,7 +143,6 @@ const char* GetTxnOutputType(txnouttype t) case TX_SCRIPTHASH: return "scripthash"; case TX_MULTISIG: return "multisig"; case TX_NULL_DATA: return "nulldata"; - case TX_CRYPTOCONDITION: return "cryptocondition"; default: return "invalid"; } return NULL; @@ -294,8 +293,6 @@ int ScriptSigArgsExpected(txnouttype t, const std::vector(hashBytes.begin(), hashBytes.end())); - } - } if (txType == TX_SCRIPTHASH) { keyType = 2; @@ -190,11 +182,6 @@ void CTxMemPool::addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewC // if we failed to solve, and got a vDest, assume P2PKH or P2PK address returned if (vDest.which()) { - uint160 hashBytes; - if (CBitcoinAddress(vDest).GetIndexKey(hashBytes, keyType, out.scriptPubKey.IsPayToCryptoCondition())) - { - vSols.push_back(vector(hashBytes.begin(), hashBytes.end())); - } } else if (txType == TX_SCRIPTHASH) { diff --git a/src/wallet/wallet_ismine.cpp b/src/wallet/wallet_ismine.cpp index c80e37d9a..5897f2bbf 100644 --- a/src/wallet/wallet_ismine.cpp +++ b/src/wallet/wallet_ismine.cpp @@ -78,16 +78,6 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& _scriptPubKey) case TX_NONSTANDARD: case TX_NULL_DATA: break; - case TX_CRYPTOCONDITION: - // for now, default is that the first value returned will be the script, subsequent values will be - // pubkeys. if we have the first pub key in our wallet, we consider this spendable - if (vSolutions.size() > 1) - { - keyID = CPubKey(vSolutions[1]).GetID(); - if (keystore.HaveKey(keyID)) - return ISMINE_SPENDABLE; - } - break; case TX_PUBKEY: keyID = CPubKey(vSolutions[0]).GetID(); if (keystore.HaveKey(keyID))