From 171102cbbd4300ea3b0f1d8a21e50b012c7a6f59 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 18 Feb 2024 09:37:06 -0500 Subject: [PATCH 1/4] Remove unused Makefile #291 --- src/cc/Makefile | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 src/cc/Makefile diff --git a/src/cc/Makefile b/src/cc/Makefile deleted file mode 100644 index 54f290573..000000000 --- a/src/cc/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -SHELL = /bin/sh -CC = gcc -CC_DARWIN = g++-6 -CC_WIN = x86_64-w64-mingw32-gcc-posix -CFLAGS = -arch x86_64 -CXXFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I -I../leveldb/include -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -dynamiclib -CXXFLAGS = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I../leveldb/include -I.. -I. -fPIC -shared -c -CXXFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I../leveldb/include -I.. -I. -fPIC -shared -c -DEBUGFLAGS = -O0 -D _DEBUG -RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program -$(info $(OS)) -OS := $(shell uname -s) -$(info $(OS)) -TARGET = ../libcc.so -TARGET_DARWIN = ../libcc.dylib -TARGET_WIN = ../libcc.dll -SOURCES = cclib.cpp ../cJSON.c -OBJS = cclib.o ../cJSON.o - -all: $(TARGET) - -%.o: %.c - $(CC) -o $@ $< $(CFLAGS) $(DEBUGFLAGS) - -%.o: %.cpp - $(CC) -o $@ $< $(CXXFLAGS) $(DEBUGFLAGS) - -$(TARGET): $(OBJS) - $(info Building cclib to src/) -ifeq ($(OS),Darwin) - $(CC_DARWIN) $(CXXFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) $(OBJS) -else ifeq ($(OS),Linux) - $(CC) $(CXXFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(OBJS) -#else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host -else - $(info WINDOWS) - $(CC_WIN) $(CXXFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) $(OBJS) -endif - -clean: - rm -rf $(TARGET) From 7b3c26ddfeaf3dfff17eee123618473bc61a5480 Mon Sep 17 00:00:00 2001 From: Duke Date: Wed, 28 Feb 2024 12:43:43 -0500 Subject: [PATCH 2/4] Remove CC dingleberries --- src/cc/CCcustom.cpp | 5 --- src/cc/CCinclude.h | 65 --------------------------------- src/cc/CCutils.cpp | 2 - src/cc/cclib.cpp | 89 --------------------------------------------- src/cc/eval.cpp | 1 - 5 files changed, 162 deletions(-) diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 8a30feadf..a98851afc 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -19,11 +19,6 @@ #include "key_io.h" #include "CCinclude.h" -int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode) -{ - return(-1); -} - struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) { return(cp); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index fb9ac7c47..29cc60d6c 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -216,7 +216,6 @@ int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256 /// @private UniValue CClib(struct CCcontract_info *cp,char *method,char *jsonstr); -UniValue CClib_info(struct CCcontract_info *cp); static const uint256 zeroid; //!< null uint256 constant @@ -430,67 +429,6 @@ void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t * /// @see GetCCaddress1of2 void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2,uint8_t *priv,char *coinaddr); -/// Creates a token transaction output with a cryptocondition that allows to spend it by one key. -/// The resulting vout will have two eval codes (EVAL_TOKENS and evalcode parameter value). -/// The returned output should be added to a transaction vout array. -/// @param evalcode cryptocondition eval code (transactions with this eval code in cc inputs will be forwarded to the contract associated with this eval code) -/// @param nValue value of the output in satoshi -/// @param pk pubkey to spend the cc -/// @returns vout object -/// @see CCinit -/// @see CCcontract_info -CTxOut MakeTokensCC1vout(uint8_t evalcode, CAmount nValue, CPubKey pk); - -/// Another MakeTokensCC1vout overloaded function that creates a token transaction output with a cryptocondition with two eval codes that allows to spend it by one key. -/// Resulting vout will have three eval codes (EVAL_TOKENS, evalcode and evalcode2 parameter values). -/// The returned output should be added to a transaction vout array. -/// @param evalcode cryptocondition eval code (transactions with this eval code in cc inputs will be forwarded to the contract associated with this eval code) -/// @param evalcode2 yet another cryptocondition eval code (transactions with this eval code in cc inputs will be forwarded to the contract associated with this eval code) -/// @param nValue value of the output in satoshi -/// @param pk pubkey to spend the cc -/// @returns vout object -/// @see CCinit -/// @see CCcontract_info -CTxOut MakeTokensCC1vout(uint8_t evalcode, uint8_t evalcode2, CAmount nValue, CPubKey pk); - -/// MakeTokensCC1of2vout creates a token transaction output with a 1of2 cryptocondition that allows to spend it by either of two keys. -/// The resulting vout will have two eval codes (EVAL_TOKENS and evalcode parameter value). -/// The returned output should be added to a transaction vout array. -/// @param evalcode cryptocondition eval code (transactions with this eval code in cc inputs will be forwarded to the contract associated with this eval code) -/// @param nValue value of the output in satoshi -/// @param pk1 one of two pubkeys to spend the cc -/// @param pk2 second of two pubkeys to spend the cc -/// @returns vout object -/// @see CCinit -/// @see CCcontract_info -CTxOut MakeTokensCC1of2vout(uint8_t evalcode, CAmount nValue, CPubKey pk1, CPubKey pk2); - -/// Another overload of MakeTokensCC1of2vout creates a token transaction output with a 1of2 cryptocondition with two eval codes that allows to spend it by either of two keys. -/// The resulting vout will have three eval codes (EVAL_TOKENS, evalcode and evalcode2 parameter values). -/// The returned output should be added to a transaction vout array. -/// @param evalcode cryptocondition eval code (transactions with this eval code in cc inputs will be forwarded to the contract associated with this eval code) -/// @param evalcode2 yet another cryptocondition eval code (transactions with this eval code in cc inputs will be forwarded to the contract associated with this eval code) -/// @param nValue value of the output in satoshi -/// @param pk1 one of two pubkeys to spend the cc -/// @param pk2 second of two pubkeys to spend the cc -/// @returns vout object -/// @see CCinit -/// @see CCcontract_info -CTxOut MakeTokensCC1of2vout(uint8_t evalcode, uint8_t evalcode2, CAmount nValue, CPubKey pk1, CPubKey pk2); - -/// Gets adddress for token cryptocondition vout -/// @param cp CCcontract_info structure initialized with EVAL_TOKENS eval code -/// @param[out] destaddr retrieved address -/// @param pk public key to create the cryptocondition -bool GetTokensCCaddress(struct CCcontract_info *cp, char *destaddr, CPubKey pk); - -/// Gets adddress for token 1of2 cc vout -/// @param cp CCcontract_info structure initialized with EVAL_TOKENS eval code -/// @param[out] destaddr retrieved address -/// @param pk first public key to create the cryptocondition -/// @param pk2 second public key to create the cryptocondition -bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey pk, CPubKey pk2); - /// CCaddrTokens1of2set sets pubkeys, private key and cc addr for spending from 1of2 token cryptocondition vout /// @param cp contract info structure where the private key is set /// @param pk1 one of the two public keys of the 1of2 cc @@ -501,9 +439,6 @@ bool GetTokensCCaddress1of2(struct CCcontract_info *cp, char *destaddr, CPubKey /// @see CCcontract_info void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, uint8_t *priv, char *coinaddr); -/// @private -int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode); - /// IsCCInput checks if scriptSig object contains a cryptocondition /// @param scriptSig scriptSig object with a cryptocondition /// @returns true if the scriptSig object contains a cryptocondition diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index a96fe02de..e46793288 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -456,6 +456,4 @@ int64_t TotalPubkeyCCInputs(const CTransaction &tx, const CPubKey &pubkey) return total; } -extern struct CCcontract_info CCinfos[0x100]; extern std::string MYCCLIBNAME; -bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx,unsigned int nIn); diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 695ecc91f..cf0dfcfe2 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -40,70 +40,6 @@ extern std::string MYCCLIBNAME; char *CClib_name() { return((char *)MYCCLIBNAME.c_str()); } -struct CClib_rpcinfo -{ - char *CCname,*method,*help; - int32_t numrequiredargs,maxargs; - uint8_t funcid,evalcode; -} - -CClib_methods[] = -{ - { (char *)"faucet2", (char *)"fund", (char *)"amount", 1, 1, 'F', EVAL_FAUCET2 }, - { (char *)"faucet2", (char *)"get", (char *)"", 0, 0, 'G', EVAL_FAUCET2 }, -#ifdef BUILD_CUSTOMCC - RPC_FUNCS -#endif -}; - -std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); - -cJSON *cclib_reparse(int32_t *nump,char *jsonstr) // assumes origparams will be freed by caller -{ - cJSON *params; char *newstr; int32_t i,j; - *nump = 0; - if ( jsonstr != 0 ) - { - if ( jsonstr[0] == '"' && jsonstr[strlen(jsonstr)-1] == '"' ) - { - jsonstr[strlen(jsonstr)-1] = 0; - jsonstr++; - } - newstr = (char *)malloc(strlen(jsonstr)+1); - for (i=j=0; jsonstr[i]!=0; i++) - { - if ( jsonstr[i] == '%' && jsonstr[i+1] == '2' && jsonstr[i+2] == '2' ) - { - newstr[j++] = '"'; - i += 2; - } - else if ( jsonstr[i] == '\'' ) - newstr[j++] = '"'; - else newstr[j++] = jsonstr[i]; - } - newstr[j] = 0; - params = cJSON_Parse(newstr); - if ( 0 && params != 0 ) - printf("new.(%s) -> %s\n",newstr,jprint(params,0)); - free(newstr); - *nump = cJSON_GetArraySize(params); - //free(origparams); - } else params = 0; - return(params); -} - -UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) -{ - UniValue result(UniValue::VOBJ); - return(result); -} - -UniValue CClib_info(struct CCcontract_info *cp) -{ - UniValue result(UniValue::VOBJ); - return(result); -} - UniValue CClib(struct CCcontract_info *cp,char *method,char *jsonstr) { UniValue result(UniValue::VOBJ); @@ -120,11 +56,6 @@ bool CClibExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction return false; } -bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx,unsigned int nIn) -{ - return false; -} - int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,char *cmpaddr,int32_t CCflag) { return 0; @@ -135,21 +66,6 @@ int64_t AddCClibtxfee(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe return(0); } -std::string Faucet2Fund(struct CCcontract_info *cp,uint64_t txfee,int64_t funds) -{ - return(""); -} - -std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params) -{ - return(""); -} - -UniValue cclib_error(UniValue &result,const char *errorstr) -{ - return(result); -} - uint256 juint256(cJSON *obj) { uint256 tmp; bits256 t = jbits256(obj,0); @@ -157,11 +73,6 @@ uint256 juint256(cJSON *obj) return(revuint256(tmp)); } -int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len) -{ - return(0); -} - #if BUILD_CUSTOMCC #include "customcc.cpp" diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index 93e7d3927..4ee4547ff 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -30,7 +30,6 @@ char *CClib_name(); Eval* EVAL_TEST = 0; -struct CCcontract_info CCinfos[0x100]; extern pthread_mutex_t HUSH_CC_mutex; From 558f662a3356e971056305ed43756849d5f22a87 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 21 Mar 2024 11:17:58 -0400 Subject: [PATCH 3/4] Do not apply sapling network rules to block height 0 or 1 in ScanForWalletTransactions --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 37b31ec85..18e38cb0c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2790,7 +2790,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) // This should never fail: we should always be able to get the tree // state on the path to the tip of our chain if (pindex->pprev) { - const bool sapling = true; + const bool sapling = pindex->GetHeight() >= 2 ? true : false; if (sapling) { // NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { assert(pcoinsTip->GetSaplingAnchorAt(pindex->pprev->hashFinalSaplingRoot, saplingTree)); } From 975f22bfa0caecbf4f7519fec907168ba50e0d4a Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 21 Mar 2024 11:30:34 -0400 Subject: [PATCH 4/4] Improve error message in z_sendmany if tx is estimated to be too large The previous error message was incorrect, it could be too many inputs or a combination of too many inputs and outputs and also did not report the estimated size. --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 51273a754..ec99d7516 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5311,7 +5311,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) } txsize += CTXOUT_REGULAR_SIZE * taddrRecipients.size(); if (txsize > max_tx_size) { - throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Too many outputs, size of raw transaction would be larger than limit of %d bytes", max_tx_size )); + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Size of raw transaction %d would be larger than limit of %d bytes", txsize, max_tx_size )); } // Minimum confirmations