From 380875906dcc7ce634eadc6cb3945ea8751fed0d Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 22 Sep 2024 09:40:37 -0400 Subject: [PATCH] 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))