diff --git a/src/Makefile.am b/src/Makefile.am index d3bd209a4..f914300de 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -410,7 +410,6 @@ libbitcoin_common_a_SOURCES = \ script/sign.cpp \ script/standard.cpp \ transaction_builder.cpp \ - cc/CCtokenutils.cpp \ cc/CCutilbits.cpp \ $(BITCOIN_CORE_H) \ $(LIBZCASH_H) diff --git a/src/cc/CCtokenutils.cpp b/src/cc/CCtokenutils.cpp deleted file mode 100644 index 3119aec36..000000000 --- a/src/cc/CCtokenutils.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2016-2023 The Hush developers -// Distributed under the GPLv3 software license, see the accompanying -// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -/****************************************************************************** -* Copyright © 2014-2019 The SuperNET Developers. * -* * -* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * -* the top-level directory of this distribution for the individual copyright * -* holder information and the developer policies on copyright and licensing. * -* * -* Unless otherwise agreed in a custom licensing agreement, no part of the * -* SuperNET software, including this file may be copied, modified, propagated * -* or distributed except according to the terms contained in the LICENSE file * -* * -* Removal or modification of this copyright notice is prohibited. * -* * -******************************************************************************/ - -// encode decode tokens opret -// make token cryptoconditions and vouts -// This code was moved to a separate source file to enable linking libcommon.so (with importcoin.cpp which depends on some token functions) - -#include "CCtokens.h" - -#ifndef IS_CHARINSTR -#define IS_CHARINSTR(c, str) (std::string(str).find((char)(c)) != std::string::npos) -#endif - -// NOTE: this inital tx won't be used by other contract -// for tokens to be used there should be at least one 't' tx with other contract's custom opret -CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, vscript_t vopretNonfungible) -{ - return CScript(); -} - -CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector origpubkey, std::string name, std::string description, std::vector> oprets) -{ - return CScript(); -} - -CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::pair opretWithId) -{ - return CScript(); -} - -CScript EncodeTokenOpRet(uint256 tokenid, std::vector voutPubkeys, std::vector> oprets) -{ - return CScript(); -} - -// overload for fungible tokens (no additional data in opret): -uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description) { - return 0; -} - -uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector &origpubkey, std::string &name, std::string &description, std::vector> &oprets) -{ - return (uint8_t)0; -} - -// decode token opret: -// for 't' returns all data from opret, vopretExtra contains other contract's data (currently only assets'). -// for 'c' returns only funcid. NOTE: nonfungible data is not returned -uint8_t DecodeTokenOpRet(const CScript scriptPubKey, uint8_t &evalCodeTokens, uint256 &tokenid, std::vector &voutPubkeys, std::vector> &oprets) -{ - return (uint8_t)0; -} - - -// make three-eval (token+evalcode+evalcode2) 1of2 cryptocondition: -CC *MakeTokensCCcond1of2(uint8_t evalcode, uint8_t evalcode2, CPubKey pk1, CPubKey pk2) -{ - // make 1of2 sigs cond - std::vector pks; - pks.push_back(CCNewSecp256k1(pk1)); - pks.push_back(CCNewSecp256k1(pk2)); - - std::vector thresholds; - thresholds.push_back(CCNewEval(E_MARSHAL(ss << evalcode))); - if (evalcode != EVAL_TOKENS) // if evalCode == EVAL_TOKENS, it is actually MakeCCcond1of2()! - thresholds.push_back(CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS))); // this is eval token cc - if (evalcode2 != 0) - thresholds.push_back(CCNewEval(E_MARSHAL(ss << evalcode2))); // add optional additional evalcode - thresholds.push_back(CCNewThreshold(1, pks)); // this is 1 of 2 sigs cc - - return CCNewThreshold(thresholds.size(), thresholds); -} -// overload to make two-eval (token+evalcode) 1of2 cryptocondition: -CC *MakeTokensCCcond1of2(uint8_t evalcode, CPubKey pk1, CPubKey pk2) { - return MakeTokensCCcond1of2(evalcode, 0, pk1, pk2); -} - -// make three-eval (token+evalcode+evalcode2) cryptocondition: -CC *MakeTokensCCcond1(uint8_t evalcode, uint8_t evalcode2, CPubKey pk) -{ - std::vector pks; - pks.push_back(CCNewSecp256k1(pk)); - - std::vector thresholds; - thresholds.push_back(CCNewEval(E_MARSHAL(ss << evalcode))); - if (evalcode != EVAL_TOKENS) // if evalCode == EVAL_TOKENS, it is actually MakeCCcond1()! - thresholds.push_back(CCNewEval(E_MARSHAL(ss << (uint8_t)EVAL_TOKENS))); // this is eval token cc - if (evalcode2 != 0) - thresholds.push_back(CCNewEval(E_MARSHAL(ss << evalcode2))); // add optional additional evalcode - thresholds.push_back(CCNewThreshold(1, pks)); // signature - - return CCNewThreshold(thresholds.size(), thresholds); -} -// overload to make two-eval (token+evalcode) cryptocondition: -CC *MakeTokensCCcond1(uint8_t evalcode, CPubKey pk) { - return MakeTokensCCcond1(evalcode, 0, pk); -} - -// make three-eval (token+evalcode+evalcode2) 1of2 cc vout: -CTxOut MakeTokensCC1of2vout(uint8_t evalcode, uint8_t evalcode2, CAmount nValue, CPubKey pk1, CPubKey pk2) -{ - CTxOut vout; - return(vout); -} -// overload to make two-eval (token+evalcode) 1of2 cc vout: -CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2) { - return CTxOut(); -} - -// make three-eval (token+evalcode+evalcode2) cc vout: -CTxOut MakeTokensCC1vout(uint8_t evalcode, uint8_t evalcode2, CAmount nValue, CPubKey pk) -{ - return CTxOut(); -} -// overload to make two-eval (token+evalcode) cc vout: -CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk) { - return CTxOut(); -} - diff --git a/src/hush_nSPV_fullnode.h b/src/hush_nSPV_fullnode.h index d93deb686..1e3bac2f9 100644 --- a/src/hush_nSPV_fullnode.h +++ b/src/hush_nSPV_fullnode.h @@ -482,6 +482,7 @@ int32_t NSPV_mempoolfuncs(bits256 *satoshisp,int32_t *vindexp,std::vector vopret; char destaddr[64]; *vindexp = -1; memset(satoshisp,0,sizeof(*satoshisp)); + /* if ( funcid == NSPV_CC_TXIDS) { std::vector > tmp_txids; uint256 tmp_txid,hashBlock; @@ -533,14 +534,17 @@ int32_t NSPV_mempoolfuncs(bits256 *satoshisp,int32_t *vindexp,std::vector> 8) & 0xff; } + */ LOCK(mempool.cs); BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) { diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 701b12054..62c6b71d7 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1508,71 +1508,6 @@ UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp, const CPubKey& return result; } -UniValue decodeccopret(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - CTransaction tx; uint256 tokenid,txid,hashblock; - std::vector vopret,vOpretExtra; uint8_t *script,tokenevalcode; - UniValue result(UniValue::VOBJ),array(UniValue::VARR); std::vector pubkeys; - - if (fHelp || params.size() < 1 || params.size() > 1) - { - string msg = "decodeccopret scriptPubKey\n" - "\nReturns eval code and function id for CC OP RETURN data.\n" - - "\nArguments:\n" - "1. scriptPubKey (string, required) Hex of scriptPubKey with OP_RETURN data.\n" - - "\nResult:\n" - "{\n" - " eval_code, (string) Eval code name.\n" - " function, (char) Function id char.\n" - "}\n" - ; - throw runtime_error(msg); - } - std::vector hex(ParseHex(params[0].get_str())); - CScript scripthex(hex.begin(),hex.end()); - std::vector> oprets; - if (DecodeTokenOpRet(scripthex,tokenevalcode,tokenid,pubkeys, oprets)!=0 && tokenevalcode==EVAL_TOKENS && oprets.size()>0) - { - // seems we need a loop here - vOpretExtra = oprets[0].second; - UniValue obj(UniValue::VOBJ); - GetOpReturnData(scripthex,vopret); - script = (uint8_t *)vopret.data(); - if ( vopret.size() > 1) - { - char func[5]; - sprintf(func,"%c",script[1]); - obj.push_back(Pair("eval_code", EvalToStr(script[0]))); - obj.push_back(Pair("function", func)); - } - else - { - obj.push_back(Pair("error", "invalid or no CC opret data for Token OP_RETURN")); - } - array.push_back(obj); - if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); - } - else GetOpReturnData(scripthex,vopret); - script = (uint8_t *)vopret.data(); - if ( vopret.size() > 1) - { - char func[5]; UniValue obj(UniValue::VOBJ); - result.push_back(Pair("result", "success")); - sprintf(func,"%c",script[1]); - obj.push_back(Pair("eval_code", EvalToStr(script[0]))); - obj.push_back(Pair("function", func)); - array.push_back(obj); - result.push_back(Pair("OpRets",array)); - } - else - { - result.push_back(Pair("result", "error")); - result.push_back(Pair("error", "invalid or no CC opret data")); - } - return result; -} static const CRPCCommand commands[] = { // category name actor (function) okSafeMode diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 4cb86d676..f07f090b5 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -406,7 +406,6 @@ static const CRPCCommand vRPCCommands[] = { "util", "validateaddress", &validateaddress, true }, /* uses wallet if enabled */ { "util", "verifymessage", &verifymessage, true }, { "util", "txnotarizedconfirmed", &txnotarizedconfirmed, true }, - { "util", "decodeccopret", &decodeccopret, true }, { "util", "estimatefee", &estimatefee, true }, { "util", "estimatepriority", &estimatepriority, true }, { "util", "z_validateaddress", &z_validateaddress, true }, /* uses wallet if enabled */ diff --git a/src/rpc/server.h b/src/rpc/server.h index bbce095f5..96bf3d9dd 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -281,7 +281,6 @@ extern UniValue walletlock(const UniValue& params, bool fHelp, const CPubKey& my extern UniValue encryptwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue validateaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue decodeccopret(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue getdragonjson(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue getnotarysendmany(const UniValue& params, bool fHelp, const CPubKey& mypk);