Browse Source

Delete more CCs #381

duke
Duke 3 months ago
parent
commit
b41785a684
  1. 1
      src/Makefile.am
  2. 134
      src/cc/CCtokenutils.cpp
  3. 4
      src/hush_nSPV_fullnode.h
  4. 65
      src/rpc/misc.cpp
  5. 1
      src/rpc/server.cpp
  6. 1
      src/rpc/server.h

1
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)

134
src/cc/CCtokenutils.cpp

@ -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<uint8_t> origpubkey, std::string name, std::string description, vscript_t vopretNonfungible)
{
return CScript();
}
CScript EncodeTokenCreateOpRet(uint8_t funcid, std::vector<uint8_t> origpubkey, std::string name, std::string description, std::vector<std::pair<uint8_t, vscript_t>> oprets)
{
return CScript();
}
CScript EncodeTokenOpRet(uint256 tokenid, std::vector<CPubKey> voutPubkeys, std::pair<uint8_t, vscript_t> opretWithId)
{
return CScript();
}
CScript EncodeTokenOpRet(uint256 tokenid, std::vector<CPubKey> voutPubkeys, std::vector<std::pair<uint8_t, vscript_t>> oprets)
{
return CScript();
}
// overload for fungible tokens (no additional data in opret):
uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector<uint8_t> &origpubkey, std::string &name, std::string &description) {
return 0;
}
uint8_t DecodeTokenCreateOpRet(const CScript &scriptPubKey, std::vector<uint8_t> &origpubkey, std::string &name, std::string &description, std::vector<std::pair<uint8_t, vscript_t>> &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<CPubKey> &voutPubkeys, std::vector<std::pair<uint8_t, vscript_t>> &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<CC*> pks;
pks.push_back(CCNewSecp256k1(pk1));
pks.push_back(CCNewSecp256k1(pk2));
std::vector<CC*> 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<CC*> pks;
pks.push_back(CCNewSecp256k1(pk));
std::vector<CC*> 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();
}

4
src/hush_nSPV_fullnode.h

@ -482,6 +482,7 @@ int32_t NSPV_mempoolfuncs(bits256 *satoshisp,int32_t *vindexp,std::vector<uint25
int32_t num = 0,vini = 0,vouti = 0; uint8_t evalcode=0,func=0; std::vector<uint8_t> vopret; char destaddr[64];
*vindexp = -1;
memset(satoshisp,0,sizeof(*satoshisp));
/*
if ( funcid == NSPV_CC_TXIDS)
{
std::vector<std::pair<CAddressIndexKey, CAmount> > tmp_txids; uint256 tmp_txid,hashBlock;
@ -533,14 +534,17 @@ int32_t NSPV_mempoolfuncs(bits256 *satoshisp,int32_t *vindexp,std::vector<uint25
}
return (0);
}
*/
if ( mempool.size() == 0 )
return(0);
/*
if ( funcid == NSPV_MEMPOOL_CCEVALCODE )
{
isCC = true;
evalcode = vout & 0xff;
func = (vout >> 8) & 0xff;
}
*/
LOCK(mempool.cs);
BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx)
{

65
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<uint8_t> vopret,vOpretExtra; uint8_t *script,tokenevalcode;
UniValue result(UniValue::VOBJ),array(UniValue::VARR); std::vector<CPubKey> 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<unsigned char> hex(ParseHex(params[0].get_str()));
CScript scripthex(hex.begin(),hex.end());
std::vector<std::pair<uint8_t, vscript_t>> 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

1
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 */

1
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);

Loading…
Cancel
Save