From b21eb999567115594f7e1f686c80fdea9eb9a16d Mon Sep 17 00:00:00 2001 From: Metaphilibert Date: Fri, 14 Jun 2019 03:12:01 +0200 Subject: [PATCH 001/171] Cosmetics for legacy view --- src/miner.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9976909fa..31345cdd7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1746,7 +1746,7 @@ void static BitcoinMiner() if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 || Mining_height > 1000000 ) { int32_t dispflag = 0; - if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) &¬aryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) + if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) || notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) dispflag = 1; komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->GetHeight()); if ( nonzpkeys > 0 ) @@ -1769,8 +1769,12 @@ void static BitcoinMiner() if ( dispflag != 0 ) { if ( mids[j] >= 0 ) - fprintf(stderr,"%d ",mids[j]); - else fprintf(stderr,"GPU "); + { + if ( mids[j] == notaryid ) + fprintf(stderr,"--<%d>-- ",mids[j]); + else + fprintf(stderr,"%d ",mids[j]); + } else fprintf(stderr,"GPU "); } if ( mids[j] == -1 ) gpucount++; From 95dcb9cd326a1754548a43b63f58aa7accc6a5b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 03:46:40 -1100 Subject: [PATCH 002/171] Initial CC support skeleton --- src/cc/CCinclude.h | 5 +- src/cc/CCtx.cpp | 8 +- src/komodo_nSPV.h | 129 ----------------------------- src/komodo_nSPV_defs.h | 156 ++++++++++++++++++++++++++++++++++++ src/komodo_nSPV_superlite.h | 1 - src/komodo_nSPV_wallet.h | 9 +++ src/main.cpp | 1 + 7 files changed, 172 insertions(+), 137 deletions(-) create mode 100644 src/komodo_nSPV_defs.h diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 4c6791676..c485ffb2d 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -52,6 +52,7 @@ one other technical note is that komodod has the insight-explorer extensions bui #include "../utlist.h" #include "../uthash.h" #include "merkleblock.h" +#include "../komodo_nSPV_defs.h" #define CC_BURNPUBKEY "02deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" #define CC_MAXVINS 1024 @@ -287,8 +288,8 @@ extern std::vector NULL_pubkeys; std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool CCflag = true); void SetCCtxids(std::vector > &addressIndex,char *coinaddr,bool CCflag = true); -int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); -int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs); +int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr = 0); +int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr = 0); int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag); bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey,uint32_t nTime); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 3931e19b4..e6da6a46b 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -518,13 +518,11 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * else return(belowi); } -int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs) +int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr) { - int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; + int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxosinfo *utxos,*up; if ( KOMODO_NSPV != 0 ) - { - //return(NSPV_addinputs(struct NSPV_utxoresp *used,CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_utxoresp *ptr,int32_t num)); - } + return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,ptr)); #ifdef ENABLE_WALLET assert(pwalletMain != NULL); const CKeyStore& keystore = *pwalletMain; diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index c8338d365..f0e59e8cb 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -28,33 +28,6 @@ #ifndef KOMODO_NSPV_H #define KOMODO_NSPV_H -#define NSPV_POLLITERS 15 -#define NSPV_POLLMICROS 100000 -#define NSPV_MAXVINS 64 -#define NSPV_AUTOLOGOUT 777 -#define NSPV_BRANCHID 0x76b809bb - -// nSPV defines and struct definitions with serialization and purge functions - -#define NSPV_INFO 0x00 -#define NSPV_INFORESP 0x01 -#define NSPV_UTXOS 0x02 -#define NSPV_UTXOSRESP 0x03 -#define NSPV_NTZS 0x04 -#define NSPV_NTZSRESP 0x05 -#define NSPV_NTZSPROOF 0x06 -#define NSPV_NTZSPROOFRESP 0x07 -#define NSPV_TXPROOF 0x08 -#define NSPV_TXPROOFRESP 0x09 -#define NSPV_SPENTINFO 0x0a -#define NSPV_SPENTINFORESP 0x0b -#define NSPV_BROADCAST 0x0c -#define NSPV_BROADCASTRESP 0x0d - -int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum); -extern uint256 SIG_TXHASH; -uint32_t NSPV_blocktime(int32_t hdrheight); - int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,uint16_t len,uint8_t *buf) { if ( rwflag != 0 ) @@ -63,18 +36,6 @@ int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,uint16_t len,uint8_t *bu return(len); } -struct NSPV_equihdr -{ - int32_t nVersion; - uint256 hashPrevBlock; - uint256 hashMerkleRoot; - uint256 hashFinalSaplingRoot; - uint32_t nTime; - uint32_t nBits; - uint256 nNonce; - uint8_t nSolution[1344]; -}; - int32_t NSPV_rwequihdr(int32_t rwflag,uint8_t *serialized,struct NSPV_equihdr *ptr) { int32_t len = 0; @@ -117,13 +78,6 @@ int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsizep, return(len); } -struct NSPV_utxoresp -{ - uint256 txid; - int64_t satoshis,extradata; - int32_t vout,height; -}; - int32_t NSPV_rwutxoresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxoresp *ptr) { int32_t len = 0; @@ -135,15 +89,6 @@ int32_t NSPV_rwutxoresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxoresp return(len); } -struct NSPV_utxosresp -{ - struct NSPV_utxoresp *utxos; - char coinaddr[64]; - int64_t total,interest; - int32_t nodeheight; - uint16_t numutxos; uint8_t CCflag,pad8; -}; - int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosresp *ptr) // check mempool { int32_t i,len = 0; @@ -173,22 +118,6 @@ int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosres return(len); } -void NSPV_utxosresp_purge(struct NSPV_utxosresp *ptr) -{ - if ( ptr != 0 ) - { - if ( ptr->utxos != 0 ) - free(ptr->utxos); - memset(ptr,0,sizeof(*ptr)); - } -} - -struct NSPV_ntz -{ - uint256 blockhash,txid,othertxid; - int32_t height,txidheight; -}; - int32_t NSPV_rwntz(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz *ptr) { int32_t len = 0; @@ -200,12 +129,6 @@ int32_t NSPV_rwntz(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz *ptr) return(len); } -struct NSPV_ntzsresp -{ - struct NSPV_ntz prevntz,nextntz; - int32_t reqheight; -}; - int32_t NSPV_rwntzsresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzsresp *ptr) { int32_t len = 0; @@ -226,14 +149,6 @@ void NSPV_ntzsresp_purge(struct NSPV_ntzsresp *ptr) memset(ptr,0,sizeof(*ptr)); } -struct NSPV_inforesp -{ - struct NSPV_ntz notarization; - uint256 blockhash; - int32_t height,hdrheight; - struct NSPV_equihdr H; -}; - int32_t NSPV_rwinforesp(int32_t rwflag,uint8_t *serialized,struct NSPV_inforesp *ptr) { int32_t len = 0; @@ -252,15 +167,6 @@ void NSPV_inforesp_purge(struct NSPV_inforesp *ptr) memset(ptr,0,sizeof(*ptr)); } -struct NSPV_txproof -{ - uint256 txid; - int64_t unspentvalue; - int32_t height,vout,pad; - uint16_t txlen,txprooflen; - uint8_t *tx,*txproof; -}; - int32_t NSPV_rwtxproof(int32_t rwflag,uint8_t *serialized,struct NSPV_txproof *ptr) { int32_t len = 0; @@ -301,13 +207,6 @@ void NSPV_txproof_purge(struct NSPV_txproof *ptr) } } -struct NSPV_ntzproofshared -{ - struct NSPV_equihdr *hdrs; - int32_t prevht,nextht,pad32; - uint16_t numhdrs,pad16; -}; - int32_t NSPV_rwntzproofshared(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzproofshared *ptr) { int32_t len = 0; @@ -320,15 +219,6 @@ int32_t NSPV_rwntzproofshared(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz return(len); } -struct NSPV_ntzsproofresp -{ - struct NSPV_ntzproofshared common; - uint256 prevtxid,nexttxid; - int32_t pad32,prevtxidht,nexttxidht; - uint16_t prevtxlen,nexttxlen; - uint8_t *prevntz,*nextntz; -}; - int32_t NSPV_rwntzsproofresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzsproofresp *ptr) { int32_t len = 0; @@ -377,19 +267,6 @@ void NSPV_ntzsproofresp_purge(struct NSPV_ntzsproofresp *ptr) } } -struct NSPV_MMRproof -{ - struct NSPV_ntzproofshared common; - // tbd -}; - -struct NSPV_spentinfo -{ - struct NSPV_txproof spent; - uint256 txid; - int32_t vout,spentvini; -}; - int32_t NSPV_rwspentinfo(int32_t rwflag,uint8_t *serialized,struct NSPV_spentinfo *ptr) // check mempool { int32_t len = 0; @@ -409,12 +286,6 @@ void NSPV_spentinfo_purge(struct NSPV_spentinfo *ptr) } } -struct NSPV_broadcastresp -{ - uint256 txid; - int32_t retcode; -}; - int32_t NSPV_rwbroadcastresp(int32_t rwflag,uint8_t *serialized,struct NSPV_broadcastresp *ptr) { int32_t len = 0; diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h new file mode 100644 index 000000000..d0c649ce5 --- /dev/null +++ b/src/komodo_nSPV_defs.h @@ -0,0 +1,156 @@ + +/****************************************************************************** + * 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. * + * * + ******************************************************************************/ + +// todo: + +// headers "sync" make sure it connects to prior blocks to notarization. use getinfo hdrht to get missing hdrs + +// interest calculations are currently just using what is returned, it should calculate it from scratch + +// CC signing +// make sure to sanity check all vector lengths on receipt +// make sure no files are updated (this is to allow nSPV=1 and later nSPV=0 without affecting database) +// bug: under load, fullnode was returning all 0 nServices + +#ifndef KOMODO_NSPV_DEFSH +#define KOMODO_NSPV_DEFSH + +#define NSPV_POLLITERS 15 +#define NSPV_POLLMICROS 100000 +#define NSPV_MAXVINS 64 +#define NSPV_AUTOLOGOUT 777 +#define NSPV_BRANCHID 0x76b809bb + +// nSPV defines and struct definitions with serialization and purge functions + +#define NSPV_INFO 0x00 +#define NSPV_INFORESP 0x01 +#define NSPV_UTXOS 0x02 +#define NSPV_UTXOSRESP 0x03 +#define NSPV_NTZS 0x04 +#define NSPV_NTZSRESP 0x05 +#define NSPV_NTZSPROOF 0x06 +#define NSPV_NTZSPROOFRESP 0x07 +#define NSPV_TXPROOF 0x08 +#define NSPV_TXPROOFRESP 0x09 +#define NSPV_SPENTINFO 0x0a +#define NSPV_SPENTINFORESP 0x0b +#define NSPV_BROADCAST 0x0c +#define NSPV_BROADCASTRESP 0x0d + +int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum); +extern uint256 SIG_TXHASH; +uint32_t NSPV_blocktime(int32_t hdrheight); + +struct NSPV_equihdr +{ + int32_t nVersion; + uint256 hashPrevBlock; + uint256 hashMerkleRoot; + uint256 hashFinalSaplingRoot; + uint32_t nTime; + uint32_t nBits; + uint256 nNonce; + uint8_t nSolution[1344]; +}; + +struct NSPV_utxoresp +{ + uint256 txid; + int64_t satoshis,extradata; + int32_t vout,height; +}; + +struct NSPV_utxosresp +{ + struct NSPV_utxoresp *utxos; + char coinaddr[64]; + int64_t total,interest; + int32_t nodeheight; + uint16_t numutxos; uint8_t CCflag,pad8; +}; + +struct NSPV_ntz +{ + uint256 blockhash,txid,othertxid; + int32_t height,txidheight; +}; + +struct NSPV_ntzsresp +{ + struct NSPV_ntz prevntz,nextntz; + int32_t reqheight; +}; + +struct NSPV_inforesp +{ + struct NSPV_ntz notarization; + uint256 blockhash; + int32_t height,hdrheight; + struct NSPV_equihdr H; +}; + +struct NSPV_txproof +{ + uint256 txid; + int64_t unspentvalue; + int32_t height,vout,pad; + uint16_t txlen,txprooflen; + uint8_t *tx,*txproof; +}; + +struct NSPV_ntzproofshared +{ + struct NSPV_equihdr *hdrs; + int32_t prevht,nextht,pad32; + uint16_t numhdrs,pad16; +}; + +struct NSPV_ntzsproofresp +{ + struct NSPV_ntzproofshared common; + uint256 prevtxid,nexttxid; + int32_t pad32,prevtxidht,nexttxidht; + uint16_t prevtxlen,nexttxlen; + uint8_t *prevntz,*nextntz; +}; + +struct NSPV_MMRproof +{ + struct NSPV_ntzproofshared common; + // tbd +}; + +struct NSPV_spentinfo +{ + struct NSPV_txproof spent; + uint256 txid; + int32_t vout,spentvini; +}; + +struct NSPV_broadcastresp +{ + uint256 txid; + int32_t retcode; +}; + +struct CC_utxosinfo +{ + struct NSPV_utxosresp U; + struct NSPV_utxoresp used[NSPV_MAXVINS]; +}; + +#endif // KOMODO_NSPV_DEFSH diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index b31115079..7c5039b78 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -686,5 +686,4 @@ UniValue NSPV_broadcast(char *hex) return(NSPV_broadcast_json(&B,txid)); } - #endif // KOMODO_NSPVSUPERLITE_H diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 300d5de22..dac7b9e49 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -406,4 +406,13 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a } } +int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr) +{ + if ( ptr != 0 ) + { + memset(ptr->used,0,sizeof(ptr->used)); + return(NSPV_addinputs(ptr->used,mtx,total,maxinputs,ptr->U.utxos,ptr->U.numutxos)); + } else return(0); +} + #endif // KOMODO_NSPVWALLET_H diff --git a/src/main.cpp b/src/main.cpp index a8ff33c2b..ab8b27ba5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7060,6 +7060,7 @@ void static ProcessGetData(CNode* pfrom) } } +#include "komodo_nSPV_defs.h" #include "komodo_nSPV.h" // shared defines, structs, serdes, purge functions #include "komodo_nSPV_fullnode.h" // nSPV fullnode handling of the getnSPV request messages #include "komodo_nSPV_superlite.h" // nSPV superlite client, issuing requests and handling nSPV responses From ee2ec523178b4541a7818e63dc1833980b93c1e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 03:50:45 -1100 Subject: [PATCH 003/171] Test --- src/cc/CCinclude.h | 1 + src/cc/CCtx.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index c485ffb2d..b51b71323 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -288,6 +288,7 @@ extern std::vector NULL_pubkeys; std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool CCflag = true); void SetCCtxids(std::vector > &addressIndex,char *coinaddr,bool CCflag = true); +int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr = 0); int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr = 0); int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index e6da6a46b..a8adab849 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -528,7 +528,7 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); - utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); + utxos = (struct CC_utxosinfo *)calloc(CC_MAXVINS,sizeof(*utxos)); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) From 2530a6b8920334824123493ac2120f54ae011ae1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 03:54:23 -1100 Subject: [PATCH 004/171] Test --- src/cc/CCinclude.h | 6 +++--- src/cc/CCtx.cpp | 2 +- src/komodo_nSPV_defs.h | 2 +- src/komodo_nSPV_wallet.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index b51b71323..ae5791358 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -288,9 +288,9 @@ extern std::vector NULL_pubkeys; std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool CCflag = true); void SetCCtxids(std::vector > &addressIndex,char *coinaddr,bool CCflag = true); -int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr); -int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr = 0); -int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr = 0); +int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCutxosinfo *ptr); +int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCutxosinfo *ptr = 0); +int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_CCutxosinfo *ptr = 0); int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag); bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey,uint32_t nTime); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index a8adab849..39f6e49ef 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -518,7 +518,7 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * else return(belowi); } -int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr) +int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCutxosinfo *ptr) { int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxosinfo *utxos,*up; if ( KOMODO_NSPV != 0 ) diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h index d0c649ce5..d0dca2543 100644 --- a/src/komodo_nSPV_defs.h +++ b/src/komodo_nSPV_defs.h @@ -147,7 +147,7 @@ struct NSPV_broadcastresp int32_t retcode; }; -struct CC_utxosinfo +struct NSPV_CCutxosinfo { struct NSPV_utxosresp U; struct NSPV_utxoresp used[NSPV_MAXVINS]; diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index dac7b9e49..892ed0991 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -406,7 +406,7 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a } } -int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCdata *ptr) +int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCutxosinfo *ptr) { if ( ptr != 0 ) { From bf173b7158b602a7af7ff171eb89283ff35f5138 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 03:58:57 -1100 Subject: [PATCH 005/171] NSPV_CCmtxinfo --- src/cc/CCinclude.h | 6 +++--- src/cc/CCtx.cpp | 2 +- src/komodo_nSPV_defs.h | 2 +- src/komodo_nSPV_wallet.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index ae5791358..4fb5bfbe5 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -288,9 +288,9 @@ extern std::vector NULL_pubkeys; std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool CCflag = true); void SetCCtxids(std::vector > &addressIndex,char *coinaddr,bool CCflag = true); -int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCutxosinfo *ptr); -int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCutxosinfo *ptr = 0); -int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_CCutxosinfo *ptr = 0); +int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr); +int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr = 0); +int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr = 0); int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag); bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey,uint32_t nTime); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 39f6e49ef..6c0f2e8d0 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -518,7 +518,7 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * else return(belowi); } -int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCutxosinfo *ptr) +int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr) { int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxosinfo *utxos,*up; if ( KOMODO_NSPV != 0 ) diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h index d0dca2543..c1ec60817 100644 --- a/src/komodo_nSPV_defs.h +++ b/src/komodo_nSPV_defs.h @@ -147,7 +147,7 @@ struct NSPV_broadcastresp int32_t retcode; }; -struct NSPV_CCutxosinfo +struct NSPV_CCmtxinfo { struct NSPV_utxosresp U; struct NSPV_utxoresp used[NSPV_MAXVINS]; diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 892ed0991..cb2e6ea79 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -406,7 +406,7 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a } } -int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCutxosinfo *ptr) +int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr) { if ( ptr != 0 ) { From 81dc3e8b836f2fe9b5ab7f085a3507b5c4063eac Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 04:02:04 -1100 Subject: [PATCH 006/171] CC_utxo --- src/cc/CCtx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 6c0f2e8d0..005a06380 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -520,7 +520,7 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr) { - int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxosinfo *utxos,*up; + int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; if ( KOMODO_NSPV != 0 ) return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,ptr)); #ifdef ENABLE_WALLET @@ -528,7 +528,7 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); - utxos = (struct CC_utxosinfo *)calloc(CC_MAXVINS,sizeof(*utxos)); + utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) From b444625676b857a6b9fe5dc7f5d5273f988b3390 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 04:20:03 -1100 Subject: [PATCH 007/171] Restore NSPV_utxosresp_purge --- src/komodo_nSPV.h | 14 ++++++++++++-- src/komodo_nSPV_defs.h | 11 ----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index f0e59e8cb..9c577512d 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -16,11 +16,11 @@ // todo: +// CC signing + // headers "sync" make sure it connects to prior blocks to notarization. use getinfo hdrht to get missing hdrs -// interest calculations are currently just using what is returned, it should calculate it from scratch -// CC signing // make sure to sanity check all vector lengths on receipt // make sure no files are updated (this is to allow nSPV=1 and later nSPV=0 without affecting database) // bug: under load, fullnode was returning all 0 nServices @@ -118,6 +118,16 @@ int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosres return(len); } +void NSPV_utxosresp_purge(struct NSPV_utxosresp *ptr) +{ + if ( ptr != 0 ) + { + if ( ptr->utxos != 0 ) + free(ptr->utxos); + memset(ptr,0,sizeof(*ptr)); + } +} + int32_t NSPV_rwntz(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz *ptr) { int32_t len = 0; diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h index c1ec60817..537a7209e 100644 --- a/src/komodo_nSPV_defs.h +++ b/src/komodo_nSPV_defs.h @@ -14,17 +14,6 @@ * * ******************************************************************************/ -// todo: - -// headers "sync" make sure it connects to prior blocks to notarization. use getinfo hdrht to get missing hdrs - -// interest calculations are currently just using what is returned, it should calculate it from scratch - -// CC signing -// make sure to sanity check all vector lengths on receipt -// make sure no files are updated (this is to allow nSPV=1 and later nSPV=0 without affecting database) -// bug: under load, fullnode was returning all 0 nServices - #ifndef KOMODO_NSPV_DEFSH #define KOMODO_NSPV_DEFSH From c3e7c38dfd1b4f8e19ae4ef9becd9fbc38fb4fd9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 04:39:18 -1100 Subject: [PATCH 008/171] ,struct NSPV_CCmtxinfo *ptr --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 005a06380..5a650a8c9 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -614,7 +614,7 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 return(0); } -int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs) +int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr) { int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; std::vector > unspentOutputs; From 9ea4e92c0cb23dab9023dff5069eb11941ac2606 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 04:39:42 -1100 Subject: [PATCH 009/171] Fix --- src/cc/CCtx.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 5a650a8c9..14cc5bc4a 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -619,9 +619,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; std::vector > unspentOutputs; if ( KOMODO_NSPV != 0 ) - { - //return(NSPV_addinputs(struct NSPV_utxoresp *used,CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_utxoresp *ptr,int32_t num)); - } + return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,ptr)); utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; From 99ba39fba136b268d0f98df8948015be2be11bcd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 04:42:44 -1100 Subject: [PATCH 010/171] Arg tweak --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 14cc5bc4a..cb9bf4a77 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -619,7 +619,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; std::vector > unspentOutputs; if ( KOMODO_NSPV != 0 ) - return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,ptr)); + return(NSPV_AddNormalinputs(mtx,pubkey2pk(Mypubkey()),total,maxinputs,ptr)); utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; From 07d19ec210c14910dcc3f2c2d0975e019045c7df Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 05:33:05 -1100 Subject: [PATCH 011/171] Add nSPV to myGetTransaction --- src/cc/CCtx.cpp | 13 ++++++++----- src/main.cpp | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index cb9bf4a77..2b02670ca 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -17,6 +17,7 @@ #include "key_io.h" std::vector NULL_pubkeys; +struct NSPV_CCmtxinfo NSPV_U; /* FinalizeCCTx is a very useful function that will properly sign both CC and normal inputs, adds normal change and the opreturn. @@ -96,8 +97,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. for (i=0; i Date: Wed, 10 Jul 2019 05:35:57 -1100 Subject: [PATCH 012/171] Syntax --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 1f000aa4c..f81b04bbc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2223,7 +2223,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo if ( KOMODO_NSPV != 0 ) { int64_t rewardsum = 0; - return(NSPV_gettransaction(1,0,txid,0,txOut,0,0,rewardsum) == 0); + return(NSPV_gettransaction(1,0,hash,0,txOut,0,0,rewardsum) == 0); } // need a GetTransaction without lock so the validation code for assets can run without deadlock { From 86d6ba3d8737b63c63fa6d7cdfe9926d480fcf3e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 06:21:04 -1100 Subject: [PATCH 013/171] Connect addressutxos to addnormalinputs --- src/cc/CCtx.cpp | 6 +++++- src/komodo_nSPV.h | 10 ++++++++++ src/komodo_nSPV_wallet.h | 8 ++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 2b02670ca..977c1e37a 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -525,7 +525,11 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 { int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; if ( KOMODO_NSPV != 0 ) - return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,ptr)); + { + if ( ptr != 0 ) + return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,ptr)); + else return(0); + } #ifdef ENABLE_WALLET assert(pwalletMain != NULL); const CKeyStore& keystore = *pwalletMain; diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index 9c577512d..2c8086cae 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -128,6 +128,16 @@ void NSPV_utxosresp_purge(struct NSPV_utxosresp *ptr) } } +void NSPV_utxosresp_copy(struct NSPV_utxosresp *dest,struct NSPV_utxosresp *ptr) +{ + *dest = *ptr; + if ( ptr->utxos != 0 ) + { + dest->utxos = (struct NSPV_utxoresp *)malloc(ptr->numutxos * sizeof(*ptr->utxos)); + memcpy(dest->utxos,ptr->utxos,ptr->numutxos * sizeof(*ptr->utxos)); + } +} + int32_t NSPV_rwntz(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz *ptr) { int32_t len = 0; diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index cb2e6ea79..08f2646d7 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -408,8 +408,16 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr) { + char coinaddr[64]; int32_t CCflag = 0; if ( ptr != 0 ) { + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); + if ( strcmp(ptr->U.coinaddr,coinaddr) != 0 ) + { + NSPV_addressutxos(coinaddr,CCflag); + NSPV_utxosresp_purge(&ptr->U); + NSPV_utxosresp_copy(&ptr->U,&NSPV_utxosresult); + } memset(ptr->used,0,sizeof(ptr->used)); return(NSPV_addinputs(ptr->used,mtx,total,maxinputs,ptr->U.utxos,ptr->U.numutxos)); } else return(0); From 4d3782db2483a20b5baa286755b802a0533171d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 06:26:26 -1100 Subject: [PATCH 014/171] Test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0821017ff..41fab362c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2387,7 +2387,7 @@ void komodo_args(char *argv0) if ( strcmp("ILN",ASSETCHAINS_SYMBOL) == 0 ) { // No CCs used on this chain yet. - CCDISABLEALL; + // CCDISABLEALL; } if ( strcmp("OUR",ASSETCHAINS_SYMBOL) == 0 ) { From 190b0d62d534b3910891ee2cd722675529a0b8ac Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 06:31:28 -1100 Subject: [PATCH 015/171] Test --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index ce59f7f67..fe038dc13 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7002,8 +7002,8 @@ UniValue faucetfund(const UniValue& params, bool fHelp) throw runtime_error("faucetfund amount\n"); if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); + //const CKeyStore& keystore = *pwalletMain; + //LOCK2(cs_main, pwalletMain->cs_wallet); funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; if (funds > 0) { hex = FaucetFund(0,(uint64_t) funds); From 2af10c9963d998ebfb03bfbd669eee9afb467bb9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 06:34:01 -1100 Subject: [PATCH 016/171] NSPV_U --- src/cc/faucet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index cf12fae69..efac2bc75 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -226,7 +226,7 @@ std::string FaucetFund(uint64_t txfee,int64_t funds) txfee = 10000; mypk = pubkey2pk(Mypubkey()); faucetpk = GetUnspendable(cp,0); - if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) + if ( AddNormalinputs(mtx,mypk,funds+txfee,64,&NSPV_U) > 0 ) { mtx.vout.push_back(MakeCC1vout(EVAL_FAUCET,funds,faucetpk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); From 5a967b10d4b639b9a7614ea1e1aed263bc25e561 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 06:35:24 -1100 Subject: [PATCH 017/171] Extern --- src/cc/CCinclude.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 4fb5bfbe5..203a9c868 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -152,6 +152,7 @@ struct oracleprice_info }; typedef std::vector vscript_t; +extern struct NSPV_CCmtxinfo NSPV_U; #ifdef ENABLE_WALLET extern CWallet* pwalletMain; From 5c3b9e7142eb6693d673400ce96b651a7ecdf782 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 06:38:53 -1100 Subject: [PATCH 018/171] Use global --- src/cc/CCinclude.h | 4 ++-- src/cc/CCtx.cpp | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 203a9c868..53a2d050f 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -290,8 +290,8 @@ std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTr void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool CCflag = true); void SetCCtxids(std::vector > &addressIndex,char *coinaddr,bool CCflag = true); int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr); -int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr = 0); -int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr = 0); +int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); +int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs); int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag); bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey,uint32_t nTime); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 977c1e37a..121271561 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -521,15 +521,11 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * else return(belowi); } -int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr) +int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs) { int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; if ( KOMODO_NSPV != 0 ) - { - if ( ptr != 0 ) - return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,ptr)); - else return(0); - } + return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,&NSPV_U)); #ifdef ENABLE_WALLET assert(pwalletMain != NULL); const CKeyStore& keystore = *pwalletMain; @@ -621,12 +617,12 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 return(0); } -int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr) +int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs) { int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; std::vector > unspentOutputs; if ( KOMODO_NSPV != 0 ) - return(NSPV_AddNormalinputs(mtx,pubkey2pk(Mypubkey()),total,maxinputs,ptr)); + return(NSPV_AddNormalinputs(mtx,pubkey2pk(Mypubkey()),total,maxinputs,&NPSV_U)); utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; From 2b0238c7d37960b26f69fb49471e54ecc822efad Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 06:45:06 -1100 Subject: [PATCH 019/171] Test --- src/komodo_nSPV_wallet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 08f2646d7..6a664e454 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -228,7 +228,7 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C { CTransaction txNewConst(mtx); SignatureData sigdata; CBasicKeyStore keystore; int64_t branchid = NSPV_BRANCHID; keystore.AddKey(NSPV_key); - if ( 0 ) + if ( 1 ) { int32_t i; for (i=0; i Date: Wed, 10 Jul 2019 07:11:55 -1100 Subject: [PATCH 020/171] NSPV --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 121271561..5e81c4b26 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -622,7 +622,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; std::vector > unspentOutputs; if ( KOMODO_NSPV != 0 ) - return(NSPV_AddNormalinputs(mtx,pubkey2pk(Mypubkey()),total,maxinputs,&NPSV_U)); + return(NSPV_AddNormalinputs(mtx,pubkey2pk(Mypubkey()),total,maxinputs,&NSPV_U)); utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; From 0c76dbf7ace84d42226052e7359174c45f44c9ed Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 07:31:07 -1100 Subject: [PATCH 021/171] -arg --- src/cc/faucet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index efac2bc75..cf12fae69 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -226,7 +226,7 @@ std::string FaucetFund(uint64_t txfee,int64_t funds) txfee = 10000; mypk = pubkey2pk(Mypubkey()); faucetpk = GetUnspendable(cp,0); - if ( AddNormalinputs(mtx,mypk,funds+txfee,64,&NSPV_U) > 0 ) + if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) { mtx.vout.push_back(MakeCC1vout(EVAL_FAUCET,funds,faucetpk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); From d304ce41cfc5599720f834efc99b3d558fecced5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 07:46:10 -1100 Subject: [PATCH 022/171] -prints --- src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f81b04bbc..8f0225f27 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2222,8 +2222,10 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo memset(&hashBlock,0,sizeof(hashBlock)); if ( KOMODO_NSPV != 0 ) { - int64_t rewardsum = 0; - return(NSPV_gettransaction(1,0,hash,0,txOut,0,0,rewardsum) == 0); + int64_t rewardsum = 0; int32_t retval,vout = 0; + retval = NSPV_gettransaction(1,vout,hash,0,txOut,0,0,rewardsum); + fprintf(stderr,"myGetTransaction retval.%d\n",retval); + return(retval == 0); } // need a GetTransaction without lock so the validation code for assets can run without deadlock { From a8863f6abdaa0667236ce2f1d070823080093289 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 07:50:43 -1100 Subject: [PATCH 023/171] Test --- src/komodo_nSPV_wallet.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 6a664e454..a5372358a 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -61,7 +61,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr) int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum) { struct NSPV_txproof *ptr; int32_t i,offset,retval = 0; int64_t rewards = 0; uint32_t nLockTime; std::vector proof; - if ( (ptr= NSPV_txproof_find(txid)) == 0 ) + if ( (ptr= NSPV_txproof_find(txid)) == 0 && ptr->txprooflen != 0 ) { NSPV_txproof(vout,txid,height); ptr = &NSPV_txproofresult; @@ -82,6 +82,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int fprintf(stderr,"extradata %.8f vs rewards %.8f\n",dstr(extradata),dstr(rewards)); rewardsum += rewards; } + fprintf(stderr,"txid.%s vs hash.%s\n",txid.GetHex().c_str(),hash.GetHex().c_str()); if ( skipvalidation == 0 ) { From b5b5e24b39d3d5766bec89c7046eb12d6b03d9ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 07:51:53 -1100 Subject: [PATCH 024/171] Tx --- src/komodo_nSPV_wallet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index a5372358a..3e766763a 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -82,7 +82,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int fprintf(stderr,"extradata %.8f vs rewards %.8f\n",dstr(extradata),dstr(rewards)); rewardsum += rewards; } - fprintf(stderr,"txid.%s vs hash.%s\n",txid.GetHex().c_str(),hash.GetHex().c_str()); + fprintf(stderr,"txid.%s vs hash.%s\n",txid.GetHex().c_str(),tx.GetHash().GetHex().c_str()); if ( skipvalidation == 0 ) { From 729a9ec2495dfcace7f6ef566e2dbf5ac1ce0290 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 07:54:51 -1100 Subject: [PATCH 025/171] Fix --- src/komodo_nSPV_wallet.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 3e766763a..7b8627c9a 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -61,7 +61,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr) int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum) { struct NSPV_txproof *ptr; int32_t i,offset,retval = 0; int64_t rewards = 0; uint32_t nLockTime; std::vector proof; - if ( (ptr= NSPV_txproof_find(txid)) == 0 && ptr->txprooflen != 0 ) + if ( (ptr= NSPV_txproof_find(txid)) == 0 || ptr->txprooflen != 0 ) { NSPV_txproof(vout,txid,height); ptr = &NSPV_txproofresult; @@ -73,8 +73,10 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int } else if ( NSPV_txextract(tx,ptr->tx,ptr->txlen) < 0 || ptr->txlen <= 0 ) retval = -2000; - else if ( skipvalidation == 0 && ptr->unspentvalue <= 0 ) + else if ( tx.GetHash() != txid ) retval = -2001; + else if ( skipvalidation == 0 && ptr->unspentvalue <= 0 ) + retval = -2002; else if ( ASSETCHAINS_SYMBOL[0] == 0 && extradata >= 0 && tiptime != 0 ) { rewards = komodo_interestnew(height,tx.vout[vout].nValue,tx.nLockTime,tiptime); @@ -118,7 +120,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int retval = -2003; } } - } else retval = -2002; + } else retval = -2005; } else retval = -2004; } return(retval); From 725c260572c6e7d90c5b369d02620e6386f0a1f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 07:57:39 -1100 Subject: [PATCH 026/171] Print --- src/komodo_nSPV_wallet.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 7b8627c9a..9b494164c 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -84,7 +84,9 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int fprintf(stderr,"extradata %.8f vs rewards %.8f\n",dstr(extradata),dstr(rewards)); rewardsum += rewards; } - fprintf(stderr,"txid.%s vs hash.%s\n",txid.GetHex().c_str(),tx.GetHash().GetHex().c_str()); + char coinaddr[64]; + Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); + fprintf(stderr,"%s txid.%s vs hash.%s\n",coinaddr,txid.GetHex().c_str(),tx.GetHash().GetHex().c_str()); if ( skipvalidation == 0 ) { From f7a0c7aee5201de3ba5869fe180682c4d954f64d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 08:03:17 -1100 Subject: [PATCH 027/171] +print --- src/cc/CCtx.cpp | 5 +++++ src/komodo_nSPV_wallet.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 5e81c4b26..e0270fd4f 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -158,6 +158,11 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { if ( KOMODO_NSPV == 0 ) { + { + char addr[64]; + Getscriptaddress(addr,vintx.vout[utxovout].scriptPubKey); + fprintf(stderr,"vout[%d] %.8f -> %s\n",utxovout,dstr(vintx.vout[utxovout].nValue),addr); + } if ( SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey) == 0 ) fprintf(stderr,"signing error for vini.%d of %llx\n",i,(long long)vinimask); } diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 9b494164c..e10e3be58 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -61,7 +61,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr) int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum) { struct NSPV_txproof *ptr; int32_t i,offset,retval = 0; int64_t rewards = 0; uint32_t nLockTime; std::vector proof; - if ( (ptr= NSPV_txproof_find(txid)) == 0 || ptr->txprooflen != 0 ) + if ( (ptr= NSPV_txproof_find(txid)) == 0 ) { NSPV_txproof(vout,txid,height); ptr = &NSPV_txproofresult; @@ -86,7 +86,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int } char coinaddr[64]; Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); - fprintf(stderr,"%s txid.%s vs hash.%s\n",coinaddr,txid.GetHex().c_str(),tx.GetHash().GetHex().c_str()); + //fprintf(stderr,"%s txid.%s vs hash.%s\n",coinaddr,txid.GetHex().c_str(),tx.GetHash().GetHex().c_str()); if ( skipvalidation == 0 ) { From ffcbd2407a26e7b4a6b821022fce43fa032d6690 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 08:05:57 -1100 Subject: [PATCH 028/171] Right place --- src/cc/CCtx.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index e0270fd4f..96b22adad 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -158,16 +158,16 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { if ( KOMODO_NSPV == 0 ) { - { - char addr[64]; - Getscriptaddress(addr,vintx.vout[utxovout].scriptPubKey); - fprintf(stderr,"vout[%d] %.8f -> %s\n",utxovout,dstr(vintx.vout[utxovout].nValue),addr); - } if ( SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey) == 0 ) fprintf(stderr,"signing error for vini.%d of %llx\n",i,(long long)vinimask); } else { + { + char addr[64]; + Getscriptaddress(addr,vintx.vout[utxovout].scriptPubKey); + fprintf(stderr,"vout[%d] %.8f -> %s\n",utxovout,dstr(vintx.vout[utxovout].nValue),addr); + } if ( NSPV_SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey,0) == 0 ) fprintf(stderr,"NSPV signing error for vini.%d of %llx\n",i,(long long)vinimask); } From 83b7596ebf5871e692f9ff7c73e2658a8c8412f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 08:11:42 -1100 Subject: [PATCH 029/171] Test --- src/cc/CCtx.cpp | 2 ++ src/komodo_nSPV_wallet.h | 7 ------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 96b22adad..d1e1217b0 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -165,6 +165,8 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { { char addr[64]; + Getscriptaddress(addr,vintx.vout[0].scriptPubKey); + fprintf(stderr,"vout[%d] %.8f -> %s\n",0,dstr(vintx.vout[0].nValue),addr); Getscriptaddress(addr,vintx.vout[utxovout].scriptPubKey); fprintf(stderr,"vout[%d] %.8f -> %s\n",utxovout,dstr(vintx.vout[utxovout].nValue),addr); } diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index e10e3be58..d38f52722 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -233,13 +233,6 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C { CTransaction txNewConst(mtx); SignatureData sigdata; CBasicKeyStore keystore; int64_t branchid = NSPV_BRANCHID; keystore.AddKey(NSPV_key); - if ( 1 ) - { - int32_t i; - for (i=0; i Date: Wed, 10 Jul 2019 21:11:49 -1100 Subject: [PATCH 030/171] Sapling for nSPV --- src/komodo_gateway.h | 3 ++- src/main.cpp | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5c60503bf..0093cd38a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -652,7 +652,8 @@ const char *banned_txids[] = //"01d8c839463bda2f2f6400ede4611357913684927a767422a8560ead1b22557c", //"6e4980a9e1bd669f4df04732dc6f11b7773b6de88d1abcf89a6b9007d72ef9ac", //"6cc1d0495170bc0e11fd3925297623562e529ea1336b66ea61f8a1159041aed2", - //"250875424cece9bcd98cb226b09da7671625633d6958589e3a462bad89ad87cc", // missed + //"250875424cece9bcd98cb226b09da7671625633d6958589e3a462bad89ad87cc", // missed + //"ea8659011de52f4dac42cda12326064b7b5013b8492f88e33159884ca299aa05", // missed }; int32_t komodo_checkvout(int32_t vout,int32_t k,int32_t indallvouts) diff --git a/src/main.cpp b/src/main.cpp index 8f0225f27..e7444bad3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8468,20 +8468,22 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para { CMutableTransaction mtx; - bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER); + bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER) || (KOMODO_NSPV != 0); if (isOverwintered) { mtx.fOverwintered = true; mtx.nExpiryHeight = nHeight + expiryDelta; - if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) { + if ( NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING) || (KOMODO_NSPV != 0) ) + { mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersion = SAPLING_TX_VERSION; - } else { + } + else + { mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; mtx.nVersion = OVERWINTER_TX_VERSION; - mtx.nExpiryHeight = std::min( - mtx.nExpiryHeight, - static_cast(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight - 1)); + mtx.nExpiryHeight = std::min(mtx.nExpiryHeight, + static_cast(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight -1)); } } return mtx; From 3ec201770581e1a1daa8d69b8e7bd8f58dd84197 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 21:17:19 -1100 Subject: [PATCH 031/171] No expiry --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e7444bad3..57f21a80b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2224,7 +2224,6 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo { int64_t rewardsum = 0; int32_t retval,vout = 0; retval = NSPV_gettransaction(1,vout,hash,0,txOut,0,0,rewardsum); - fprintf(stderr,"myGetTransaction retval.%d\n",retval); return(retval == 0); } // need a GetTransaction without lock so the validation code for assets can run without deadlock @@ -8471,7 +8470,8 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER) || (KOMODO_NSPV != 0); if (isOverwintered) { mtx.fOverwintered = true; - mtx.nExpiryHeight = nHeight + expiryDelta; + if ( KOMODO_NSPV == 0 ) + mtx.nExpiryHeight = nHeight + expiryDelta; if ( NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING) || (KOMODO_NSPV != 0) ) { From e351db5325b54b9d84b405a650660ec0ee357e14 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 21:25:27 -1100 Subject: [PATCH 032/171] Spend to scriptPubKey --- src/komodo_nSPV_wallet.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index d38f52722..ffb1c0311 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -299,7 +299,7 @@ std::string NSPV_signtx(int64_t &rewardsum,int64_t &interestsum,UniValue &retcod UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its all about! { - UniValue result(UniValue::VOBJ),retcodes(UniValue::VARR); uint8_t rmd160[128]; int64_t txfee = 10000; + UniValue result(UniValue::VOBJ),retcodes(UniValue::VARR); CScript scriptPubKey; uint8_t rmd160[128]; int64_t txfee = 10000; if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT ) { result.push_back(Pair("result","error")); @@ -315,10 +315,16 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a } else if ( bitcoin_base58decode(rmd160,destaddr) != 25 ) { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","invalid destaddr")); - return(result); + if ( is_hexstr(destaddr) > 0 ) + scriptPubKey = CScript() << ParseHex(destaddr); + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","invalid destaddr")); + return(result); + } } + else scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ParseHex(HexStr(data)) << OP_EQUALVERIFY << OP_CHECKSIG); if ( NSPV_inforesult.height == 0 ) { result.push_back(Pair("result","error")); @@ -359,7 +365,7 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a if ( NSPV_addinputs(used,mtx,satoshis+txfee,64,NSPV_utxosresult.utxos,NSPV_utxosresult.numutxos) > 0 ) { - mtx.vout.push_back(CTxOut(satoshis,CScript() << OP_DUP << OP_HASH160 << ParseHex(HexStr(data)) << OP_EQUALVERIFY << OP_CHECKSIG)); + mtx.vout.push_back(CTxOut(satoshis,scriptPubKey); if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT ) { result.push_back(Pair("result","error")); From 312ad7dc2455ef6f2eca958ab868162253c9b0b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 21:28:20 -1100 Subject: [PATCH 033/171] Rearrange --- src/komodo_nSPV_wallet.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index ffb1c0311..8f11c3b44 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -299,7 +299,7 @@ std::string NSPV_signtx(int64_t &rewardsum,int64_t &interestsum,UniValue &retcod UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its all about! { - UniValue result(UniValue::VOBJ),retcodes(UniValue::VARR); CScript scriptPubKey; uint8_t rmd160[128]; int64_t txfee = 10000; + UniValue result(UniValue::VOBJ),retcodes(UniValue::VARR); std::vector data; CScript scriptPubKey; uint8_t rmd160[128]; int64_t txfee = 10000; if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT ) { result.push_back(Pair("result","error")); @@ -315,7 +315,7 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a } else if ( bitcoin_base58decode(rmd160,destaddr) != 25 ) { - if ( is_hexstr(destaddr) > 0 ) + if ( is_hexstr(destaddr,0) > 0 ) scriptPubKey = CScript() << ParseHex(destaddr); else { @@ -324,7 +324,12 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a return(result); } } - else scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ParseHex(HexStr(data)) << OP_EQUALVERIFY << OP_CHECKSIG); + else + { + data.resize(20); + memcpy(&data[0],&rmd160[1],20); + scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ParseHex(HexStr(data)) << OP_EQUALVERIFY << OP_CHECKSIG); + } if ( NSPV_inforesult.height == 0 ) { result.push_back(Pair("result","error")); @@ -352,7 +357,7 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a return(result); } printf("%s numutxos.%d balance %.8f\n",NSPV_utxosresult.coinaddr,NSPV_utxosresult.numutxos,(double)NSPV_utxosresult.total/COIN); - std::vector data; CScript opret; std::string hex; struct NSPV_utxoresp used[NSPV_MAXVINS]; CMutableTransaction mtx; CTransaction tx; int64_t rewardsum=0,interestsum=0; + CScript opret; std::string hex; struct NSPV_utxoresp used[NSPV_MAXVINS]; CMutableTransaction mtx; CTransaction tx; int64_t rewardsum=0,interestsum=0; mtx.fOverwintered = true; mtx.nExpiryHeight = 0; mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; @@ -360,8 +365,6 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a if ( ASSETCHAINS_SYMBOL[0] == 0 ) mtx.nLockTime = (uint32_t)time(NULL) - 777; memset(used,0,sizeof(used)); - data.resize(20); - memcpy(&data[0],&rmd160[1],20); if ( NSPV_addinputs(used,mtx,satoshis+txfee,64,NSPV_utxosresult.utxos,NSPV_utxosresult.numutxos) > 0 ) { From 1983e7036888c23ce1e108d00c61517361a570fa Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 21:29:51 -1100 Subject: [PATCH 034/171] +( --- src/komodo_nSPV_wallet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 8f11c3b44..e625a21d8 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -328,7 +328,7 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a { data.resize(20); memcpy(&data[0],&rmd160[1],20); - scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ParseHex(HexStr(data)) << OP_EQUALVERIFY << OP_CHECKSIG); + scriptPubKey = (CScript() << OP_DUP << OP_HASH160 << ParseHex(HexStr(data)) << OP_EQUALVERIFY << OP_CHECKSIG); } if ( NSPV_inforesult.height == 0 ) { From cdac9257956a2bacdd335008e6fdfe510b0c7be5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 21:30:48 -1100 Subject: [PATCH 035/171] +) --- src/komodo_nSPV_wallet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index e625a21d8..f2e645bd7 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -368,7 +368,7 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a if ( NSPV_addinputs(used,mtx,satoshis+txfee,64,NSPV_utxosresult.utxos,NSPV_utxosresult.numutxos) > 0 ) { - mtx.vout.push_back(CTxOut(satoshis,scriptPubKey); + mtx.vout.push_back(CTxOut(satoshis,scriptPubKey)); if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT ) { result.push_back(Pair("result","error")); From 40f2cf29c472301ec51c082f2eb0e7f44acb7996 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 21:42:51 -1100 Subject: [PATCH 036/171] Test --- src/komodo_nSPV_superlite.h | 1 + src/komodo_nSPV_wallet.h | 10 +++++----- src/main.cpp | 18 ++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index 7c5039b78..d51d0a0ff 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -431,6 +431,7 @@ UniValue NSPV_broadcast_json(struct NSPV_broadcastresp *ptr,uint256 txid) UniValue NSPV_login(char *wifstr) { UniValue result(UniValue::VOBJ); char coinaddr[64]; uint8_t data[128]; int32_t len,valid = 0; + NSPV_logout(); len = bitcoin_base58decode(data,wifstr); if ( strlen(wifstr) < 64 && (len == 38 && data[len-5] == 1) || (len == 37 && data[len-5] != 1) ) valid = 1; diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index f2e645bd7..509886697 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -238,10 +238,14 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C fprintf(stderr,"use legacy sig validation\n"); branchid = 0; } + mtx.fOverwintered = true; + mtx.nExpiryHeight = 0; + mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; + mtx.nVersion = branchid; if ( ProduceSignature(TransactionSignatureCreator(&keystore,&txNewConst,vini,utxovalue,SIGHASH_ALL),scriptPubKey,sigdata,branchid) != 0 ) { UpdateTransaction(mtx,vini,sigdata); - // fprintf(stderr,"SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN); + fprintf(stderr,"SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN); return(true); } else fprintf(stderr,"sigerr SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN); return(false); @@ -358,10 +362,6 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a } printf("%s numutxos.%d balance %.8f\n",NSPV_utxosresult.coinaddr,NSPV_utxosresult.numutxos,(double)NSPV_utxosresult.total/COIN); CScript opret; std::string hex; struct NSPV_utxoresp used[NSPV_MAXVINS]; CMutableTransaction mtx; CTransaction tx; int64_t rewardsum=0,interestsum=0; - mtx.fOverwintered = true; - mtx.nExpiryHeight = 0; - mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; - mtx.nVersion = SAPLING_TX_VERSION; if ( ASSETCHAINS_SYMBOL[0] == 0 ) mtx.nLockTime = (uint32_t)time(NULL) - 777; memset(used,0,sizeof(used)); diff --git a/src/main.cpp b/src/main.cpp index 57f21a80b..8f0225f27 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2224,6 +2224,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo { int64_t rewardsum = 0; int32_t retval,vout = 0; retval = NSPV_gettransaction(1,vout,hash,0,txOut,0,0,rewardsum); + fprintf(stderr,"myGetTransaction retval.%d\n",retval); return(retval == 0); } // need a GetTransaction without lock so the validation code for assets can run without deadlock @@ -8467,23 +8468,20 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para { CMutableTransaction mtx; - bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER) || (KOMODO_NSPV != 0); + bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER); if (isOverwintered) { mtx.fOverwintered = true; - if ( KOMODO_NSPV == 0 ) - mtx.nExpiryHeight = nHeight + expiryDelta; + mtx.nExpiryHeight = nHeight + expiryDelta; - if ( NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING) || (KOMODO_NSPV != 0) ) - { + if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) { mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersion = SAPLING_TX_VERSION; - } - else - { + } else { mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; mtx.nVersion = OVERWINTER_TX_VERSION; - mtx.nExpiryHeight = std::min(mtx.nExpiryHeight, - static_cast(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight -1)); + mtx.nExpiryHeight = std::min( + mtx.nExpiryHeight, + static_cast(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight - 1)); } } return mtx; From 97bea40b398f245221b67c9eb504ce590a078776 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 21:45:22 -1100 Subject: [PATCH 037/171] Revert --- src/komodo_nSPV_wallet.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 509886697..c2c65111f 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -238,10 +238,6 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C fprintf(stderr,"use legacy sig validation\n"); branchid = 0; } - mtx.fOverwintered = true; - mtx.nExpiryHeight = 0; - mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; - mtx.nVersion = branchid; if ( ProduceSignature(TransactionSignatureCreator(&keystore,&txNewConst,vini,utxovalue,SIGHASH_ALL),scriptPubKey,sigdata,branchid) != 0 ) { UpdateTransaction(mtx,vini,sigdata); @@ -362,6 +358,10 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a } printf("%s numutxos.%d balance %.8f\n",NSPV_utxosresult.coinaddr,NSPV_utxosresult.numutxos,(double)NSPV_utxosresult.total/COIN); CScript opret; std::string hex; struct NSPV_utxoresp used[NSPV_MAXVINS]; CMutableTransaction mtx; CTransaction tx; int64_t rewardsum=0,interestsum=0; + mtx.fOverwintered = true; + mtx.nExpiryHeight = 0; + mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; + mtx.nVersion = SAPLING_TX_VERSION; if ( ASSETCHAINS_SYMBOL[0] == 0 ) mtx.nLockTime = (uint32_t)time(NULL) - 777; memset(used,0,sizeof(used)); From 3a50d1a9b9a81b1e1914bf3bd5aa60967fa5fc48 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 21:48:19 -1100 Subject: [PATCH 038/171] mtx init --- src/komodo_nSPV_wallet.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index c2c65111f..cfd450f14 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -418,6 +418,10 @@ int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total char coinaddr[64]; int32_t CCflag = 0; if ( ptr != 0 ) { + mtx.fOverwintered = true; + mtx.nExpiryHeight = 0; + mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; + mtx.nVersion = SAPLING_TX_VERSION; Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); if ( strcmp(ptr->U.coinaddr,coinaddr) != 0 ) { From 1fd0425265d3136253d5a01d4c9a4288732525d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 21:56:28 -1100 Subject: [PATCH 039/171] Raw script --- src/komodo_nSPV_wallet.h | 11 ++++++++--- src/main.cpp | 1 - 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index cfd450f14..fc7a293fd 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -299,7 +299,7 @@ std::string NSPV_signtx(int64_t &rewardsum,int64_t &interestsum,UniValue &retcod UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its all about! { - UniValue result(UniValue::VOBJ),retcodes(UniValue::VARR); std::vector data; CScript scriptPubKey; uint8_t rmd160[128]; int64_t txfee = 10000; + UniValue result(UniValue::VOBJ),retcodes(UniValue::VARR); CScript scriptPubKey; uint8_t *data,rmd160[128]; int32_t len; int64_t txfee = 10000; if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT ) { result.push_back(Pair("result","error")); @@ -315,8 +315,13 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a } else if ( bitcoin_base58decode(rmd160,destaddr) != 25 ) { - if ( is_hexstr(destaddr,0) > 0 ) - scriptPubKey = CScript() << ParseHex(destaddr); + if ( (len= is_hexstr(destaddr,0)) > 0 ) + { + len >>= 1; + scriptPubKey.resize(len); + data = (uint8_t *)scriptPubKey.begin(); + decode_hex(data,len,destaddr); + } else { result.push_back(Pair("result","error")); diff --git a/src/main.cpp b/src/main.cpp index 8f0225f27..d2b16b2a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2224,7 +2224,6 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo { int64_t rewardsum = 0; int32_t retval,vout = 0; retval = NSPV_gettransaction(1,vout,hash,0,txOut,0,0,rewardsum); - fprintf(stderr,"myGetTransaction retval.%d\n",retval); return(retval == 0); } // need a GetTransaction without lock so the validation code for assets can run without deadlock From 97ca6a1a51388fbcab0b6630810ec7eba3d545ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 22:01:00 -1100 Subject: [PATCH 040/171] Test --- src/komodo_nSPV_wallet.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index fc7a293fd..3b1b88180 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -299,7 +299,7 @@ std::string NSPV_signtx(int64_t &rewardsum,int64_t &interestsum,UniValue &retcod UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its all about! { - UniValue result(UniValue::VOBJ),retcodes(UniValue::VARR); CScript scriptPubKey; uint8_t *data,rmd160[128]; int32_t len; int64_t txfee = 10000; + UniValue result(UniValue::VOBJ),retcodes(UniValue::VARR); std::vector data; CScript scriptPubKey; uint8_t *ptr,rmd160[128]; int32_t len; int64_t txfee = 10000; if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT ) { result.push_back(Pair("result","error")); @@ -318,9 +318,9 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a if ( (len= is_hexstr(destaddr,0)) > 0 ) { len >>= 1; - scriptPubKey.resize(len); - data = (uint8_t *)scriptPubKey.begin(); - decode_hex(data,len,destaddr); + data.resize(len); + decode_hex(&data[0],len,destaddr); + scriptPubKey = CScript() << data << OP_CHECKCRYPTOCONDITION; } else { From ffd97afa0f5183e1f53b70a931b7f11f2ebd76fe Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 22:06:21 -1100 Subject: [PATCH 041/171] Test --- src/main.cpp | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d2b16b2a6..79822f93c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8466,21 +8466,31 @@ extern "C" const char* getDataDir() CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight) { CMutableTransaction mtx; - - bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER); - if (isOverwintered) { + if ( KOMODO_NSPV != 0 ) + { mtx.fOverwintered = true; - mtx.nExpiryHeight = nHeight + expiryDelta; - - if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) { - mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; - mtx.nVersion = SAPLING_TX_VERSION; - } else { - mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; - mtx.nVersion = OVERWINTER_TX_VERSION; - mtx.nExpiryHeight = std::min( - mtx.nExpiryHeight, - static_cast(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight - 1)); + mtx.nExpiryHeight = 0; + mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; + mtx.nVersion = SAPLING_TX_VERSION; + } + else + { + bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER); + if (isOverwintered) + { + mtx.fOverwintered = true; + mtx.nExpiryHeight = nHeight + expiryDelta; + if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) + { + mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; + mtx.nVersion = SAPLING_TX_VERSION; + } + else + { + mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; + mtx.nVersion = OVERWINTER_TX_VERSION; + mtx.nExpiryHeight = std::min(mtx.nExpiryHeight,static_cast(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight - 1)); + } } } return mtx; From 39993614d0bfea3943972648afd79815a9c91b36 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 22:12:49 -1100 Subject: [PATCH 042/171] +prints --- src/script/sign.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index d0ae52b3a..784f2b8b8 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -51,8 +51,10 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, if (pprivKey) key = *pprivKey; else if (!keystore || !keystore->GetKey(address, key)) + { + fprintf(stderr,"keystore error\n"); return false; - + } if (scriptCode.IsPayToCryptoCondition()) { CC *cc = (CC *)extraData; @@ -67,7 +69,10 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, if ( ASSETCHAINS_TXPOW == 0 ) { if (!key.Sign(hash, vchSig)) + { + fprintf(stderr,"key.Sign error\n"); return false; + } } else { From 14f86959b453c9aef27a0cb497edbd8101067717 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 22:19:06 -1100 Subject: [PATCH 043/171] Test --- src/komodo_nSPV_wallet.h | 4 ++-- src/script/sign.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 3b1b88180..2406ee5e3 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -241,9 +241,9 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C if ( ProduceSignature(TransactionSignatureCreator(&keystore,&txNewConst,vini,utxovalue,SIGHASH_ALL),scriptPubKey,sigdata,branchid) != 0 ) { UpdateTransaction(mtx,vini,sigdata); - fprintf(stderr,"SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN); + //fprintf(stderr,"SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN); return(true); - } else fprintf(stderr,"sigerr SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN); + } //else fprintf(stderr,"sigerr SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN); return(false); } diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 784f2b8b8..232953432 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -52,7 +52,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, key = *pprivKey; else if (!keystore || !keystore->GetKey(address, key)) { - fprintf(stderr,"keystore error\n"); + fprintf(stderr,"size.%d keystore.%p error\n",(int32_t)keystore.size(),keystore); return false; } if (scriptCode.IsPayToCryptoCondition()) From 3bab8916c2fd5438ae6b375f84f3656e8fb45a66 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 22:23:22 -1100 Subject: [PATCH 044/171] Use global NSPV_key --- src/script/sign.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 232953432..e92634526 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -35,6 +35,8 @@ using namespace std; typedef vector valtype; extern uint8_t ASSETCHAINS_TXPOW; +extern CKey NSPV_key; +extern int32_t KOMODO_NSPV; uint256 SIG_TXHASH; TransactionSignatureCreator::TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn) {} @@ -48,11 +50,13 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, return false; } SIG_TXHASH = hash; - if (pprivKey) + if ( KOMODO_NSPV != 0 ) + key = NSPV_key; + else if (pprivKey) key = *pprivKey; else if (!keystore || !keystore->GetKey(address, key)) { - fprintf(stderr,"size.%d keystore.%p error\n",(int32_t)keystore.size(),keystore); + fprintf(stderr,"size.%d keystore.%p error\n",(int32_t)keystore->size(),keystore); return false; } if (scriptCode.IsPayToCryptoCondition()) From 2f62d0eec39e20a535f0be907a7ad4fe47b06f89 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 22:24:25 -1100 Subject: [PATCH 045/171] -size --- src/script/sign.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index e92634526..aba91f953 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -56,7 +56,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, key = *pprivKey; else if (!keystore || !keystore->GetKey(address, key)) { - fprintf(stderr,"size.%d keystore.%p error\n",(int32_t)keystore->size(),keystore); + fprintf(stderr,"keystore.%p error\n",keystore); return false; } if (scriptCode.IsPayToCryptoCondition()) From 18a58c1c946ca7d8d908796952e4e54fc2b4e9aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 22:25:41 -1100 Subject: [PATCH 046/171] Declare --- src/komodo-tx.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo-tx.cpp b/src/komodo-tx.cpp index 67ac68cd4..04baecd39 100644 --- a/src/komodo-tx.cpp +++ b/src/komodo-tx.cpp @@ -47,6 +47,7 @@ using namespace std; #include "komodo_interest.h" +CKey NSPV_key; uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight) { return(0); From 32df8381f68d8a84394de16fc320d96340086755 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 22:35:28 -1100 Subject: [PATCH 047/171] +prints --- src/script/sign.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index aba91f953..df6d0422e 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -47,7 +47,10 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, try { hash = SignatureHash(scriptCode, *txTo, nIn, nHashType, amount, consensusBranchId); } catch (logic_error ex) { + { + fprintf(stderr,"logic error\n"); return false; + } } SIG_TXHASH = hash; if ( KOMODO_NSPV != 0 ) @@ -64,7 +67,10 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, CC *cc = (CC *)extraData; // assume either 1of1 or 1of2. if the condition created by the if (!cc || cc_signTreeSecp256k1Msg32(cc, key.begin(), hash.begin()) == 0) + { + fprintf(stderr,"CC tree error\n"); return false; + } vchSig = CCSigVec(cc); return true; } From a9997c32bc4638713f15148e418217f1e760e824 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 22:49:04 -1100 Subject: [PATCH 048/171] Test --- src/cc/CCtx.cpp | 2 -- src/komodo_nSPV_superlite.h | 22 +++++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index d1e1217b0..96b22adad 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -165,8 +165,6 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { { char addr[64]; - Getscriptaddress(addr,vintx.vout[0].scriptPubKey); - fprintf(stderr,"vout[%d] %.8f -> %s\n",0,dstr(vintx.vout[0].nValue),addr); Getscriptaddress(addr,vintx.vout[utxovout].scriptPubKey); fprintf(stderr,"vout[%d] %.8f -> %s\n",utxovout,dstr(vintx.vout[utxovout].nValue),addr); } diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index d51d0a0ff..188d64c29 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -66,16 +66,32 @@ struct NSPV_ntzsresp *NSPV_ntzsresp_add(struct NSPV_ntzsresp *ptr) struct NSPV_txproof *NSPV_txproof_find(uint256 txid) { - int32_t i; + int32_t i; struct NSPV_txproof *backup = 0; for (i=0; itxprooflen != 0 ) + { + NSPV_txproof_purge(&NSPV_txproof_cache[i]); + NSPV_txproof_copy(&NSPV_txproof_cache[i],ptr); + return; + } + else if ( NSPV_txproof_cache[i].txprooflen != 0 || ptr->txprooflen == 0 ) + return; + } for (i=0; i Date: Wed, 10 Jul 2019 22:50:39 -1100 Subject: [PATCH 049/171] Fix --- src/komodo_nSPV_superlite.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index 188d64c29..3215abab3 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -81,16 +81,16 @@ struct NSPV_txproof *NSPV_txproof_add(struct NSPV_txproof *ptr) { int32_t i; for (i=0; itxid ) { if ( NSPV_txproof_cache[i].txprooflen == 0 && ptr->txprooflen != 0 ) { NSPV_txproof_purge(&NSPV_txproof_cache[i]); NSPV_txproof_copy(&NSPV_txproof_cache[i],ptr); - return; + return(&NSPV_txproof_cache[i]); } else if ( NSPV_txproof_cache[i].txprooflen != 0 || ptr->txprooflen == 0 ) - return; + return(&NSPV_txproof_cache[i]); } for (i=0; i Date: Wed, 10 Jul 2019 22:53:58 -1100 Subject: [PATCH 050/171] +print --- src/script/sign.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index df6d0422e..8aaa4b191 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -83,6 +83,10 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, fprintf(stderr,"key.Sign error\n"); return false; } + else + { + fprintf(stderr,"signed success %s\n",HexStr(vchSig)); + } } else { From cf5d65336510993c795946888e2b6a1bb4f85758 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 22:54:50 -1100 Subject: [PATCH 051/171] Cast --- src/script/sign.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 8aaa4b191..2ea5bd78f 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -85,7 +85,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, } else { - fprintf(stderr,"signed success %s\n",HexStr(vchSig)); + fprintf(stderr,"signed success %s\n",(char *)HexStr(vchSig).c_str()); } } else From a6c16efaa26780848f724eac575bfe2e94b3eded Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 10 Jul 2019 23:53:09 -1100 Subject: [PATCH 052/171] +print --- src/script/sign.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 2ea5bd78f..6516c7176 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -104,7 +104,10 @@ static bool Sign1(const CKeyID& address, const BaseSignatureCreator& creator, co { vector vchSig; if (!creator.CreateSig(vchSig, address, scriptCode, consensusBranchId)) + { + fprintf(stderr,"Sign1 creatsig error\n"); return false; + } ret.push_back(vchSig); return true; } From f6f3fc8606daa33c70f7da575e399b89bfc558d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 00:06:06 -1100 Subject: [PATCH 053/171] Rpcwallet bypass --- src/cc/faucet.cpp | 1 + src/wallet/rpcwallet.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index cf12fae69..25eb5271d 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -221,6 +221,7 @@ std::string FaucetFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk,faucetpk; CScript opret; struct CCcontract_info *cp,C; + cp = CCinit(&C,EVAL_FAUCET); if ( txfee == 0 ) txfee = 10000; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fe038dc13..76924be44 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7000,11 +7000,19 @@ UniValue faucetfund(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t funds; std::string hex; if ( fHelp || params.size() > 1 ) throw runtime_error("faucetfund amount\n"); + funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; + if ( KOMODO_NSPV != 0 ) + { + char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v; + cp = CCinit(&C,EVAL_FAUCET); + v = MakeCC1vout(EVAL_FAUCET,funds,GetUnspendable(cp,0)); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkey2pk(Mypubkey()))) << OP_CHECKSIG); + return(NSPV_spend(srcaddr,HexStr(v.scriptPubKey.begin(),v.scriptPubKey.end()),funds)); + } if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - //const CKeyStore& keystore = *pwalletMain; - //LOCK2(cs_main, pwalletMain->cs_wallet); - funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); if (funds > 0) { hex = FaucetFund(0,(uint64_t) funds); if ( hex.size() > 0 ) From c3f1008f80c3fa00ce1b366b3345c370e9abee34 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 00:08:58 -1100 Subject: [PATCH 054/171] Syntax --- src/komodo_nSPV_defs.h | 1 + src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h index 537a7209e..c72fb2aeb 100644 --- a/src/komodo_nSPV_defs.h +++ b/src/komodo_nSPV_defs.h @@ -41,6 +41,7 @@ #define NSPV_BROADCASTRESP 0x0d int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum); +UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis); extern uint256 SIG_TXHASH; uint32_t NSPV_blocktime(int32_t hdrheight); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 76924be44..e4a559bc4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7007,7 +7007,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_FAUCET); v = MakeCC1vout(EVAL_FAUCET,funds,GetUnspendable(cp,0)); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkey2pk(Mypubkey()))) << OP_CHECKSIG); - return(NSPV_spend(srcaddr,HexStr(v.scriptPubKey.begin(),v.scriptPubKey.end()),funds)); + return(NSPV_spend(coinaddr,HexStr(v.scriptPubKey.begin(),v.scriptPubKey.end()),funds)); } if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); From e9707b1fde9448caac3512f79f4a87b9251f69ff Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 00:32:45 -1100 Subject: [PATCH 055/171] c_str --- 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 e4a559bc4..3b7c45cde 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7007,7 +7007,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_FAUCET); v = MakeCC1vout(EVAL_FAUCET,funds,GetUnspendable(cp,0)); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkey2pk(Mypubkey()))) << OP_CHECKSIG); - return(NSPV_spend(coinaddr,HexStr(v.scriptPubKey.begin(),v.scriptPubKey.end()),funds)); + return(NSPV_spend(coinaddr,HexStr(v.scriptPubKey.begin(),v.scriptPubKey.end()).c_str(),funds)); } if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); From 90e5dddda9a5513e86ccc802f67ca40d05184ce2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 00:33:55 -1100 Subject: [PATCH 056/171] Char * --- 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 3b7c45cde..16378c592 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7007,7 +7007,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_FAUCET); v = MakeCC1vout(EVAL_FAUCET,funds,GetUnspendable(cp,0)); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkey2pk(Mypubkey()))) << OP_CHECKSIG); - return(NSPV_spend(coinaddr,HexStr(v.scriptPubKey.begin(),v.scriptPubKey.end()).c_str(),funds)); + return(NSPV_spend(coinaddr,(char *)HexStr(v.scriptPubKey.begin(),v.scriptPubKey.end()).c_str(),funds)); } if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); From 635602d51982f81fb3809b01c949b6eadf1efa7c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 00:40:06 -1100 Subject: [PATCH 057/171] Off by 1 --- 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 16378c592..c11c4e7b2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7007,7 +7007,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) cp = CCinit(&C,EVAL_FAUCET); v = MakeCC1vout(EVAL_FAUCET,funds,GetUnspendable(cp,0)); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkey2pk(Mypubkey()))) << OP_CHECKSIG); - return(NSPV_spend(coinaddr,(char *)HexStr(v.scriptPubKey.begin(),v.scriptPubKey.end()).c_str(),funds)); + return(NSPV_spend(coinaddr,(char *)HexStr(v.scriptPubKey.begin()+1,v.scriptPubKey.end()-1).c_str(),funds)); } if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); From 4dfad9f720e1092fd1e3701f64680e957503b81c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 00:42:45 -1100 Subject: [PATCH 058/171] Bypass --- 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 c11c4e7b2..49c419c3d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7001,7 +7001,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("faucetfund amount\n"); funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; - if ( KOMODO_NSPV != 0 ) + if ( (0) && KOMODO_NSPV != 0 ) { char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v; cp = CCinit(&C,EVAL_FAUCET); From 6ee665057fb3a2dab0caa4ba2cdbb82fe809bcba Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 00:45:20 -1100 Subject: [PATCH 059/171] No lock --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 49c419c3d..968777b32 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7011,8 +7011,8 @@ UniValue faucetfund(const UniValue& params, bool fHelp) } if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); + //const CKeyStore& keystore = *pwalletMain; + //LOCK2(cs_main, pwalletMain->cs_wallet); if (funds > 0) { hex = FaucetFund(0,(uint64_t) funds); if ( hex.size() > 0 ) From 3501a9cd4c1b5df9742cb7feed84e8991436eeb7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 00:54:11 -1100 Subject: [PATCH 060/171] Solved bypass --- src/script/sign.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 6516c7176..532c4d448 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -433,7 +433,8 @@ bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPu } sigdata.scriptSig = PushAll(result); - + if ( KOMODO_NSPV != 0 ) + return(solved); // Test solution return solved && VerifyScript(sigdata.scriptSig, fromPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker(), consensusBranchId); } From 2a771477ce910a8195f22e2a7d92fe99a4bf806f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 01:33:53 -1100 Subject: [PATCH 061/171] Clear info N --- src/komodo_nSPV_fullnode.h | 1 + src/script/sign.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index bbc1712b8..da15c82e1 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -126,6 +126,7 @@ int32_t NSPV_getinfo(struct NSPV_inforesp *ptr,int32_t reqheight) { ptr->height = pindex->GetHeight(); ptr->blockhash = pindex->GetBlockHash(); + memset(&pair,0,sizeof(pair)); if ( NSPV_getntzsresp(&pair,ptr->height-1) < 0 ) return(-1); ptr->notarization = pair.prevntz; diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 532c4d448..3a9f658a2 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -85,7 +85,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, } else { - fprintf(stderr,"signed success %s\n",(char *)HexStr(vchSig).c_str()); + //fprintf(stderr,"signed success %s\n",(char *)HexStr(vchSig).c_str()); } } else From b403b5a838c41aa65612c0f2a1559c0e0fd004a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 01:43:35 -1100 Subject: [PATCH 062/171] Enable --- src/script/sign.cpp | 2 -- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 3a9f658a2..31e4b49fc 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -433,8 +433,6 @@ bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPu } sigdata.scriptSig = PushAll(result); - if ( KOMODO_NSPV != 0 ) - return(solved); // Test solution return solved && VerifyScript(sigdata.scriptSig, fromPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker(), consensusBranchId); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 968777b32..a597cc429 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7001,7 +7001,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("faucetfund amount\n"); funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; - if ( (0) && KOMODO_NSPV != 0 ) + if ( (1) && KOMODO_NSPV != 0 ) { char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v; cp = CCinit(&C,EVAL_FAUCET); From ca67f285cb2e9358c7cb65389e3ac27628c5da72 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 04:38:32 -1100 Subject: [PATCH 063/171] Fix rewards/validated --- src/komodo_nSPV_wallet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 2406ee5e3..9fcbc760b 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -383,8 +383,8 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a hex = NSPV_signtx(rewardsum,interestsum,retcodes,mtx,txfee,opret,used); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - result.push_back(Pair("rewards",AmountFromValue(interestsum))); - result.push_back(Pair("validated",AmountFromValue(rewardsum))); + result.push_back(Pair("rewards",(double)interestsum/COIN)); + result.push_back(Pair("validated",(double)rewardsum/COIN)); } if ( hex.size() > 0 ) { From a3fefe3aeb1ee39bba2841dd41afd7fb7a712292 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 04:42:47 -1100 Subject: [PATCH 064/171] +print --- src/script/sign.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 31e4b49fc..e4ab3525d 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -359,7 +359,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP } CKeyID keyID; - + fprintf(stderr,"whichtype.%d vs %d\n",whichTypeRet,TX_PUBKEYHASH); switch (whichTypeRet) { case TX_NONSTANDARD: @@ -371,12 +371,16 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP case TX_PUBKEYHASH: keyID = CKeyID(uint160(vSolutions[0])); if (!Sign1(keyID, creator, scriptPubKey, ret, consensusBranchId)) + { + fprintf(stderr,"sign1 error\n"); return false; + } else { CPubKey vch; creator.KeyStore().GetPubKey(keyID, vch); ret.push_back(ToByteVector(vch)); + fprintf(stderr,"push pubkey\n"); } return true; case TX_SCRIPTHASH: From 382d683b1a8268c5d9ec490675b9725987d2697a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 04:54:25 -1100 Subject: [PATCH 065/171] %.8f --- src/komodo_nSPV_wallet.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 9fcbc760b..61d7487c8 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -383,8 +383,11 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a hex = NSPV_signtx(rewardsum,interestsum,retcodes,mtx,txfee,opret,used); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - result.push_back(Pair("rewards",(double)interestsum/COIN)); - result.push_back(Pair("validated",(double)rewardsum/COIN)); + char numstr[64]; + sprintf(numstr,"%.8f",(double)interestsum/COIN) + result.push_back(Pair("rewards",numstr)); + sprintf(numstr,"%.8f",(double)rewardsum/COIN) + result.push_back(Pair("validated",numstr)); } if ( hex.size() > 0 ) { From a85a56543d0dd078886197dc2a491255e58e5e0c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 04:56:48 -1100 Subject: [PATCH 066/171] ; --- src/komodo_nSPV_wallet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 61d7487c8..3dc4b23f0 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -384,9 +384,9 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a if ( ASSETCHAINS_SYMBOL[0] == 0 ) { char numstr[64]; - sprintf(numstr,"%.8f",(double)interestsum/COIN) + sprintf(numstr,"%.8f",(double)interestsum/COIN); result.push_back(Pair("rewards",numstr)); - sprintf(numstr,"%.8f",(double)rewardsum/COIN) + sprintf(numstr,"%.8f",(double)rewardsum/COIN); result.push_back(Pair("validated",numstr)); } if ( hex.size() > 0 ) From e25d27e8c2f8bd9af81e92a047db739938c161a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:00:55 -1100 Subject: [PATCH 067/171] Disable bypass --- 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 a597cc429..968777b32 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7001,7 +7001,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("faucetfund amount\n"); funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; - if ( (1) && KOMODO_NSPV != 0 ) + if ( (0) && KOMODO_NSPV != 0 ) { char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v; cp = CCinit(&C,EVAL_FAUCET); From 200c155da6217485f2fc274d3b86eec2bbd96076 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:02:42 -1100 Subject: [PATCH 068/171] Print --- src/script/sign.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index e4ab3525d..1c33fd81a 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -380,7 +380,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP CPubKey vch; creator.KeyStore().GetPubKey(keyID, vch); ret.push_back(ToByteVector(vch)); - fprintf(stderr,"push pubkey\n"); + fprintf(stderr,"push pubkey %s\n",HexStr(vch).c_str()); } return true; case TX_SCRIPTHASH: From ca216319447b5dc468193545894d915d367f762c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:07:12 -1100 Subject: [PATCH 069/171] Test --- src/script/sign.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 1c33fd81a..ee188db63 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -380,7 +380,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP CPubKey vch; creator.KeyStore().GetPubKey(keyID, vch); ret.push_back(ToByteVector(vch)); - fprintf(stderr,"push pubkey %s\n",HexStr(vch).c_str()); + fprintf(stderr,"push pubkey %s %d\n",HexStr(vch).c_str(),TX_PUBKEYHASH); } return true; case TX_SCRIPTHASH: From 66247192444e9c52378bdd794efe7fae8d6580a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:10:13 -1100 Subject: [PATCH 070/171] Test --- src/script/sign.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index ee188db63..b775b03b0 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -377,10 +377,18 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP } else { - CPubKey vch; - creator.KeyStore().GetPubKey(keyID, vch); - ret.push_back(ToByteVector(vch)); - fprintf(stderr,"push pubkey %s %d\n",HexStr(vch).c_str(),TX_PUBKEYHASH); + if ( KOMODO_NSPV != 0 ) + { + extern char NSPV_pubkeystr[]; + fprintf(stderr,"push pubkey %s\n",NSPV_pubkeystr); + ret.push_back(ParseHex(NSPV_pubkeystr)); + } + else + { + CPubKey vch; + creator.KeyStore().GetPubKey(keyID, vch); + ret.push_back(ToByteVector(vch)); + } } return true; case TX_SCRIPTHASH: From 4e0ac4d995c2a8725eac9e9c7615a12236981100 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:11:34 -1100 Subject: [PATCH 071/171] extern char NSPV_pubkeystr[]; --- src/script/sign.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index b775b03b0..2e5354a0a 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -330,6 +330,8 @@ static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scrip * unless whichTypeRet is TX_SCRIPTHASH, in which case scriptSigRet is the redemption script. * Returns false if scriptPubKey could not be completely satisfied. */ +extern char NSPV_pubkeystr[]; + static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptPubKey, std::vector& ret, txnouttype& whichTypeRet, uint32_t consensusBranchId) { @@ -379,7 +381,6 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP { if ( KOMODO_NSPV != 0 ) { - extern char NSPV_pubkeystr[]; fprintf(stderr,"push pubkey %s\n",NSPV_pubkeystr); ret.push_back(ParseHex(NSPV_pubkeystr)); } From 72efa0be35c74ce335b14f87dd5f2057e9073c59 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:13:19 -1100 Subject: [PATCH 072/171] In komodo-tx --- src/komodo-tx.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo-tx.cpp b/src/komodo-tx.cpp index 04baecd39..2408dc076 100644 --- a/src/komodo-tx.cpp +++ b/src/komodo-tx.cpp @@ -48,6 +48,7 @@ using namespace std; #include "komodo_interest.h" CKey NSPV_key; +char NSPV_pubkeystr[67]; uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight) { return(0); From b41983c09c8dde782b88f4386c6f4f0a2ec05cf9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:15:13 -1100 Subject: [PATCH 073/171] Bypass verify --- src/script/sign.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 2e5354a0a..4face3f63 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -447,6 +447,8 @@ bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPu sigdata.scriptSig = PushAll(result); // Test solution + if ( KOMODO_NSPV != 0 ) + return(solved); return solved && VerifyScript(sigdata.scriptSig, fromPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker(), consensusBranchId); } From 4b82f0d4f7957dc5ee59459fc759aade39402a52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:23:50 -1100 Subject: [PATCH 074/171] +print --- src/script/sign.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 4face3f63..c9182940d 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -62,6 +62,8 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, fprintf(stderr,"keystore.%p error\n",keystore); return false; } + fprintf(stderr,"privkey for %s\n",EncodeDestination(NSPV_key.GetPubKey().GetID()).c_str()); + if (scriptCode.IsPayToCryptoCondition()) { CC *cc = (CC *)extraData; @@ -330,8 +332,6 @@ static bool SignStepCC(const BaseSignatureCreator& creator, const CScript& scrip * unless whichTypeRet is TX_SCRIPTHASH, in which case scriptSigRet is the redemption script. * Returns false if scriptPubKey could not be completely satisfied. */ -extern char NSPV_pubkeystr[]; - static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptPubKey, std::vector& ret, txnouttype& whichTypeRet, uint32_t consensusBranchId) { @@ -379,17 +379,10 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP } else { - if ( KOMODO_NSPV != 0 ) - { - fprintf(stderr,"push pubkey %s\n",NSPV_pubkeystr); - ret.push_back(ParseHex(NSPV_pubkeystr)); - } - else - { - CPubKey vch; - creator.KeyStore().GetPubKey(keyID, vch); - ret.push_back(ToByteVector(vch)); - } + CPubKey vch; + creator.KeyStore().GetPubKey(keyID, vch); + ret.push_back(ToByteVector(vch)); + fprintf(stderr,"push pubkey (%s)\n",HexStr(vch).c_str()); } return true; case TX_SCRIPTHASH: @@ -447,8 +440,6 @@ bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPu sigdata.scriptSig = PushAll(result); // Test solution - if ( KOMODO_NSPV != 0 ) - return(solved); return solved && VerifyScript(sigdata.scriptSig, fromPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker(), consensusBranchId); } From 9deab4a00bbd591a5c603978867b6a616b82e102 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:26:43 -1100 Subject: [PATCH 075/171] Test --- src/script/sign.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index c9182940d..7a9bb4052 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -36,6 +36,7 @@ using namespace std; typedef vector valtype; extern uint8_t ASSETCHAINS_TXPOW; extern CKey NSPV_key; +extern char NSPV_wifstr[]; extern int32_t KOMODO_NSPV; uint256 SIG_TXHASH; @@ -62,7 +63,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, fprintf(stderr,"keystore.%p error\n",keystore); return false; } - fprintf(stderr,"privkey for %s\n",EncodeDestination(NSPV_key.GetPubKey().GetID()).c_str()); + fprintf(stderr,"privkey (%s) for %s\n",NSPV_wifstr,EncodeDestination(NSPV_key.GetPubKey().GetID()).c_str()); if (scriptCode.IsPayToCryptoCondition()) { From 13185e15df32f7c4dd4ec14a42a1e14c4df6b409 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:29:57 -1100 Subject: [PATCH 076/171] Test --- src/komodo-tx.cpp | 2 +- src/script/sign.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/komodo-tx.cpp b/src/komodo-tx.cpp index 2408dc076..084d99c80 100644 --- a/src/komodo-tx.cpp +++ b/src/komodo-tx.cpp @@ -48,7 +48,7 @@ using namespace std; #include "komodo_interest.h" CKey NSPV_key; -char NSPV_pubkeystr[67]; +char NSPV_pubkeystr[67],NSPV_wifstr[64]; uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight) { return(0); diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 7a9bb4052..5ede7987b 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -35,7 +35,6 @@ using namespace std; typedef vector valtype; extern uint8_t ASSETCHAINS_TXPOW; -extern CKey NSPV_key; extern char NSPV_wifstr[]; extern int32_t KOMODO_NSPV; uint256 SIG_TXHASH; @@ -55,7 +54,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, } SIG_TXHASH = hash; if ( KOMODO_NSPV != 0 ) - key = NSPV_key; + key = DecodeSecret(wifstr); else if (pprivKey) key = *pprivKey; else if (!keystore || !keystore->GetKey(address, key)) @@ -63,7 +62,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, fprintf(stderr,"keystore.%p error\n",keystore); return false; } - fprintf(stderr,"privkey (%s) for %s\n",NSPV_wifstr,EncodeDestination(NSPV_key.GetPubKey().GetID()).c_str()); + fprintf(stderr,"privkey (%s) for %s\n",NSPV_wifstr,EncodeDestination(key.GetPubKey().GetID()).c_str()); if (scriptCode.IsPayToCryptoCondition()) { From da62c118e2c455f5c1209af546d39f604c92aa21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:30:54 -1100 Subject: [PATCH 077/171] Extern --- src/script/sign.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 5ede7987b..49e0d9ce2 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -54,7 +54,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, } SIG_TXHASH = hash; if ( KOMODO_NSPV != 0 ) - key = DecodeSecret(wifstr); + key = DecodeSecret(NSPV_wifstr); else if (pprivKey) key = *pprivKey; else if (!keystore || !keystore->GetKey(address, key)) From 1b718659f6c4b0595db9ffa4cb6b8fb19e72d530 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:33:57 -1100 Subject: [PATCH 078/171] Test --- src/script/sign.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 49e0d9ce2..8a77217f1 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -62,7 +62,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, fprintf(stderr,"keystore.%p error\n",keystore); return false; } - fprintf(stderr,"privkey (%s) for %s\n",NSPV_wifstr,EncodeDestination(key.GetPubKey().GetID()).c_str()); + //fprintf(stderr,"privkey (%s) for %s\n",NSPV_wifstr,EncodeDestination(key.GetPubKey().GetID()).c_str()); if (scriptCode.IsPayToCryptoCondition()) { @@ -361,7 +361,6 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP } CKeyID keyID; - fprintf(stderr,"whichtype.%d vs %d\n",whichTypeRet,TX_PUBKEYHASH); switch (whichTypeRet) { case TX_NONSTANDARD: @@ -379,10 +378,17 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP } else { - CPubKey vch; - creator.KeyStore().GetPubKey(keyID, vch); - ret.push_back(ToByteVector(vch)); - fprintf(stderr,"push pubkey (%s)\n",HexStr(vch).c_str()); + if ( KOMODO_NSPV == 0 ) + { + CPubKey vch; + creator.KeyStore().GetPubKey(keyID, vch); + ret.push_back(ToByteVector(vch)); + } + else + { + ret.push_back(ParseHex(NSPV_pubkey)); + fprintf(stderr,"push pubkey (%s)\n",NSPV_pubkey); + } } return true; case TX_SCRIPTHASH: From 6a0f51d066edc4e531204355bfa80e146d9534b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:35:20 -1100 Subject: [PATCH 079/171] NSPV_pubkeystr --- src/script/sign.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 8a77217f1..5088f5ec0 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -35,7 +35,7 @@ using namespace std; typedef vector valtype; extern uint8_t ASSETCHAINS_TXPOW; -extern char NSPV_wifstr[]; +extern char NSPV_wifstr[],NSPV_pubkeystr[]; extern int32_t KOMODO_NSPV; uint256 SIG_TXHASH; @@ -386,8 +386,8 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP } else { - ret.push_back(ParseHex(NSPV_pubkey)); - fprintf(stderr,"push pubkey (%s)\n",NSPV_pubkey); + ret.push_back(ParseHex(NSPV_pubkeystr)); + fprintf(stderr,"push pubkey (%s)\n",NSPV_pubkeystr); } } return true; From dc7e92dd37de68e2ceaf6b86068f977a9fa16c39 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:37:40 -1100 Subject: [PATCH 080/171] Test --- 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 968777b32..a597cc429 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7001,7 +7001,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("faucetfund amount\n"); funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; - if ( (0) && KOMODO_NSPV != 0 ) + if ( (1) && KOMODO_NSPV != 0 ) { char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v; cp = CCinit(&C,EVAL_FAUCET); From 99313e742faa0bd38a9809c5fbfa9c1d06ec3bf6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 05:44:53 -1100 Subject: [PATCH 081/171] Tmp tmp wallet --- src/init.cpp | 1 + src/script/sign.cpp | 7 +------ src/wallet/rpcwallet.cpp | 6 +++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 4adde6681..9296d17ac 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1496,6 +1496,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) InitBlockIndex(); SetRPCWarmupFinished(); uiInterface.InitMessage(_("Done loading")); + pwalletMain = new CWallet("tmptmp.wallet"); return !fRequestShutdown; } // ********************************************************* Step 7: load block chain diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 5088f5ec0..451a63d4b 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -383,12 +383,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP CPubKey vch; creator.KeyStore().GetPubKey(keyID, vch); ret.push_back(ToByteVector(vch)); - } - else - { - ret.push_back(ParseHex(NSPV_pubkeystr)); - fprintf(stderr,"push pubkey (%s)\n",NSPV_pubkeystr); - } + } else ret.push_back(ParseHex(NSPV_pubkeystr)); } return true; case TX_SCRIPTHASH: diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a597cc429..49c419c3d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7001,7 +7001,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("faucetfund amount\n"); funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; - if ( (1) && KOMODO_NSPV != 0 ) + if ( (0) && KOMODO_NSPV != 0 ) { char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v; cp = CCinit(&C,EVAL_FAUCET); @@ -7011,8 +7011,8 @@ UniValue faucetfund(const UniValue& params, bool fHelp) } if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - //const CKeyStore& keystore = *pwalletMain; - //LOCK2(cs_main, pwalletMain->cs_wallet); + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); if (funds > 0) { hex = FaucetFund(0,(uint64_t) funds); if ( hex.size() > 0 ) From 04710fdf01dedacce9a0cf293454e8b558b705f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 13:55:33 -1100 Subject: [PATCH 082/171] -const in CBlockIndexWorkComparator https://github.com/jl777/komodo/issues/1606 --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e01cba61f..a8f333aa8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -147,7 +147,7 @@ namespace { struct CBlockIndexWorkComparator { - bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const { + bool operator()(CBlockIndex *pa, const CBlockIndex *pb) const { // First sort by most total work, ... if (ASSETCHAINS_LWMAPOS) { From 3f3f80723c4618f8c50321e7005f0ef81b0827a8 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Sat, 6 Jul 2019 19:16:53 +0200 Subject: [PATCH 083/171] jokers payments fix --- src/cc/payments.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index b6e85480c..be4d63271 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -314,6 +314,8 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & fIsMerge = true; else if ( DecodePaymentsReleaseOpRet(ccopret,createtxid,amountReleased) != 'R' ) return(eval->Invalid("could not decode ccopret")); + if ( tx.vout.back().scriptPubKey.IsOpReturn() ) + fHasOpret = true; mpz_set_si(mpzCheckamount,amountReleased); } else return(eval->Invalid("could not decode ccopret")); From bb6d8b7b99697bc4240f05cc7a575b396fb5e957 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Tue, 9 Jul 2019 22:17:00 +0200 Subject: [PATCH 084/171] fix ac_cbmaturity magic without other params --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1bf8dfbeb..e06b42b69 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2040,7 +2040,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); StartShutdown(); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 || ASSETCHAINS_BLOCKTIME != 60 || ASSETCHAINS_CBOPRET != 0 || Mineropret.size() != 0 || (ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0) || KOMODO_SNAPSHOT_INTERVAL != 0 || ASSETCHAINS_EARLYTXIDCONTRACT != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 || ASSETCHAINS_BLOCKTIME != 60 || ASSETCHAINS_CBOPRET != 0 || Mineropret.size() != 0 || (ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0) || KOMODO_SNAPSHOT_INTERVAL != 0 || ASSETCHAINS_EARLYTXIDCONTRACT != 0 || ASSETCHAINS_CBMATURITY != 0) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; From 51c44114466602f6cea7f2733d5f354fbdb0fdaf Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Fri, 5 Jul 2019 23:02:18 +0200 Subject: [PATCH 085/171] add ac_cbmaturity --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index d8e292431..9ffa147ea 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -46,7 +46,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = _COINBASE_MATURITY;//100; unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; uint256 KOMODO_EARLYTXID; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e06b42b69..76ca5c7ae 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1839,6 +1839,7 @@ void komodo_args(char *argv0) Split(GetArg("-ac_decay",""), ASSETCHAINS_DECAY, 0); Split(GetArg("-ac_notarypay",""), ASSETCHAINS_NOTARY_PAY, 0); + for ( int i = 0; i < ASSETCHAINS_MAX_ERAS; i++ ) { if ( ASSETCHAINS_DECAY[i] == 100000000 && ASSETCHAINS_ENDSUBSIDY == 0 ) @@ -1872,6 +1873,7 @@ void komodo_args(char *argv0) ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); ASSETCHAINS_CBOPRET = GetArg("-ac_cbopret",0); + ASSETCHAINS_CBMATURITY = GetArg("-ac_cbmaturity",100); //fprintf(stderr,"ASSETCHAINS_CBOPRET.%llx\n",(long long)ASSETCHAINS_CBOPRET); if ( ASSETCHAINS_CBOPRET != 0 ) { @@ -2184,6 +2186,10 @@ void komodo_args(char *argv0) { extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_EARLYTXIDCONTRACT),(void *)&ASSETCHAINS_EARLYTXIDCONTRACT); } + if ( ASSETCHAINS_CBMATURITY != 100 ) + { + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBMATURITY),(void *)&ASSETCHAINS_CBMATURITY); + } } addn = GetArg("-seednode",""); @@ -2234,8 +2240,15 @@ void komodo_args(char *argv0) } if ( (port= komodo_userpass(ASSETCHAINS_USERPASS,ASSETCHAINS_SYMBOL)) != 0 ) ASSETCHAINS_RPCPORT = port; - else komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT + 1); - if (ASSETCHAINS_LASTERA == 0 || is_STAKED(ASSETCHAINS_SYMBOL) != 0) + else komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT + 1);\ + if (ASSETCHAINS_CBMATURITY < 1) + { + fprintf(stderr,"ac_cbmaturity must be >0\n"); + StartShutdown(); + } + if (ASSETCHAINS_CBMATURITY != 100) + COINBASE_MATURITY = ASSETCHAINS_CBMATURITY; + else if (ASSETCHAINS_LASTERA == 0 || is_STAKED(ASSETCHAINS_SYMBOL) != 0) COINBASE_MATURITY = 1; //fprintf(stderr,"ASSETCHAINS_RPCPORT (%s) %u\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_RPCPORT); } From c7ecffc934af7715c6d6b2c367e84c904e418efe Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Fri, 5 Jul 2019 23:13:15 +0200 Subject: [PATCH 086/171] syntax, remove misplaced \ --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 76ca5c7ae..f72d11762 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2240,7 +2240,7 @@ void komodo_args(char *argv0) } if ( (port= komodo_userpass(ASSETCHAINS_USERPASS,ASSETCHAINS_SYMBOL)) != 0 ) ASSETCHAINS_RPCPORT = port; - else komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT + 1);\ + else komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT + 1); if (ASSETCHAINS_CBMATURITY < 1) { fprintf(stderr,"ac_cbmaturity must be >0\n"); From a273e8fdedc78c50a4d310eb18fa8c5fdd8fa89e Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Fri, 5 Jul 2019 23:14:37 +0200 Subject: [PATCH 087/171] remove extra whitespace --- src/komodo_utils.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f72d11762..08c28a2fd 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1839,7 +1839,6 @@ void komodo_args(char *argv0) Split(GetArg("-ac_decay",""), ASSETCHAINS_DECAY, 0); Split(GetArg("-ac_notarypay",""), ASSETCHAINS_NOTARY_PAY, 0); - for ( int i = 0; i < ASSETCHAINS_MAX_ERAS; i++ ) { if ( ASSETCHAINS_DECAY[i] == 100000000 && ASSETCHAINS_ENDSUBSIDY == 0 ) From 5b7afedaecf1799ba3620740c37e803cafea49a3 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Fri, 5 Jul 2019 23:39:32 +0200 Subject: [PATCH 088/171] fix ac_cbmaturity=100 case --- src/komodo_utils.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 08c28a2fd..57d652309 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1872,7 +1872,7 @@ void komodo_args(char *argv0) ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); ASSETCHAINS_CBOPRET = GetArg("-ac_cbopret",0); - ASSETCHAINS_CBMATURITY = GetArg("-ac_cbmaturity",100); + ASSETCHAINS_CBMATURITY = GetArg("-ac_cbmaturity",0); //fprintf(stderr,"ASSETCHAINS_CBOPRET.%llx\n",(long long)ASSETCHAINS_CBOPRET); if ( ASSETCHAINS_CBOPRET != 0 ) { @@ -2185,7 +2185,7 @@ void komodo_args(char *argv0) { extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_EARLYTXIDCONTRACT),(void *)&ASSETCHAINS_EARLYTXIDCONTRACT); } - if ( ASSETCHAINS_CBMATURITY != 100 ) + if ( ASSETCHAINS_CBMATURITY != 0 ) { extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBMATURITY),(void *)&ASSETCHAINS_CBMATURITY); } @@ -2240,15 +2240,16 @@ void komodo_args(char *argv0) if ( (port= komodo_userpass(ASSETCHAINS_USERPASS,ASSETCHAINS_SYMBOL)) != 0 ) ASSETCHAINS_RPCPORT = port; else komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT + 1); - if (ASSETCHAINS_CBMATURITY < 1) - { - fprintf(stderr,"ac_cbmaturity must be >0\n"); - StartShutdown(); - } - if (ASSETCHAINS_CBMATURITY != 100) + + if (ASSETCHAINS_CBMATURITY != 0) COINBASE_MATURITY = ASSETCHAINS_CBMATURITY; else if (ASSETCHAINS_LASTERA == 0 || is_STAKED(ASSETCHAINS_SYMBOL) != 0) COINBASE_MATURITY = 1; + if (COINBASE_MATURITY < 1) + { + fprintf(stderr,"ac_cbmaturity must be >0, shutting down\n"); + StartShutdown(); + } //fprintf(stderr,"ASSETCHAINS_RPCPORT (%s) %u\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_RPCPORT); } if ( ASSETCHAINS_RPCPORT == 0 ) From c267dcb2823ffe02ec261bfc6f5c03d9aabdc965 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 14:52:43 -1100 Subject: [PATCH 089/171] KOMODO_EARLYTXID_HEIGHT --- src/bitcoind.cpp | 2 +- src/cc/faucet.cpp | 2 +- src/cc/hempcoin_notes.txt | 4 ++-- src/komodo_bitcoind.h | 10 +++++----- src/komodo_defs.h | 2 +- src/komodo_utils.h | 2 +- src/miner.cpp | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index a356e20a7..0baadf620 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -72,7 +72,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) // Tell the main threads to shutdown. if (komodo_currentheight()>KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID!=zeroid && ((height=tx_height(KOMODO_EARLYTXID))==0 || height>KOMODO_EARLYTXID_HEIGHT)) { - fprintf(stderr,"error: earlytx must be before block height 100 or tx does not exist\n"); + fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT); StartShutdown(); } if ( ASSETCHAINS_CBOPRET != 0 ) diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index 25eb5271d..fd3a8f60f 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -159,7 +159,7 @@ int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub continue; //char str[65]; fprintf(stderr,"check %s/v%d %.8f`\n",uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); // no need to prevent dup - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( (nValue= IsFaucetvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { diff --git a/src/cc/hempcoin_notes.txt b/src/cc/hempcoin_notes.txt index 2fd72c897..04bf0e9ac 100644 --- a/src/cc/hempcoin_notes.txt +++ b/src/cc/hempcoin_notes.txt @@ -1,6 +1,6 @@ How this works: - - earlytxid must be a transaction included in the chain before block 100. The chain MUST not have any other of these type of tx before block 100, or someone may be able to change it and mess things up. - - When it gets to block 100, it takes the txid specified by the -earlytxid param (does not affect magic) + - earlytxid must be a transaction included in the chain before block KOMODO_EARLYTXID_HEIGHT. The chain MUST not have any other of these type of tx before block KOMODO_EARLYTXID_HEIGHT, or someone may be able to change it and mess things up. + - When it gets to block KOMODO_EARLYTXID_HEIGHT, it takes the txid specified by the -earlytxid param (does not affect magic) - Looks up the transaction searches for the opreturn, then permenantly appends it to the end of ac_script in RAM. - After every daemon restart, the first time the daemon mines a block, or receives a block that pays ac_script it will look up the op_return and save it again. - this enables it to always reach consensus but doesnt need to constantly keep looking up the tx in the chain. diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b3f870170..477c99ff2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2072,7 +2072,7 @@ bool komodo_appendACscriptpub() { CTransaction tx; uint256 blockhash; // get transaction and check that it occured before height 100. - if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < 100 ) + if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < KOMODO_EARLYTXID_HEIGHT ) { for (int i = 0; i < tx.vout.size(); i++) { @@ -2107,15 +2107,15 @@ void GetKomodoEarlytxidScriptPub() StartShutdown(); return; } - if ( chainActive.Height() < 100 ) + if ( chainActive.Height() < KOMODO_EARLYTXID_HEIGHT ) { - fprintf(stderr, "Cannot fetch -earlytxid before block 100.\n"); + fprintf(stderr, "Cannot fetch -earlytxid before block %d.\n",KOMODO_EARLYTXID_HEIGHT); StartShutdown(); return; } CTransaction tx; uint256 blockhash; int32_t i; // get transaction and check that it occured before height 100. - if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < 100 ) + if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < KOMODO_EARLYTXID_HEIGHT ) { for (i = 0; i < tx.vout.size(); i++) if ( tx.vout[i].scriptPubKey[0] == OP_RETURN ) @@ -2156,7 +2156,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { static bool didinit = false; - if ( !didinit && height > 100 && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() ) + if ( !didinit && height > KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() ) { fprintf(stderr, "appended CC_op_return to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str()); didinit = true; diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 001ee0dce..1ee3ef788 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -17,7 +17,7 @@ #define KOMODO_DEFS_H #include "komodo_nk.h" -#define KOMODO_EARLYTXID_HEIGHT 200 +#define KOMODO_EARLYTXID_HEIGHT 100 #define ASSETCHAINS_MINHEIGHT 128 #define ASSETCHAINS_MAX_ERAS 7 #define KOMODO_ELECTION_GAP 2000 diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 41fab362c..0821017ff 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2387,7 +2387,7 @@ void komodo_args(char *argv0) if ( strcmp("ILN",ASSETCHAINS_SYMBOL) == 0 ) { // No CCs used on this chain yet. - // CCDISABLEALL; + CCDISABLEALL; } if ( strcmp("OUR",ASSETCHAINS_SYMBOL) == 0 ) { diff --git a/src/miner.cpp b/src/miner.cpp index 55e2c708f..2e428c0dc 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -665,7 +665,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { static bool didinit = false; - if ( !didinit && nHeight > 100 && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() ) + if ( !didinit && nHeight > KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() ) { fprintf(stderr, "appended ccopreturn to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str()); didinit = true; From 4bbc78d5275202e0fc7b976d26fccb807906be2b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 15:17:25 -1100 Subject: [PATCH 090/171] NSPV_utxos2CCunspents --- src/cc/CCtx.cpp | 7 +++++++ src/komodo_nSPV_wallet.h | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 96b22adad..c29856d1c 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -325,9 +325,16 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else return("0"); } +void NSPV_CCunspents(std::vector > &unspentOutputs,char *coinaddr,bool ccflag); + void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool ccflag) { int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector > addresses; + if ( KOMODO_NSPV != 0 ) + { + NSPV_CCunspents(unspentOutputs,coinaddr,ccflag); + return; + } n = (int32_t)strlen(coinaddr); addrstr.resize(n+1); ptr = (char *)addrstr.data(); diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 3dc4b23f0..2e883a439 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -442,4 +442,31 @@ int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total } else return(0); } +void NSPV_utxos2CCunspents(struct NSPV_utxosresp *ptr,std::vector > &outputs) +{ + CAddressUnspentKey key; CAddressUnspentValue value; int32_t i,type; uint160 hashBytes; std::string addrstr(ptr->coinaddr); + if ( ptr->utxos != NULL && ptr->numutxos > 0 ) + { + CBitcoinAddress address(addrstr); + if (address.GetIndexKey(hashBytes, type, ptr->CCflag) == 0) + return; + for (i = 0; i < ptr->numutxos; i ++) + { + key.type = type; + key.hashBytes = hashBytes; + key.txhash = ptr->utxos[i].txid; + key.index = ptr->utxos[i].vout; + value.satoshis = ptr->utxos[i].satoshis; + value.blockHeight = ptr->utxos[i].height; + outputs.push_back(std::make_pair(key, value)); + } + } +} + +void NSPV_CCunspents(std::vector > &outputs,char *coinaddr,bool ccflag) +{ + UniValue NSPV_addressutxos(coinaddr,ccflag); + NSPV_utxos2CCunspents(&NSPV_utxosresult,outputs); +} + #endif // KOMODO_NSPVWALLET_H From 44cd71622cb839b778c142aa0ef5882739fe7ade Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 15:23:20 -1100 Subject: [PATCH 091/171] +print --- src/komodo_nSPV_wallet.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 2e883a439..bf64657df 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -445,11 +445,15 @@ int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total void NSPV_utxos2CCunspents(struct NSPV_utxosresp *ptr,std::vector > &outputs) { CAddressUnspentKey key; CAddressUnspentValue value; int32_t i,type; uint160 hashBytes; std::string addrstr(ptr->coinaddr); + fprintf(stderr,"in converter\n"); if ( ptr->utxos != NULL && ptr->numutxos > 0 ) { CBitcoinAddress address(addrstr); - if (address.GetIndexKey(hashBytes, type, ptr->CCflag) == 0) + if ( address.GetIndexKey(hashBytes, type, ptr->CCflag) == 0 ) + { + fprintf(stderr,"couldnt get indexkey\n"); return; + } for (i = 0; i < ptr->numutxos; i ++) { key.type = type; From 88a5fd74ec1eee030bdf54afb481355804bb6976 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 15:25:12 -1100 Subject: [PATCH 092/171] Cast --- src/komodo_nSPV_wallet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index bf64657df..94123941e 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -469,7 +469,7 @@ void NSPV_utxos2CCunspents(struct NSPV_utxosresp *ptr,std::vector > &outputs,char *coinaddr,bool ccflag) { - UniValue NSPV_addressutxos(coinaddr,ccflag); + UniValue NSPV_addressutxos(coinaddr,(int32_t)ccflag); NSPV_utxos2CCunspents(&NSPV_utxosresult,outputs); } From c893ef98995ee83a06090061e192f767c6a3434d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 15:26:17 -1100 Subject: [PATCH 093/171] Syntax --- src/komodo_nSPV_wallet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 94123941e..8b638c28b 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -469,7 +469,7 @@ void NSPV_utxos2CCunspents(struct NSPV_utxosresp *ptr,std::vector > &outputs,char *coinaddr,bool ccflag) { - UniValue NSPV_addressutxos(coinaddr,(int32_t)ccflag); + NSPV_addressutxos(coinaddr,ccflag); NSPV_utxos2CCunspents(&NSPV_utxosresult,outputs); } From c84b5641c82cc8eae11e9f0f5de051c8f80eabb8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 21:16:19 -1100 Subject: [PATCH 094/171] +print --- src/cc/CCtx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index c29856d1c..506b710e7 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -175,7 +175,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); - //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); + fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { @@ -199,7 +199,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = unspendablepriv; cond = othercond; - //fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); + fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); } else if (strcmp(destaddr, unspendabletokensaddr) == 0) { From c63782f0ca4088cbd40e532074b6cca225d71921 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 21:21:26 -1100 Subject: [PATCH 095/171] +print --- src/cc/CCtx.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 506b710e7..ab4c55a3f 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -175,7 +175,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); - fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); + //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { @@ -199,7 +199,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = unspendablepriv; cond = othercond; - fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); + //fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); } else if (strcmp(destaddr, unspendabletokensaddr) == 0) { @@ -280,13 +280,13 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL, utxovalues[i],consensusBranchId, &txdata); if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 ) { - //int32_t z; - //for (z=0; z<32; z++) - // fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); - //fprintf(stderr," sighash, "); - //for (z=0; z<32; z++) - // fprintf(stderr,"%02x",privkey[z]); - //fprintf(stderr," signed with privkey\n"); + int32_t z; + for (z=0; z<32; z++) + fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); + fprintf(stderr," sighash, "); + for (z=0; z<32; z++) + fprintf(stderr,"%02x",privkey[z]); + fprintf(stderr," signed with privkey\n"); mtx.vin[i].scriptSig = CCSig(cond); } else From 93fb6f5f5121b0c6e3396dcbe13829e878f872fe Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 21:47:48 -1100 Subject: [PATCH 096/171] -print --- src/cc/CCinclude.h | 1 + src/cc/CCtx.cpp | 14 +-- src/rpc/crosschain.cpp | 23 ++-- src/rpc/testtransactions.cpp | 10 +- src/wallet/rpcwallet.cpp | 236 +++++++++++++++++------------------ 5 files changed, 143 insertions(+), 141 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 53a2d050f..5882a1355 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -56,6 +56,7 @@ one other technical note is that komodod has the insight-explorer extensions bui #define CC_BURNPUBKEY "02deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" #define CC_MAXVINS 1024 +#define CC_REQUIREMENTS_MSG (KOMMODO_NSPV!=0?"to use CC contracts you need to nspv_login first\n":"to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n") #define SMALLVAL 0.000000000000001 #define SATOSHIDEN ((uint64_t)100000000L) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index ab4c55a3f..c29856d1c 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -280,13 +280,13 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL, utxovalues[i],consensusBranchId, &txdata); if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 ) { - int32_t z; - for (z=0; z<32; z++) - fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); - fprintf(stderr," sighash, "); - for (z=0; z<32; z++) - fprintf(stderr,"%02x",privkey[z]); - fprintf(stderr," signed with privkey\n"); + //int32_t z; + //for (z=0; z<32; z++) + // fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); + //fprintf(stderr," sighash, "); + //for (z=0; z<32; z++) + // fprintf(stderr,"%02x",privkey[z]); + //fprintf(stderr," signed with privkey\n"); mtx.vin[i].scriptSig = CCSig(cond); } else diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index bf0dbea4c..8407439ff 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -854,6 +854,7 @@ UniValue importgatewayinfo(const UniValue& params, bool fHelp) return(ImportGatewayInfo(txid)); } + UniValue importgatewaybind(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); @@ -866,7 +867,7 @@ UniValue importgatewaybind(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 8) throw runtime_error("use \'importgatewaybind coin orcletxid M N pubkeys pubtype p2shtype wiftype [taddr]\' to bind an import gateway\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); CCerror = ""; coin = params[0].get_str(); oracletxid = Parseuint256(params[1].get_str().c_str()); @@ -919,7 +920,7 @@ UniValue importgatewaydeposit(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 9) throw runtime_error("use \'importgatewaydeposit bindtxid height coin burntxid nvout rawburntx rawproof destpub amount\' to import deposited coins\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); CCerror = ""; bindtxid = Parseuint256(params[0].get_str().c_str()); height = atoi(params[1].get_str().c_str()); @@ -962,7 +963,7 @@ UniValue importgatewaywithdraw(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 4) throw runtime_error("use \'importgatewaywithdraw bindtxid coin withdrawpub amount\' to burn imported coins and withdraw them on external chain\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); CCerror = ""; bindtxid = Parseuint256(params[0].get_str().c_str()); coin = params[1].get_str(); @@ -997,7 +998,7 @@ UniValue importgatewaypartialsign(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("importgatewayspartialsign txidaddr refcoin hex\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); txid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); parthex = params[2].get_str(); @@ -1020,7 +1021,7 @@ UniValue importgatewaycompletesigning(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("importgatewaycompletesigning withdrawtxid coin hex\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); withdrawtxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); txhex = params[2].get_str(); @@ -1040,7 +1041,7 @@ UniValue importgatewaymarkdone(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("importgatewaymarkdone completesigningtx coin\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); completetxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); hex = ImportGatewayMarkDone(0,completetxid,coin); @@ -1059,7 +1060,7 @@ UniValue importgatewaypendingdeposits(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("importgatewaypendingdeposits bindtxid coin\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); return(ImportGatewayPendingDeposits(bindtxid,coin)); @@ -1071,7 +1072,7 @@ UniValue importgatewaypendingwithdraws(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("importgatewaypendingwithdraws bindtxid coin\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); return(ImportGatewayPendingWithdraws(bindtxid,coin)); @@ -1083,7 +1084,7 @@ UniValue importgatewayprocessed(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("importgatewayprocessed bindtxid coin\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); return(ImportGatewayProcessedWithdraws(bindtxid,coin)); @@ -1096,7 +1097,7 @@ UniValue importgatewayexternaladdress(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2) throw runtime_error("importgatewayexternaladdress bindtxid pubkey\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); pubkey = ParseHex(params[1].get_str().c_str()); return(ImportGatewayExternalAddress(bindtxid,pubkey)); @@ -1109,7 +1110,7 @@ UniValue importgatewaydumpprivkey(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2) throw runtime_error("importgatewaydumpprivkey bindtxid address\n"); if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); std::string strAddress = params[1].get_str(); CTxDestination dest = DecodeDestination(strAddress); diff --git a/src/rpc/testtransactions.cpp b/src/rpc/testtransactions.cpp index ddf7c8895..849300a62 100644 --- a/src/rpc/testtransactions.cpp +++ b/src/rpc/testtransactions.cpp @@ -61,7 +61,7 @@ UniValue test_ac(const UniValue& params, bool fHelp) if (fHelp || (params.size() != 4)) throw runtime_error("incorrect params\n"); if (ensure_CCrequirements(EVAL_HEIR) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); std::vector pubkey1; std::vector pubkey2; @@ -106,7 +106,7 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp) if (fHelp || (params.size() != 1)) throw runtime_error("incorrect params\n"); if (ensure_CCrequirements(EVAL_HEIR) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); uint256 fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -137,7 +137,7 @@ UniValue test_burntx(const UniValue& params, bool fHelp) if (fHelp || (params.size() != 1)) throw runtime_error("incorrect params\n"); if (ensure_CCrequirements(EVAL_TOKENS) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); uint256 tokenid = Parseuint256((char *)params[0].get_str().c_str()); @@ -230,7 +230,7 @@ UniValue test_pricesmarker(const UniValue& params, bool fHelp) if (fHelp || (params.size() != 1)) throw runtime_error("incorrect params\n"); if (ensure_CCrequirements(EVAL_PRICES) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); uint256 bettxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -265,4 +265,4 @@ void RegisterTesttransactionsRPCCommands(CRPCTable &tableRPC) { for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]); -} \ No newline at end of file +} diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 49c419c3d..426baa1f7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5544,7 +5544,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("channelsaddress pubkey\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Channels",pubkey)); } @@ -5555,7 +5555,7 @@ UniValue cclibaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 2 ) throw runtime_error("cclibaddress [evalcode] [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() >= 1 ) { evalcode = atoi(params[0].get_str().c_str()); @@ -5576,7 +5576,7 @@ UniValue cclibinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 0 ) throw runtime_error("cclibinfo\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); cp = CCinit(&C,evalcode); return(CClib_info(cp)); } @@ -5591,7 +5591,7 @@ UniValue cclib(const UniValue& params, bool fHelp) if ( ASSETCHAINS_CCLIB.size() == 0 ) throw runtime_error("no -ac_cclib= specified\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); method = (char *)params[0].get_str().c_str(); @@ -5624,7 +5624,7 @@ UniValue payments_release(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("paymentsrelease \"[%22createtxid%22,amount,(skipminimum)]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); @@ -5637,7 +5637,7 @@ UniValue payments_fund(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("paymentsfund \"[%22createtxid%22,amount(,useopret)]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); @@ -5650,7 +5650,7 @@ UniValue payments_merge(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("paymentsmerge \"[%22createtxid%22]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); @@ -5663,7 +5663,7 @@ UniValue payments_txidopret(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("paymentstxidopret \"[allocation,%22scriptPubKey%22(,%22destopret%22)]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); @@ -5676,7 +5676,7 @@ UniValue payments_create(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("paymentscreate \"[lockedblocks,minamount,%22paytxid0%22,...,%22paytxidN%22]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); @@ -5689,7 +5689,7 @@ UniValue payments_airdrop(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("paymentsairdrop \"[lockedblocks,minamount,mintoaddress,top,bottom,fixedFlag,%22excludeAddress%22,...,%22excludeAddressN%22]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); @@ -5702,7 +5702,7 @@ UniValue payments_airdroptokens(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("payments_airdroptokens \"[%22tokenid%22,lockedblocks,minamount,mintoaddress,top,bottom,fixedFlag,%22excludePubKey%22,...,%22excludePubKeyN%22]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); @@ -5715,7 +5715,7 @@ UniValue payments_info(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("paymentsinfo \"[%22createtxid%22]\"\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); @@ -5728,7 +5728,7 @@ UniValue payments_list(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 0 ) throw runtime_error("paymentslist\n"); if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); cp = CCinit(&C,EVAL_PAYMENTS); @@ -5742,7 +5742,7 @@ UniValue oraclesaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("oraclesaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Oracles",pubkey)); @@ -5756,7 +5756,7 @@ UniValue pricesaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("pricesaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); result = CCaddress(cp,(char *)"Prices",pubkey); @@ -5778,7 +5778,7 @@ UniValue pegsaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("pegssaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Pegs",pubkey)); @@ -5791,7 +5791,7 @@ UniValue marmaraaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("Marmaraaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Marmara",pubkey)); @@ -5804,7 +5804,7 @@ UniValue paymentsaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("paymentsaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Payments",pubkey)); @@ -5817,7 +5817,7 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("gatewaysaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Gateways",pubkey)); @@ -5830,7 +5830,7 @@ UniValue heiraddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("heiraddress pubkey\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Heir",pubkey)); } @@ -5842,7 +5842,7 @@ UniValue lottoaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("lottoaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Lotto",pubkey)); @@ -5855,7 +5855,7 @@ UniValue FSMaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("FSMaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"FSM",pubkey)); @@ -5868,7 +5868,7 @@ UniValue auctionaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("auctionaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Auction",pubkey)); @@ -5881,7 +5881,7 @@ UniValue diceaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("diceaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Dice",pubkey)); @@ -5909,7 +5909,7 @@ UniValue rewardsaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("rewardsaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Rewards",pubkey)); @@ -5922,7 +5922,7 @@ UniValue assetsaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() > 1) throw runtime_error("assetsaddress [pubkey]\n"); if (ensure_CCrequirements(0) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if (params.size() == 1) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp, (char *)"Assets", pubkey)); @@ -5935,7 +5935,7 @@ UniValue tokenaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("tokenaddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"Tokens", pubkey)); @@ -5948,7 +5948,7 @@ UniValue importgatewayaddress(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("importgatewayddress [pubkey]\n"); if ( ensure_CCrequirements(0) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); return(CCaddress(cp,(char *)"ImportGateway", pubkey)); @@ -5964,7 +5964,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) throw runtime_error("marmarapoolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); } if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); perc = atof(params[0].get_str().c_str()) / 100.; @@ -5984,7 +5984,7 @@ UniValue marmara_receive(const UniValue& params, bool fHelp) throw runtime_error("marmarareceive senderpk amount currency matures batontxid\n"); } if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); memset(&batontxid,0,sizeof(batontxid)); @@ -6015,7 +6015,7 @@ UniValue marmara_issue(const UniValue& params, bool fHelp) throw runtime_error("marmaraissue receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); receiverpub = ParseHex(params[0].get_str().c_str()); @@ -6040,7 +6040,7 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp) throw runtime_error("marmaratransfer receiverpk amount currency matures approvaltxid\n"); } if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); receiverpub = ParseHex(params[0].get_str().c_str()); if (receiverpub.size()!= 33) { @@ -6066,7 +6066,7 @@ UniValue marmara_info(const UniValue& params, bool fHelp) throw runtime_error("marmarainfo firstheight lastheight minamount maxamount [currency issuerpk]\n"); } if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); firstheight = atol(params[0].get_str().c_str()); @@ -6098,7 +6098,7 @@ UniValue marmara_creditloop(const UniValue& params, bool fHelp) throw runtime_error("marmaracreditloop txid\n"); } if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6116,7 +6116,7 @@ UniValue marmara_settlement(const UniValue& params, bool fHelp) throw runtime_error("marmarasettlement batontxid\n"); } if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); batontxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6145,7 +6145,7 @@ UniValue channelslist(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 0 ) throw runtime_error("channelsinfo\n"); if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); return(ChannelsList()); @@ -6157,7 +6157,7 @@ UniValue channelsinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("channelsinfo [opentxid]\n"); if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); opentxid=zeroid; @@ -6175,7 +6175,7 @@ UniValue channelsopen(const UniValue& params, bool fHelp) if ( fHelp || params.size() < 3 || params.size() > 4) throw runtime_error("channelsopen destpubkey numpayments payment\n"); if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); destpub = ParseHex(params[0].get_str().c_str()); @@ -6217,7 +6217,7 @@ UniValue channelspayment(const UniValue& params, bool fHelp) if ( fHelp || params.size() < 2 || params.size() >3 ) throw runtime_error("channelspayment opentxid amount [secret]\n"); if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); opentxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6248,7 +6248,7 @@ UniValue channelsclose(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("channelsclose opentxid\n"); if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); opentxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6269,7 +6269,7 @@ UniValue channelsrefund(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("channelsrefund opentxid closetxid\n"); if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); opentxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6290,7 +6290,7 @@ UniValue rewardscreatefunding(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 6 || params.size() < 2 ) throw runtime_error("rewardscreatefunding name amount APR mindays maxdays mindeposit\n"); if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); // default to OOT params @@ -6359,7 +6359,7 @@ UniValue rewardslock(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("rewardslock name fundingtxid amount\n"); if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); @@ -6389,7 +6389,7 @@ UniValue rewardsaddfunding(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("rewardsaddfunding name fundingtxid amount\n"); if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); @@ -6424,7 +6424,7 @@ UniValue rewardsunlock(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 3 || params.size() < 2 ) throw runtime_error("rewardsunlock name fundingtxid [txid]\n"); if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); @@ -6452,7 +6452,7 @@ UniValue rewardslist(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 0 ) throw runtime_error("rewardslist\n"); if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); return(RewardsList()); @@ -6464,7 +6464,7 @@ UniValue rewardsinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("rewardsinfo fundingtxid\n"); if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6476,7 +6476,7 @@ UniValue gatewayslist(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 0 ) throw runtime_error("gatewayslist\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); return(GatewaysList()); @@ -6489,7 +6489,7 @@ UniValue gatewaysexternaladdress(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2) throw runtime_error("gatewaysexternaladdress bindtxid pubkey\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6504,7 +6504,7 @@ UniValue gatewaysdumpprivkey(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2) throw runtime_error("gatewaysdumpprivkey bindtxid address\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); std::string strAddress = params[1].get_str(); @@ -6529,7 +6529,7 @@ UniValue gatewaysinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("gatewaysinfo bindtxid\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6544,7 +6544,7 @@ UniValue gatewaysbind(const UniValue& params, bool fHelp) if ( fHelp || params.size() < 10 ) throw runtime_error("gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s) pubtype p2shtype wiftype [taddr]\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6584,7 +6584,7 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 9 ) throw runtime_error("gatewaysdeposit bindtxid height coin cointxid claimvout deposithex proof destpub amount\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6617,7 +6617,7 @@ UniValue gatewaysclaim(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 5 ) throw runtime_error("gatewaysclaim bindtxid coin deposittxid destpub amount\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6643,7 +6643,7 @@ UniValue gatewayswithdraw(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 4 ) throw runtime_error("gatewayswithdraw bindtxid coin withdrawpub amount\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6668,7 +6668,7 @@ UniValue gatewayspartialsign(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("gatewayspartialsign txidaddr refcoin hex\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6690,7 +6690,7 @@ UniValue gatewayscompletesigning(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("gatewayscompletesigning withdrawtxid coin hex\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); withdrawtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6712,7 +6712,7 @@ UniValue gatewaysmarkdone(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("gatewaysmarkdone completesigningtx coin\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); completetxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6733,7 +6733,7 @@ UniValue gatewayspendingdeposits(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("gatewayspendingdeposits bindtxid coin\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6747,7 +6747,7 @@ UniValue gatewayspendingwithdraws(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("gatewayspendingwithdraws bindtxid coin\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6761,7 +6761,7 @@ UniValue gatewaysprocessed(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("gatewaysprocessed bindtxid coin\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6774,7 +6774,7 @@ UniValue oracleslist(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 0 ) throw runtime_error("oracleslist\n"); if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); return(OraclesList()); @@ -6786,7 +6786,7 @@ UniValue oraclesinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("oraclesinfo oracletxid\n"); if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6799,7 +6799,7 @@ UniValue oraclesfund(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("oraclesfund oracletxid\n"); if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6819,7 +6819,7 @@ UniValue oraclesregister(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("oraclesregister oracletxid datafee\n"); if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6841,7 +6841,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("oraclessubscribe oracletxid publisher amount\n"); if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6863,7 +6863,7 @@ UniValue oraclessample(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("oraclessample oracletxid txid\n"); if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); oracletxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6877,7 +6877,7 @@ UniValue oraclessamples(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("oraclessamples oracletxid batonaddress num\n"); if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6892,7 +6892,7 @@ UniValue oraclesdata(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("oraclesdata oracletxid hexstr\n"); if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); @@ -6913,7 +6913,7 @@ UniValue oraclescreate(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("oraclescreate name description format\n"); if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = params[0].get_str(); @@ -6950,7 +6950,7 @@ UniValue FSMcreate(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("FSMcreate name states\n"); if ( ensure_CCrequirements(EVAL_FSM) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = params[0].get_str(); @@ -6970,7 +6970,7 @@ UniValue FSMlist(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 0 ) throw runtime_error("FSMlist\n"); if ( ensure_CCrequirements(EVAL_FSM) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); return(FSMList()); } @@ -6980,7 +6980,7 @@ UniValue FSMinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("FSMinfo fundingtxid\n"); if ( ensure_CCrequirements(EVAL_FSM) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); FSMtxid = Parseuint256((char *)params[0].get_str().c_str()); return(FSMInfo(FSMtxid)); } @@ -6991,7 +6991,7 @@ UniValue faucetinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 0 ) throw runtime_error("faucetinfo\n"); if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); return(FaucetInfo()); } @@ -7010,7 +7010,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) return(NSPV_spend(coinaddr,(char *)HexStr(v.scriptPubKey.begin()+1,v.scriptPubKey.end()-1).c_str(),funds)); } if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); if (funds > 0) { @@ -7030,7 +7030,7 @@ UniValue faucetget(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 0 ) throw runtime_error("faucetget\n"); if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); hex = FaucetGet(0); @@ -7059,7 +7059,7 @@ UniValue priceslist(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 0 && params.size() != 1) throw runtime_error("priceslist [all|open|closed]\n"); if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); uint32_t filter = 0; if (params.size() == 1) filter = pricesGetParam(params[0]); @@ -7074,7 +7074,7 @@ UniValue mypriceslist(const UniValue& params, bool fHelp) if (fHelp || params.size() != 0 && params.size() != 1) throw runtime_error("mypriceslist [all|open|closed]\n"); if (ensure_CCrequirements(EVAL_PRICES) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); uint32_t filter = 0; if (params.size() == 1) @@ -7090,7 +7090,7 @@ UniValue pricesinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 && params.size() != 2) throw runtime_error("pricesinfo bettxid [height]\n"); if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); bettxid = Parseuint256((char *)params[0].get_str().c_str()); height = 0; if (params.size() == 2) @@ -7104,7 +7104,7 @@ UniValue dicefund(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 6 ) throw runtime_error("dicefund name funds minbet maxbet maxodds timeoutblocks\n"); if ( ensure_CCrequirements(EVAL_DICE) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); @@ -7137,7 +7137,7 @@ UniValue diceaddfunds(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("diceaddfunds name fundingtxid amount\n"); if ( ensure_CCrequirements(EVAL_DICE) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); @@ -7165,7 +7165,7 @@ UniValue dicebet(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 4 ) throw runtime_error("dicebet name fundingtxid amount odds\n"); if ( ensure_CCrequirements(EVAL_DICE) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); @@ -7197,7 +7197,7 @@ UniValue dicefinish(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("dicefinish name fundingtxid bettxid\n"); if ( ensure_CCrequirements(EVAL_DICE) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); @@ -7232,7 +7232,7 @@ UniValue dicestatus(const UniValue& params, bool fHelp) if ( fHelp || (params.size() != 2 && params.size() != 3) ) throw runtime_error("dicestatus name fundingtxid bettxid\n"); if ( ensure_CCrequirements(EVAL_DICE) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); @@ -7280,7 +7280,7 @@ UniValue dicelist(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 0 ) throw runtime_error("dicelist\n"); if ( ensure_CCrequirements(EVAL_DICE) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); return(DiceList()); } @@ -7290,7 +7290,7 @@ UniValue diceinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("diceinfo fundingtxid\n"); if ( ensure_CCrequirements(EVAL_DICE) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); return(DiceInfo(fundingtxid)); } @@ -7301,7 +7301,7 @@ UniValue tokenlist(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 0 ) throw runtime_error("tokenlist\n"); if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); return(TokenList()); } @@ -7311,7 +7311,7 @@ UniValue tokeninfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("tokeninfo tokenid\n"); if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); @@ -7324,7 +7324,7 @@ UniValue tokenorders(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 1 ) throw runtime_error("tokenorders tokenid\n"); if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); if (params.size() == 1) { @@ -7346,7 +7346,7 @@ UniValue mytokenorders(const UniValue& params, bool fHelp) if (fHelp || params.size() > 2) throw runtime_error("mytokenorders [evalcode]\n"); if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7365,7 +7365,7 @@ UniValue tokenbalance(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 2 ) throw runtime_error("tokenbalance tokenid [pubkey]\n"); if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); LOCK(cs_main); @@ -7407,7 +7407,7 @@ UniValue tokencreate(const UniValue& params, bool fHelp) if ( fHelp || params.size() > 4 || params.size() < 2 ) throw runtime_error("tokencreate name supply [description][data]\n"); if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7467,7 +7467,7 @@ UniValue tokentransfer(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3) throw runtime_error("tokentransfer tokenid destpubkey amount\n"); if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7503,7 +7503,7 @@ UniValue tokenconvert(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 4 ) throw runtime_error("tokenconvert evalcode tokenid pubkey amount\n"); if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); evalcode = atoi(params[0].get_str().c_str()); @@ -7544,7 +7544,7 @@ UniValue tokenbid(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("tokenbid numtokens tokenid price\n"); if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); //numtokens = atoi(params[0].get_str().c_str()); @@ -7586,7 +7586,7 @@ UniValue tokencancelbid(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("tokencancelbid tokenid bidtxid\n"); if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); @@ -7611,7 +7611,7 @@ UniValue tokenfillbid(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("tokenfillbid tokenid bidtxid fillamount\n"); if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); @@ -7643,7 +7643,7 @@ UniValue tokenask(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("tokenask numtokens tokenid price\n"); if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); //numtokens = atoi(params[0].get_str().c_str()); @@ -7677,7 +7677,7 @@ UniValue tokenswapask(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 4 ) throw runtime_error("tokenswapask numtokens tokenid otherid price\n"); if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); //numtokens = atoi(params[0].get_str().c_str()); @@ -7705,7 +7705,7 @@ UniValue tokencancelask(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 2 ) throw runtime_error("tokencancelask tokenid asktxid\n"); if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); @@ -7730,7 +7730,7 @@ UniValue tokenfillask(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) throw runtime_error("tokenfillask tokenid asktxid fillunits\n"); if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); @@ -7770,7 +7770,7 @@ UniValue tokenfillswap(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 4 ) throw runtime_error("tokenfillswap tokenid otherid asktxid fillunits\n"); if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); @@ -7851,7 +7851,7 @@ UniValue heirfund(const UniValue& params, bool fHelp) if (fHelp || params.size() != 6 && params.size() != 7) throw runtime_error("heirfund txfee funds heirname heirpubkey inactivitytime memo [tokenid]\n"); if (ensure_CCrequirements(EVAL_HEIR) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7925,7 +7925,7 @@ UniValue heiradd(const UniValue& params, bool fHelp) if (fHelp || params.size() != 3) throw runtime_error("heiradd txfee funds fundingtxid\n"); if (ensure_CCrequirements(EVAL_HEIR) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7959,7 +7959,7 @@ UniValue heirclaim(const UniValue& params, bool fHelp) if (fHelp || params.size() != 3) throw runtime_error("heirclaim txfee funds fundingtxid\n"); if (ensure_CCrequirements(EVAL_HEIR) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); @@ -7984,7 +7984,7 @@ UniValue heirinfo(const UniValue& params, bool fHelp) throw runtime_error("heirinfo fundingtxid\n"); // if ( ensure_CCrequirements(EVAL_HEIR) < 0 ) - // throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + // throw runtime_error(CC_REQUIREMENTS_MSG); fundingtxid = Parseuint256((char*)params[0].get_str().c_str()); return (HeirInfo(fundingtxid)); @@ -7996,7 +7996,7 @@ UniValue heirlist(const UniValue& params, bool fHelp) throw runtime_error("heirlist\n"); // if ( ensure_CCrequirements(EVAL_HEIR) < 0 ) - // throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + // throw runtime_error(CC_REQUIREMENTS_MSG); return (HeirList()); } @@ -8009,7 +8009,7 @@ UniValue pegscreate(const UniValue& params, bool fHelp) if ( fHelp || params.size()<3) throw runtime_error("pegscreate amount N bindtxid1 [bindtxid2 ...]\n"); if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); amount = atof((char *)params[0].get_str().c_str()) * COIN + 0.00000000499999; @@ -8039,7 +8039,7 @@ UniValue pegsfund(const UniValue& params, bool fHelp) if ( fHelp || params.size()!=3) throw runtime_error("pegsfund pegstxid tokenid amount\n"); if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pegstxid = Parseuint256(params[0].get_str().c_str()); @@ -8062,7 +8062,7 @@ UniValue pegsget(const UniValue& params, bool fHelp) if ( fHelp || params.size()!=3) throw runtime_error("pegsget pegstxid tokenid amount\n"); if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pegstxid = Parseuint256(params[0].get_str().c_str()); @@ -8085,7 +8085,7 @@ UniValue pegsredeem(const UniValue& params, bool fHelp) if ( fHelp || params.size()!=2) throw runtime_error("pegsredem pegstxid tokenid\n"); if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pegstxid = Parseuint256(params[0].get_str().c_str()); @@ -8107,7 +8107,7 @@ UniValue pegsliquidate(const UniValue& params, bool fHelp) if ( fHelp || params.size()!=3) throw runtime_error("pegsliquidate pegstxid tokenid accounttxid\n"); if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pegstxid = Parseuint256(params[0].get_str().c_str()); @@ -8130,7 +8130,7 @@ UniValue pegsexchange(const UniValue& params, bool fHelp) if ( fHelp || params.size()!=3) throw runtime_error("pegsliquidate pegstxid tokenid accounttxid\n"); if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pegstxid = Parseuint256(params[0].get_str().c_str()); @@ -8153,7 +8153,7 @@ UniValue pegsaccounthistory(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("pegsaccounthistory pegstxid\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pegstxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -8167,7 +8167,7 @@ UniValue pegsaccountinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("pegsaccountinfo pegstxid\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pegstxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -8181,7 +8181,7 @@ UniValue pegsworstaccounts(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("pegsworstaccounts pegstxid\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pegstxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -8195,7 +8195,7 @@ UniValue pegsinfo(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("pegsinfo pegstxid\n"); if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); pegstxid = Parseuint256((char *)params[0].get_str().c_str()); @@ -8304,7 +8304,7 @@ UniValue opreturn_burn(const UniValue& params, bool fHelp) throw runtime_error("amount to burn, hexstring to send\n"); struct CCcontract_info *cp, C; UniValue ret(UniValue::VOBJ); if (ensure_CCrequirements(EVAL_ORACLES) < 0) - throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + throw runtime_error(CC_REQUIREMENTS_MSG); cp = CCinit(&C, EVAL_ORACLES); CAmount nAmount = AmountFromValue(params[0]); From c7ee536652548b1c26d912d40f180035f0e0a0d6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 21:55:15 -1100 Subject: [PATCH 097/171] CC_REQ_MSG --- src/cc/CCinclude.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 5882a1355..24acc03e2 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -56,7 +56,7 @@ one other technical note is that komodod has the insight-explorer extensions bui #define CC_BURNPUBKEY "02deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" #define CC_MAXVINS 1024 -#define CC_REQUIREMENTS_MSG (KOMMODO_NSPV!=0?"to use CC contracts you need to nspv_login first\n":"to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n") +#define CC_REQUIREMENTS_MSG (KOMODO_NSPV!=0?"to use CC contracts you need to nspv_login first\n":"to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n") #define SMALLVAL 0.000000000000001 #define SATOSHIDEN ((uint64_t)100000000L) From 8fc2650ff9fcb05de387318d85b822bfb68a54f2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 22:44:49 -1100 Subject: [PATCH 098/171] msgHash --- src/cryptoconditions/src/cryptoconditions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptoconditions/src/cryptoconditions.c b/src/cryptoconditions/src/cryptoconditions.c index 9bbdfbd95..3763c867b 100644 --- a/src/cryptoconditions/src/cryptoconditions.c +++ b/src/cryptoconditions/src/cryptoconditions.c @@ -274,7 +274,7 @@ int cc_verify(const struct CC *cond, const unsigned char *msg, size_t msgLength, else memcpy(msgHash, msg, 32); if (!cc_secp256k1VerifyTreeMsg32(cond, msgHash)) { - fprintf(stderr,"cc_verify error C\n"); + fprintf(stderr,"cc_verify error C msgHash.%s\n",msgHash.GetHex().c_str()); return 0; } From 1904b96d92da7fd9541eb57df5be2cc247707d62 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 22:54:25 -1100 Subject: [PATCH 099/171] Sighs --- src/cc/CCtx.cpp | 8 ++++---- src/cryptoconditions/src/cryptoconditions.c | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index c29856d1c..1351cdffb 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -280,10 +280,10 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL, utxovalues[i],consensusBranchId, &txdata); if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 ) { - //int32_t z; - //for (z=0; z<32; z++) - // fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); - //fprintf(stderr," sighash, "); + int32_t z; + for (z=0; z<32; z++) + fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); + fprintf(stderr," sighash\n"); //for (z=0; z<32; z++) // fprintf(stderr,"%02x",privkey[z]); //fprintf(stderr," signed with privkey\n"); diff --git a/src/cryptoconditions/src/cryptoconditions.c b/src/cryptoconditions/src/cryptoconditions.c index 3763c867b..1aae52c9b 100644 --- a/src/cryptoconditions/src/cryptoconditions.c +++ b/src/cryptoconditions/src/cryptoconditions.c @@ -274,7 +274,10 @@ int cc_verify(const struct CC *cond, const unsigned char *msg, size_t msgLength, else memcpy(msgHash, msg, 32); if (!cc_secp256k1VerifyTreeMsg32(cond, msgHash)) { - fprintf(stderr,"cc_verify error C msgHash.%s\n",msgHash.GetHex().c_str()); + int32_t z; + for (z=0; z<32; z++) + fprintf(stderr,"%02x",msgHash[z]); + fprintf(stderr," msgHash, cc_verify error C\n"); return 0; } From 4f9165480a59e08183ce73dc7a557b9daa1884b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 23:55:14 -1100 Subject: [PATCH 100/171] +prints --- src/main.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 79822f93c..4f61549e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1780,7 +1780,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa //fprintf(stderr,"already in mempool\n"); return state.Invalid(false, REJECT_DUPLICATE, "already in mempool"); } - +fprintf(stderr,"addmempool 0\n"); // Node operator can choose to reject tx by number of transparent inputs static_assert(std::numeric_limits::max() >= std::numeric_limits::max(), "size_t too small"); size_t limit = (size_t) GetArg("-mempooltxinputlimit", 0); @@ -1794,6 +1794,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return false; } } +fprintf(stderr,"addmempool 1\n"); auto verifier = libzcash::ProofVerifier::Strict(); if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,chainActive.LastTip()->GetHeight()+1,chainActive.LastTip()->GetMedianTimePast() + 777,0) < 0 ) @@ -1811,7 +1812,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); } - // Coinbase is only valid in a block, not as a loose transaction +fprintf(stderr,"addmempool 2\n"); + // Coinbase is only valid in a block, not as a loose transaction if (tx.IsCoinBase()) { fprintf(stderr,"AcceptToMemoryPool coinbase as individual tx\n"); @@ -1833,6 +1835,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa //fprintf(stderr,"AcceptToMemoryPool reject non-final\n"); return state.DoS(0, false, REJECT_NONSTANDARD, "non-final"); } +fprintf(stderr,"addmempool 3\n"); // Check for conflicts with in-memory transactions if (!fSkipExpiry) @@ -1861,6 +1864,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } } } +fprintf(stderr,"addmempool 4\n"); { CCoinsView dummy; @@ -1960,6 +1964,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } } } +fprintf(stderr,"addmempool 5\n"); // Grab the branch ID we expect this transaction to commit to. We don't // yet know if it does, but if the entry gets added to the mempool, then @@ -2022,6 +2027,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa LogPrint("mempool", errmsg.c_str()); return state.Error("AcceptToMemoryPool: " + errmsg); } +fprintf(stderr,"addmempool 6\n"); // Check against previous transactions // This is done last to help prevent CPU exhaustion denial-of-service attacks. @@ -2047,6 +2053,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa flag = 1; KOMODO_CONNECTING = (1<<30) + (int32_t)chainActive.LastTip()->GetHeight() + 1; } +fprintf(stderr,"addmempool 7\n"); if (!fSkipExpiry && !ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) { if ( flag != 0 ) From 80a3be3604b4d952e720e8d91bcae4aa94cf8e70 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 00:02:52 -1100 Subject: [PATCH 101/171] +print --- src/cryptoconditions/src/cryptoconditions.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cryptoconditions/src/cryptoconditions.c b/src/cryptoconditions/src/cryptoconditions.c index 1aae52c9b..12f973b97 100644 --- a/src/cryptoconditions/src/cryptoconditions.c +++ b/src/cryptoconditions/src/cryptoconditions.c @@ -272,12 +272,13 @@ int cc_verify(const struct CC *cond, const unsigned char *msg, size_t msgLength, unsigned char msgHash[32]; if (doHashMsg) sha256(msg, msgLength, msgHash); else memcpy(msgHash, msg, 32); + int32_t z; + for (z=0; z<32; z++) + fprintf(stderr,"%02x",msgHash[z]); + fprintf(stderr," msgHash msglen.%d\n",msgLength); if (!cc_secp256k1VerifyTreeMsg32(cond, msgHash)) { - int32_t z; - for (z=0; z<32; z++) - fprintf(stderr,"%02x",msgHash[z]); - fprintf(stderr," msgHash, cc_verify error C\n"); + fprintf(stderr," cc_verify error C\n"); return 0; } From 69a46d84ec13262c30bb656eef94979e4945890c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 00:26:13 -1100 Subject: [PATCH 102/171] +print --- src/cc/CCtx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 1351cdffb..c69d0e738 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -277,13 +277,13 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran return(""); } } - uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL, utxovalues[i],consensusBranchId, &txdata); + uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL,utxovalues[i],consensusBranchId, &txdata); if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 ) { int32_t z; for (z=0; z<32; z++) fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); - fprintf(stderr," sighash\n"); + fprintf(stderr," sighash [%d] %.8f %x\n",i,(double)utxovalues[i]/COIN,consensusBranchId); //for (z=0; z<32; z++) // fprintf(stderr,"%02x",privkey[z]); //fprintf(stderr," signed with privkey\n"); From 59ef159612fbb7b87bd746576bb5d85bca98898f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 00:33:02 -1100 Subject: [PATCH 103/171] +print --- src/komodo_nSPV_wallet.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 8b638c28b..0d763964a 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -437,6 +437,7 @@ int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total NSPV_utxosresp_purge(&ptr->U); NSPV_utxosresp_copy(&ptr->U,&NSPV_utxosresult); } + fprintf(stderr,"%s numutxos.%d\n",ptr->U.coinaddr,ptr->U.numutxos); memset(ptr->used,0,sizeof(ptr->used)); return(NSPV_addinputs(ptr->used,mtx,total,maxinputs,ptr->U.utxos,ptr->U.numutxos)); } else return(0); From 80fd6fee580ec4c4adfbcde5f4af5243113d6c30 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 00:58:31 -1100 Subject: [PATCH 104/171] mtx.fOverwintered = true; mtx.nExpiryHeight = 0; mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersion = SAPLING_TX_VERSION; --- src/consensus/upgrades.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/consensus/upgrades.cpp b/src/consensus/upgrades.cpp index 3cd30399f..aea806dfc 100644 --- a/src/consensus/upgrades.cpp +++ b/src/consensus/upgrades.cpp @@ -97,7 +97,10 @@ int CurrentEpoch(int nHeight, const Consensus::Params& params) { return Consensus::BASE_SPROUT; } -uint32_t CurrentEpochBranchId(int nHeight, const Consensus::Params& params) { +uint32_t CurrentEpochBranchId(int nHeight, const Consensus::Params& params) +{ + if ( KOMODO_NSPV != 0 ) + return(SAPLING_TX_VERSION); return NetworkUpgradeInfo[CurrentEpoch(nHeight, params)].nBranchId; } From c9ec6d961dcccbb7a0581e0f98adf05216c6ac01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 01:00:10 -1100 Subject: [PATCH 105/171] Include --- src/consensus/upgrades.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/consensus/upgrades.cpp b/src/consensus/upgrades.cpp index aea806dfc..3153284c0 100644 --- a/src/consensus/upgrades.cpp +++ b/src/consensus/upgrades.cpp @@ -18,7 +18,7 @@ ******************************************************************************/ #include "consensus/upgrades.h" - +#include "komodo_nSPV_defs.h" /** * General information about each network upgrade. * Ordered by Consensus::UpgradeIndex. @@ -100,7 +100,7 @@ int CurrentEpoch(int nHeight, const Consensus::Params& params) { uint32_t CurrentEpochBranchId(int nHeight, const Consensus::Params& params) { if ( KOMODO_NSPV != 0 ) - return(SAPLING_TX_VERSION); + return(NSPV_BRANCHID); return NetworkUpgradeInfo[CurrentEpoch(nHeight, params)].nBranchId; } From 8910b7c56f19a544ba2a2a21a8aa4054af64b404 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 01:01:32 -1100 Subject: [PATCH 106/171] #define NSPV_BRANCHID 0x76b809bb --- src/consensus/upgrades.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/consensus/upgrades.cpp b/src/consensus/upgrades.cpp index 3153284c0..786e58510 100644 --- a/src/consensus/upgrades.cpp +++ b/src/consensus/upgrades.cpp @@ -18,7 +18,9 @@ ******************************************************************************/ #include "consensus/upgrades.h" -#include "komodo_nSPV_defs.h" +extern int32_t KOMODO_NSPV; +#define NSPV_BRANCHID 0x76b809bb + /** * General information about each network upgrade. * Ordered by Consensus::UpgradeIndex. From aa95a58f26bdd18f0d14c4b396e6fa8fc23cc331 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 01:14:25 -1100 Subject: [PATCH 107/171] Txheight --- src/cc/CCtx.cpp | 8 ++++---- src/komodo_nSPV_wallet.h | 1 - src/main.cpp | 26 ++++++++++++++++---------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index c69d0e738..768e34fe7 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -280,10 +280,10 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL,utxovalues[i],consensusBranchId, &txdata); if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 ) { - int32_t z; - for (z=0; z<32; z++) - fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); - fprintf(stderr," sighash [%d] %.8f %x\n",i,(double)utxovalues[i]/COIN,consensusBranchId); + //int32_t z; + //for (z=0; z<32; z++) + // fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); + //fprintf(stderr," sighash [%d] %.8f %x\n",i,(double)utxovalues[i]/COIN,consensusBranchId); //for (z=0; z<32; z++) // fprintf(stderr,"%02x",privkey[z]); //fprintf(stderr," signed with privkey\n"); diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 0d763964a..df0cb9a8d 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -446,7 +446,6 @@ int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total void NSPV_utxos2CCunspents(struct NSPV_utxosresp *ptr,std::vector > &outputs) { CAddressUnspentKey key; CAddressUnspentValue value; int32_t i,type; uint160 hashBytes; std::string addrstr(ptr->coinaddr); - fprintf(stderr,"in converter\n"); if ( ptr->utxos != NULL && ptr->numutxos > 0 ) { CBitcoinAddress address(addrstr); diff --git a/src/main.cpp b/src/main.cpp index 4f61549e2..4e2e4a9c4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1780,7 +1780,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa //fprintf(stderr,"already in mempool\n"); return state.Invalid(false, REJECT_DUPLICATE, "already in mempool"); } -fprintf(stderr,"addmempool 0\n"); +//fprintf(stderr,"addmempool 0\n"); // Node operator can choose to reject tx by number of transparent inputs static_assert(std::numeric_limits::max() >= std::numeric_limits::max(), "size_t too small"); size_t limit = (size_t) GetArg("-mempooltxinputlimit", 0); @@ -1794,7 +1794,7 @@ fprintf(stderr,"addmempool 0\n"); return false; } } -fprintf(stderr,"addmempool 1\n"); +//fprintf(stderr,"addmempool 1\n"); auto verifier = libzcash::ProofVerifier::Strict(); if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,chainActive.LastTip()->GetHeight()+1,chainActive.LastTip()->GetMedianTimePast() + 777,0) < 0 ) @@ -1812,7 +1812,7 @@ fprintf(stderr,"addmempool 1\n"); { return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); } -fprintf(stderr,"addmempool 2\n"); +//fprintf(stderr,"addmempool 2\n"); // Coinbase is only valid in a block, not as a loose transaction if (tx.IsCoinBase()) { @@ -1835,7 +1835,7 @@ fprintf(stderr,"addmempool 2\n"); //fprintf(stderr,"AcceptToMemoryPool reject non-final\n"); return state.DoS(0, false, REJECT_NONSTANDARD, "non-final"); } -fprintf(stderr,"addmempool 3\n"); +//fprintf(stderr,"addmempool 3\n"); // Check for conflicts with in-memory transactions if (!fSkipExpiry) @@ -1864,7 +1864,7 @@ fprintf(stderr,"addmempool 3\n"); } } } -fprintf(stderr,"addmempool 4\n"); +//fprintf(stderr,"addmempool 4\n"); { CCoinsView dummy; @@ -1964,7 +1964,7 @@ fprintf(stderr,"addmempool 4\n"); } } } -fprintf(stderr,"addmempool 5\n"); +//fprintf(stderr,"addmempool 5\n"); // Grab the branch ID we expect this transaction to commit to. We don't // yet know if it does, but if the entry gets added to the mempool, then @@ -2027,7 +2027,7 @@ fprintf(stderr,"addmempool 5\n"); LogPrint("mempool", errmsg.c_str()); return state.Error("AcceptToMemoryPool: " + errmsg); } -fprintf(stderr,"addmempool 6\n"); +//fprintf(stderr,"addmempool 6\n"); // Check against previous transactions // This is done last to help prevent CPU exhaustion denial-of-service attacks. @@ -2053,7 +2053,7 @@ fprintf(stderr,"addmempool 6\n"); flag = 1; KOMODO_CONNECTING = (1<<30) + (int32_t)chainActive.LastTip()->GetHeight() + 1; } -fprintf(stderr,"addmempool 7\n"); +//fprintf(stderr,"addmempool 7\n"); if (!fSkipExpiry && !ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) { if ( flag != 0 ) @@ -2229,8 +2229,14 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo memset(&hashBlock,0,sizeof(hashBlock)); if ( KOMODO_NSPV != 0 ) { - int64_t rewardsum = 0; int32_t retval,vout = 0; - retval = NSPV_gettransaction(1,vout,hash,0,txOut,0,0,rewardsum); + int64_t rewardsum = 0; int32_t i,retval,txheight = 0,vout = 0; + for (i=0; i Date: Fri, 12 Jul 2019 01:35:59 -1100 Subject: [PATCH 108/171] ->myGetTransaction for nSPV virtualisation --- src/cc/CCassetstx.cpp | 12 ++++---- src/cc/CCtokens.cpp | 8 ++--- src/cc/auction.cpp | 2 +- src/cc/cclib.cpp | 4 +-- src/cc/channels.cpp | 24 +++++++-------- src/cc/dilithium.c | 2 +- src/cc/eval.cpp | 2 +- src/cc/fsm.cpp | 2 +- src/cc/gateways.cpp | 66 ++++++++++++++++++++-------------------- src/cc/heir.cpp | 6 ++-- src/cc/import.cpp | 6 ++-- src/cc/importgateway.cpp | 58 +++++++++++++++++------------------ src/cc/lotto.cpp | 8 ++--- src/cc/marmara.cpp | 18 +++++------ src/cc/oracles.cpp | 26 ++++++++-------- src/cc/payments.cpp | 2 +- src/cc/pegs.cpp | 48 ++++++++++++++--------------- src/cc/prices.cpp | 4 +-- src/cc/rewards.cpp | 12 ++++---- src/cc/sudoku.cpp | 6 ++-- src/rpc/crosschain.cpp | 4 +-- 21 files changed, 160 insertions(+), 160 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 0929591ff..6788cbf1f 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -39,7 +39,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode) txid = it->first.txhash; LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "addOrders() checking txid=" << txid.GetHex() << std::endl); - if ( GetTransaction(txid, ordertx, hashBlock, false) != 0 ) + if ( myGetTransaction(txid, ordertx, hashBlock) != 0 ) { // for logging: funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); if (ordertx.vout.size() > 0 && (funcid = DecodeAssetTokenOpRet(ordertx.vout[ordertx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) @@ -273,7 +273,7 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in fprintf(stderr,"negative bidamount %lld, pricetotal %lld\n", (long long)bidamount, (long long)pricetotal); return(""); } - if (GetTransaction(assetid, vintx, hashBlock, false) == 0) + if (myGetTransaction(assetid, vintx, hashBlock) == 0) { fprintf(stderr,"cant find assetid\n"); return(""); @@ -470,7 +470,7 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) + if (myGetTransaction(bidtxid, vintx, hashBlock) != 0) { std::vector vopretNonfungible; GetNonfungibleData(assetid, vopretNonfungible); @@ -520,7 +520,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) + if (myGetTransaction(asktxid, vintx, hashBlock) != 0) { std::vector vopretNonfungible; GetNonfungibleData(assetid, vopretNonfungible); @@ -594,7 +594,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); - if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) + if (myGetTransaction(bidtxid, vintx, hashBlock) != 0) { bidamount = vintx.vout[bidvout].nValue; SetAssetOrigpubkey(origpubkey, origprice, vintx); @@ -697,7 +697,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a //if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) //{ //mask = ~((1LL << mtx.vin.size()) - 1); - if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) + if (myGetTransaction(asktxid, vintx, hashBlock) != 0) { orig_assetoshis = vintx.vout[askvout].nValue; SetAssetOrigpubkey(origpubkey, total_nValue, vintx); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 0319af622..289549c36 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -654,7 +654,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C if (ivin != mtx.vin.size()) // that is, the tx.vout is already added to mtx.vin (in some previous calls) continue; - if (GetTransaction(vintxid, vintx, hashBlock, false) != 0) + if (myGetTransaction(vintxid, vintx, hashBlock) != 0) { Getscriptaddress(destaddr, vintx.vout[vout].scriptPubKey); if (strcmp(destaddr, tokenaddr) != 0 && @@ -920,7 +920,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid) // CCerror = strprintf("obsolete, cannot return correct value without eval"); // return 0; - if (GetTransaction(tokenid, tokentx, hashBlock, false) == 0) + if (myGetTransaction(tokenid, tokentx, hashBlock) == 0) { LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "cant find tokenid" << std::endl); CCerror = strprintf("cant find tokenid"); @@ -945,7 +945,7 @@ UniValue TokenInfo(uint256 tokenid) cpTokens = CCinit(&tokensCCinfo, EVAL_TOKENS); - if( !GetTransaction(tokenid, tokenbaseTx, hashBlock, false) ) + if( !myGetTransaction(tokenid, tokenbaseTx, hashBlock) ) { fprintf(stderr, "TokenInfo() cant find tokenid\n"); result.push_back(Pair("result", "error")); @@ -1031,7 +1031,7 @@ UniValue TokenList() cp = CCinit(&C, EVAL_TOKENS); auto addTokenId = [&](uint256 txid) { - if (GetTransaction(txid, vintx, hashBlock, false) != 0) { + if (myGetTransaction(txid, vintx, hashBlock) != 0) { if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description) != 0) { result.push_back(txid.GetHex()); } diff --git a/src/cc/auction.cpp b/src/cc/auction.cpp index 7521256c7..88d5134af 100644 --- a/src/cc/auction.cpp +++ b/src/cc/auction.cpp @@ -131,7 +131,7 @@ int64_t AddAuctionInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu // prevent dup if ( it->second.satoshis < 1000000 ) continue; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( (nValue= IsAuctionvout(cp,vintx,(int32_t)it->first.index)) > 0 ) { diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index ee52dadcf..dddd59f59 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -520,7 +520,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK if ( it->second.satoshis < threshold || it->second.satoshis == txfee ) continue; // no need to prevent dup - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) >= 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { @@ -550,7 +550,7 @@ int64_t AddCClibtxfee(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); if ( it->second.satoshis < txfee ) continue; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( (nValue= IsCClibvout(cp,vintx,vout,coinaddr)) != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 2d161675c..f88546b6e 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -416,7 +416,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C else marker=2; for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { - if ( (int32_t)it->first.index==0 && GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0) + if ( (int32_t)it->first.index==0 && myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0) { if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==openTx.GetHash() || tx.GetHash()==openTx.GetHash()) && IsChannelsMarkervout(cp,tx,marker==1?srcpub:destpub,marker)>0 && @@ -517,7 +517,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) + if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0) { CCerror = strprintf("invalid channel open txid"); LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -555,7 +555,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount)>=0) { numpayments=amount/payment; - if (GetTransaction(prevtxid,prevTx,hashblock,false) != 0 && (numvouts=prevTx.vout.size()) > 0 && + if (myGetTransaction(prevtxid,prevTx,hashblock) != 0 && (numvouts=prevTx.vout.size()) > 0 && ((funcid = DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, prevdepth, param2, param3)) != 0) && (funcid == 'P' || funcid=='O')) { @@ -642,7 +642,7 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) + if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0) { CCerror = strprintf("invalid channel open txid"); LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -702,7 +702,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (GetTransaction(closetxid,channelCloseTx,hashblock,false) == 0) + if (myGetTransaction(closetxid,channelCloseTx,hashblock) == 0) { CCerror = strprintf("invalid channel close txid"); LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -726,7 +726,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); return (""); } - if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) + if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0) { CCerror = strprintf("invalid channel open txid"); LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -754,7 +754,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) { if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds>0) { - if ((GetTransaction(prevtxid,prevTx,hashblock,false) != 0) && (numvouts=prevTx.vout.size()) > 0 && + if ((myGetTransaction(prevtxid,prevTx,hashblock) != 0) && (numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, param1, param2, param3) != 0) { mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,mypk)); @@ -799,7 +799,7 @@ UniValue ChannelsList() txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second; - if ( (vout == 1 || vout == 2) && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) + if ( (vout == 1 || vout == 2) && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 ) { if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O') { @@ -822,7 +822,7 @@ UniValue ChannelsInfo(uint256 channeltxid) cp = CCinit(&C,EVAL_CHANNELS); mypk = pubkey2pk(Mypubkey()); - if (GetTransaction(channeltxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && + if (myGetTransaction(channeltxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,opentxid,srcpub,destpub,param1,param2,param3) == 'O')) { GetCCaddress(cp,CCaddr,mypk); @@ -845,7 +845,7 @@ UniValue ChannelsInfo(uint256 channeltxid) SetCCtxids(addressIndex,CCaddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { - if (GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) + if (myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 ) if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==channeltxid || tx.GetHash()==channeltxid)) txids.push_back(it->first.txhash); } @@ -861,7 +861,7 @@ UniValue ChannelsInfo(uint256 channeltxid) for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { txid=*it; - if (txid!=prevtxid && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) + if (txid!=prevtxid && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 ) { UniValue obj(UniValue::VOBJ); if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O' && tx.GetHash()==channeltxid) @@ -870,7 +870,7 @@ UniValue ChannelsInfo(uint256 channeltxid) } else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,opentxid,srcpub,destpub,param1,param2,param3) == 'P' && opentxid==channeltxid) { - if (GetTransaction(opentxid,opentx,hashBlock,false) != 0 && (numvouts=opentx.vout.size()) > 0 && + if (myGetTransaction(opentxid,opentx,hashBlock) != 0 && (numvouts=opentx.vout.size()) > 0 && DecodeChannelsOpRet(opentx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,numpayments,payment,hashchain) == 'O') { Getscriptaddress(str,tx.vout[3].scriptPubKey); diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 5dfa1deda..4a3813e61 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3354,7 +3354,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); if ( it->second.satoshis < threshold || it->second.satoshis == DILITHIUM_TXFEE ) continue; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && (numvouts= vintx.vout.size()) > 1 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 ) { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index c580753cf..86065204a 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -129,7 +129,7 @@ bool Eval::GetTxUnconfirmed(const uint256 &hash, CTransaction &txOut, uint256 &h { return(myGetTransaction(hash, txOut,hashBlock)); /*if (!myGetTransaction(hash, txOut,hashBlock)) { - return(GetTransaction(hash, txOut,hashBlock)); + return(myGetTransaction(hash, txOut,hashBlock)); } else return(true);*/ } diff --git a/src/cc/fsm.cpp b/src/cc/fsm.cpp index e44f85e47..dca2efd2d 100644 --- a/src/cc/fsm.cpp +++ b/src/cc/fsm.cpp @@ -133,7 +133,7 @@ int64_t AddFSMInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey // prevent dup if ( it->second.satoshis < 1000000 ) continue; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock,false) != 0 ) { if ( (nValue= IsFSMvout(cp,vintx,(int32_t)it->first.index)) > 0 ) { diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 00c80082b..c25a6e001 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -823,7 +823,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP std::vector > unspentOutputs; std::string refcoin,tmprefcoin; CPubKey withdrawpub,destpub; uint256 tokenid,txid,oracletxid,tmpbindtxid,tmptokenid,deposittxid,hashBlock; - if ( GetTransaction(bindtxid,bindtx,hashBlock,false) != 0 ) + if ( myGetTransaction(bindtxid,bindtx,hashBlock) != 0 ) { if ((numvouts=bindtx.vout.size())!=0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,refcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B') { @@ -839,7 +839,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP { txid = it->first.txhash; vout = (int32_t)it->first.index; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { funcid=DecodeGatewaysOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey); if ((vout==0 && funcid=='B' && bindtxid==txid && total != 0 && maxinputs != 0) || @@ -932,7 +932,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if ( GetTransaction(oracletxid,oracletx,hashBlock,false) == 0 || (numvouts= oracletx.vout.size()) <= 0 ) + if ( myGetTransaction(oracletxid,oracletx,hashBlock) == 0 || (numvouts= oracletx.vout.size()) <= 0 ) { CCerror = strprintf("cant find oracletxid %s",uint256_str(str,oracletxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -982,7 +982,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: txfee = 10000; mypk = pubkey2pk(Mypubkey()); LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "GatewaysDeposit ht." << height << " " << refcoin << " " << (double)amount/COIN << " numpks." << (int32_t)pubkeys.size() << std::endl); - if ( GetTransaction(bindtxid,bindtx,hashBlock,false) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,bindtx,hashBlock) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1059,7 +1059,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui txfee = 10000; mypk = pubkey2pk(Mypubkey()); gatewayspk = GetUnspendable(cp,0); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1077,7 +1077,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if ( GetTransaction(deposittxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(deposittxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find deposittxid %s",uint256_str(str,bindtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1138,7 +1138,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin mypk = pubkey2pk(Mypubkey()); gatewayspk = GetUnspendable(cp, 0); - if( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1164,7 +1164,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; K=0; - if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 && (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P')) { if (funcid=='W' && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' @@ -1176,7 +1176,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin } else if (funcid=='P' && DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)=='P' && - GetTransaction(withdrawtxid,tx,hashBlock,false)!=0 && (numvouts=tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' + myGetTransaction(withdrawtxid,tx,hashBlock)!=0 && (numvouts=tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' && refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid) { CCerror = strprintf("unable to create withdraw, another withdraw pending"); @@ -1220,7 +1220,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc txfee = 10000; mypk = pubkey2pk(Mypubkey()); gatewayspk = GetUnspendable(cp,0); - if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 + if (myGetTransaction(lasttxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0 || (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) { CCerror = strprintf("can't find last tx %s",uint256_str(str,lasttxid)); @@ -1242,7 +1242,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1264,7 +1264,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts= tmptx.vout.size())<=0) + else if (myGetTransaction(withdrawtxid,tmptx,hashBlock)==0 || (numvouts= tmptx.vout.size())<=0) { CCerror = strprintf("can't find withdraw tx %s",uint256_str(str,withdrawtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1283,7 +1283,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1320,7 +1320,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string gatewayspk = GetUnspendable(cp,0); if ( txfee == 0 ) txfee = 10000; - if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 + if (myGetTransaction(lasttxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0 || (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) { CCerror = strprintf("invalid last txid %s",uint256_str(str,lasttxid)); @@ -1336,7 +1336,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1364,7 +1364,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())==0) + else if (myGetTransaction(withdrawtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())==0) { CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1382,7 +1382,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1418,7 +1418,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref mypk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) txfee = 10000; - if (GetTransaction(completetxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0) + if (myGetTransaction(completetxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0) { CCerror = strprintf("invalid completesigning txid %s",uint256_str(str,completetxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1436,7 +1436,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())==0) + else if (myGetTransaction(withdrawtxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())==0) { CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1448,7 +1448,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(bindtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + else if (myGetTransaction(bindtxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1485,7 +1485,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) mypk = pubkey2pk(Mypubkey()); gatewayspk = GetUnspendable(cp,0); _GetCCaddress(coinaddr,EVAL_GATEWAYS,mypk); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); @@ -1503,7 +1503,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && + if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,publishers,txids,height,cointxid,claimvout,hex,proof,destpub,amount) == 'D' && tmpbindtxid==bindtxid && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) { @@ -1540,7 +1540,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) gatewayspk = GetUnspendable(cp,0); _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); GetTokensCCaddress(cp,tokensaddr,gatewayspk); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); @@ -1567,7 +1567,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; K=0; - if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 && (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P') && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) { if (funcid=='W') @@ -1576,7 +1576,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) } else if (funcid=='P') { - if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)!='P' || GetTransaction(withdrawtxid,tx,hashBlock,false)==0 + if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)!='P' || myGetTransaction(withdrawtxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0 || DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin || tmptokenid!=tokenid || tmpbindtxid!=bindtxid) continue; @@ -1628,7 +1628,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) mypk = pubkey2pk(Mypubkey()); gatewayspk = GetUnspendable(cp,0); _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); @@ -1654,10 +1654,10 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 && DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) { - if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 + if (myGetTransaction(withdrawtxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount) == 'W' || refcoin!=coin || tmptokenid!=tokenid) { UniValue obj(UniValue::VOBJ); @@ -1689,7 +1689,7 @@ UniValue GatewaysList() for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( vintx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 ) { @@ -1706,7 +1706,7 @@ UniValue GatewaysExternalAddress(uint256 bindtxid,CPubKey pubkey) std::string coin; int64_t numvouts,totalsupply; char str[65],addr[65],depositaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector msigpubkeys; cp = CCinit(&C,EVAL_GATEWAYS); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); @@ -1730,7 +1730,7 @@ UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey key) std::string coin,priv; int64_t numvouts,totalsupply; char str[65],addr[65],depositaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector msigpubkeys; cp = CCinit(&C,EVAL_GATEWAYS); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); @@ -1759,7 +1759,7 @@ UniValue GatewaysInfo(uint256 bindtxid) cp = CCinit(&C,EVAL_GATEWAYS); Gatewayspk = GetUnspendable(cp,0); GetTokensCCaddress(cp,gatewaystokens,Gatewayspk); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { result.push_back(Pair("result","error")); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); @@ -1771,7 +1771,7 @@ UniValue GatewaysInfo(uint256 bindtxid) result.push_back(Pair("error",strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()))); return(result); } - if ( GetTransaction(bindtxid,tx,hashBlock,false) != 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) != 0 ) { result.push_back(Pair("result","success")); result.push_back(Pair("name","Gateways")); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index e047d1ab1..fc3a2f2fd 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -531,7 +531,7 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, //std::cerr << "Add1of2AddressInputs() txid=" << txid.GetHex() << std::endl; - if (GetTransaction(txid, heirtx, hashBlock, false) != 0) { + if (myGetTransaction(txid, heirtx, hashBlock) != 0) { uint256 tokenid; uint256 fundingTxidInOpret; uint8_t hasHeirSpendingBegunDummy; @@ -579,7 +579,7 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info CTransaction heirtx; // TODO: check all funding tx should contain unspendable markers - if (GetTransaction(txid, heirtx, hashBlock, false) && heirtx.vout.size() > 0) { + if (myGetTransaction(txid, heirtx, hashBlock) && heirtx.vout.size() > 0) { uint256 tokenid; uint256 fundingTxidInOpret; uint8_t hasHeirSpendingBegunDummy; @@ -1232,7 +1232,7 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result) //std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; CTransaction fundingtx; - if (GetTransaction(txid, fundingtx, hashBlock, false)) { + if (myGetTransaction(txid, fundingtx, hashBlock)) { CPubKey ownerPubkey, heirPubkey; std::string heirName, memo; int64_t inactivityTimeSec; diff --git a/src/cc/import.cpp b/src/cc/import.cpp index aa2ea5d11..4a1978e8d 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -367,7 +367,7 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string return(-1); } // check for valid burn from external coin blockchain and if valid return(0); - if (GetTransaction(bindtxid, bindtx, hashBlock, false) == 0 || (numvouts = bindtx.vout.size()) <= 0) + if (myGetTransaction(bindtxid, bindtx, hashBlock) == 0 || (numvouts = bindtx.vout.size()) <= 0) { LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport cant find bindtxid=" << bindtxid.GetHex() << std::endl); return(-1); @@ -397,7 +397,7 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport bindtx not yet confirmed/notarized" << std::endl); return(-1); } - else if (GetTransaction(oracletxid, oracletx, hashBlock, false) == 0 || (numvouts = oracletx.vout.size()) <= 0) + else if (myGetTransaction(oracletxid, oracletx, hashBlock) == 0 || (numvouts = oracletx.vout.size()) <= 0) { LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport cant find oracletxid=" << oracletxid.GetHex() << std::endl); return(-1); @@ -417,7 +417,7 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; - if ( GetTransaction(txid,regtx,hashBlock,false) != 0 && regtx.vout.size() > 0 + if ( myGetTransaction(txid,regtx,hashBlock) != 0 && regtx.vout.size() > 0 && DecodeOraclesOpRet(regtx.vout[regtx.vout.size()-1].scriptPubKey,tmporacletxid,regpk,datafee) == 'R' && oracletxid == tmporacletxid ) { pubkeys.push_back(regpk); diff --git a/src/cc/importgateway.cpp b/src/cc/importgateway.cpp index eff7bc287..e5590bb3d 100644 --- a/src/cc/importgateway.cpp +++ b/src/cc/importgateway.cpp @@ -525,7 +525,7 @@ std::string ImportGatewayBind(uint64_t txfee,std::string coin,uint256 oracletxid LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if ( GetTransaction(oracletxid,oracletx,hashBlock,false) == 0 || (numvouts= oracletx.vout.size()) <= 0 ) + if ( myGetTransaction(oracletxid,oracletx,hashBlock) == 0 || (numvouts= oracletx.vout.size()) <= 0 ) { CCerror = strprintf("cant find oracletxid %s",uint256_str(str,oracletxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -581,7 +581,7 @@ std::string ImportGatewayDeposit(uint64_t txfee,uint256 bindtxid,int32_t height, return std::string(""); } LOGSTREAM("importgateway",CCLOG_DEBUG1, stream << "ImportGatewayDeposit ht." << height << " " << refcoin << " " << (double)amount/COIN << " numpks." << (int32_t)pubkeys.size() << std::endl); - if ( GetTransaction(bindtxid,bindtx,hashBlock,false) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,bindtx,hashBlock) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -651,7 +651,7 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re mypk = pubkey2pk(Mypubkey()); importgatewaypk = GetUnspendable(cp, 0); - if( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -677,7 +677,7 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; K=0; - if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 && (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P')) { if (funcid=='W' && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' @@ -689,7 +689,7 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re } else if (funcid=='P' && DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)=='P' && - GetTransaction(withdrawtxid,tx,hashBlock,false)!=0 && (numvouts=tx.vout.size())>0 && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' + myGetTransaction(withdrawtxid,tx,hashBlock)!=0 && (numvouts=tx.vout.size())>0 && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' && refcoin==coin && tmpbindtxid==bindtxid) { CCerror = strprintf("unable to create withdraw, another withdraw pending"); @@ -722,7 +722,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string txfee = 10000; mypk = pubkey2pk(Mypubkey()); importgatewaypk = GetUnspendable(cp,0); - if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 + if (myGetTransaction(lasttxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0 || (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) { CCerror = strprintf("can't find last tx %s",uint256_str(str,lasttxid)); @@ -744,7 +744,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -766,7 +766,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts= tmptx.vout.size())<=0) + else if (myGetTransaction(withdrawtxid,tmptx,hashBlock)==0 || (numvouts= tmptx.vout.size())<=0) { CCerror = strprintf("can't find withdraw tx %s",uint256_str(str,withdrawtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -785,7 +785,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -822,7 +822,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st importgatewaypk = GetUnspendable(cp,0); if ( txfee == 0 ) txfee = 10000; - if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 + if (myGetTransaction(lasttxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0 || (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) { CCerror = strprintf("invalid last txid %s",uint256_str(str,lasttxid)); @@ -838,7 +838,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -866,7 +866,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())==0) + else if (myGetTransaction(withdrawtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())==0) { CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -884,7 +884,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) + else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -920,7 +920,7 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin mypk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) txfee = 10000; - if (GetTransaction(completetxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0) + if (myGetTransaction(completetxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0) { CCerror = strprintf("invalid completesigning txid %s",uint256_str(str,completetxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -938,7 +938,7 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())==0) + else if (myGetTransaction(withdrawtxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())==0) { CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -950,7 +950,7 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - else if (GetTransaction(bindtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + else if (myGetTransaction(bindtxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -987,7 +987,7 @@ UniValue ImportGatewayPendingDeposits(uint256 bindtxid,std::string refcoin) mypk = pubkey2pk(Mypubkey()); importgatewaypk = GetUnspendable(cp,0); _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,mypk); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -1005,7 +1005,7 @@ UniValue ImportGatewayPendingDeposits(uint256 bindtxid,std::string refcoin) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && + if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && DecodeImportGatewayDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,publishers,txids,height,burntxid,claimvout,hex,proof,destpub,amount) == 'D' && tmpbindtxid==bindtxid && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) { @@ -1041,7 +1041,7 @@ UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin) mypk = pubkey2pk(Mypubkey()); importgatewaypk = GetUnspendable(cp,0); _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,importgatewaypk); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -1068,7 +1068,7 @@ UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin) vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; K=0; - if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 && (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P') && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) { if (funcid=='W') @@ -1077,7 +1077,7 @@ UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin) } else if (funcid=='P') { - if (DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)!='P' || GetTransaction(withdrawtxid,tx,hashBlock,false)==0 + if (DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)!='P' || myGetTransaction(withdrawtxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0 || DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin || tmpbindtxid!=bindtxid) continue; @@ -1129,7 +1129,7 @@ UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin) mypk = pubkey2pk(Mypubkey()); importgatewaypk = GetUnspendable(cp,0); _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,importgatewaypk); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -1155,10 +1155,10 @@ UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && + if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 && DecodeImportGatewayCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) { - if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 + if (myGetTransaction(withdrawtxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,withdrawpub,amount) == 'W' || refcoin!=coin) { UniValue obj(UniValue::VOBJ); @@ -1192,7 +1192,7 @@ UniValue ImportGatewayList() for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( vintx.vout.size() > 0 && DecodeImportGatewayBindOpRet(burnaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 ) { @@ -1209,7 +1209,7 @@ UniValue ImportGatewayExternalAddress(uint256 bindtxid,CPubKey pubkey) std::string coin; int64_t numvouts; char str[65],addr[65],burnaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector msigpubkeys; cp = CCinit(&C,EVAL_IMPORTGATEWAY); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -1233,7 +1233,7 @@ UniValue ImportGatewayDumpPrivKey(uint256 bindtxid,CKey key) std::string coin,priv; int64_t numvouts; char str[65],addr[65],burnaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector msigpubkeys; cp = CCinit(&C,EVAL_IMPORTGATEWAY); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -1262,7 +1262,7 @@ UniValue ImportGatewayInfo(uint256 bindtxid) cp = CCinit(&C,EVAL_IMPORTGATEWAY); ImportGatewaypk = GetUnspendable(cp,0); GetTokensCCaddress(cp,gatewaystokens,ImportGatewaypk); - if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 ) { CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); @@ -1274,7 +1274,7 @@ UniValue ImportGatewayInfo(uint256 bindtxid) LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if ( GetTransaction(bindtxid,tx,hashBlock,false) != 0 ) + if ( myGetTransaction(bindtxid,tx,hashBlock) != 0 ) { result.push_back(Pair("result","success")); result.push_back(Pair("name","ImportGateway")); diff --git a/src/cc/lotto.cpp b/src/cc/lotto.cpp index f873b3881..e8466bd88 100644 --- a/src/cc/lotto.cpp +++ b/src/cc/lotto.cpp @@ -173,7 +173,7 @@ int64_t AddLottoInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK // prevent dup if ( it->second.satoshis < COIN ) continue; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( (nValue= IsLottovout(cp,vintx,(int32_t)it->first.index)) > 0 ) { @@ -214,7 +214,7 @@ int64_t LottoPlanFunds(uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,u { txid = it->first.txhash; vout = (int32_t)it->first.index; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) { // need to implement this! if ( (funcid= DecodeLottoOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) == 'F' || funcid == 'T' ) { @@ -233,7 +233,7 @@ int64_t LottoPlanFunds(uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,u UniValue LottoInfo(uint256 lottoid) { UniValue result(UniValue::VOBJ); uint256 hashBlock,hentropy; CTransaction vintx; uint64_t lockedfunds,sbits; int32_t ticketsize,odds,firstheight,period; CPubKey lottopk; struct CCcontract_info *cp,C; char str[67],numstr[65]; - if ( GetTransaction(lottoid,vintx,hashBlock,false) == 0 ) + if ( myGetTransaction(lottoid,vintx,hashBlock) == 0 ) { fprintf(stderr,"cant find lottoid\n"); result.push_back(Pair("result","error")); @@ -270,7 +270,7 @@ UniValue LottoList() for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( vintx.vout.size() > 0 && DecodeLottoFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,ticketsize,odds,firstheight,period,hentropy) == 'F' ) { diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f0d55eaf4..e28566079 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -360,7 +360,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, txid = it->first.txhash; vout = (int32_t)it->first.index; //fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout); - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( vintx.IsCoinBase() != 0 && vintx.vout.size() == 2 && vintx.vout[1].nValue == 0 ) { @@ -399,7 +399,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, vout = (int32_t)it->first.index; if ( it->second.satoshis < threshold ) continue; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' ) { @@ -468,7 +468,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) vout = (int32_t)it->first.index; if ( (nValue= it->second.satoshis) < threshold ) continue; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' ) { @@ -516,7 +516,7 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx) uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector pubkeys; struct CCcontract_info *cp,C; uint64_t txfee; txfee = 10000; vout = mtx.vin[0].prevout.n; - if ( GetTransaction(mtx.vin[0].prevout.hash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts ) + if ( myGetTransaction(mtx.vin[0].prevout.hash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts ) { cp = CCinit(&C,EVAL_MARMARA); mypk = pubkey2pk(Mypubkey()); @@ -553,7 +553,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) height = chainActive.LastTip()->GetHeight(); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 ) { - if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && (numvouts= batontx.vout.size()) > 1 ) + if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && (numvouts= batontx.vout.size()) > 1 ) { if ( (funcid= MarmaraDecodeLoopOpret(batontx.vout[numvouts-1].scriptPubKey,refcreatetxid,pk,refamount,refmatures,refcurrency)) != 0 ) { @@ -593,7 +593,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) pubkeys.push_back(mypk); for (i=1; i 1 ) + if ( myGetTransaction(creditloop[i],tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) { @@ -674,7 +674,7 @@ int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuanc txid = it->first.txhash; vout = (int32_t)it->first.index; //fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout); - if ( vout == 1 && GetTransaction(txid,tx,hashBlock,false) != 0 ) + if ( vout == 1 && myGetTransaction(txid,tx,hashBlock) != 0 ) { if ( tx.IsCoinBase() == 0 && (numvouts= tx.vout.size()) > 2 && tx.vout[numvouts - 1].nValue == 0 ) { @@ -814,7 +814,7 @@ UniValue MarmaraCreditloop(uint256 txid) cp = CCinit(&C,EVAL_MARMARA); if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { - if ( GetTransaction(batontxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + if ( myGetTransaction(batontxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { result.push_back(Pair("result",(char *)"success")); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); @@ -886,7 +886,7 @@ UniValue MarmaraCreditloop(uint256 txid) } for (i=0; i 1 ) + if ( myGetTransaction(creditloop[i],tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) { diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index bdd01ccfa..5056ccade 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -759,7 +759,7 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,uint txid = it->first.txhash; vout = (int32_t)it->first.index; //char str[65]; fprintf(stderr,"oracle check %s/v%d\n",uint256_str(str,txid),vout); - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && (numvouts=vintx.vout.size()-1)>0) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 && (numvouts=vintx.vout.size()-1)>0) { if ((funcid=DecodeOraclesOpRet(vintx.vout[numvouts].scriptPubKey,tmporacletxid,tmppk,tmpnum))!=0 && (funcid=='S' || funcid=='D')) { @@ -795,7 +795,7 @@ int64_t LifetimeOraclesFunds(struct CCcontract_info *cp,uint256 oracletxid,CPubK for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; - if ( GetTransaction(txid,subtx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,subtx,hashBlock) != 0 ) { if ( subtx.vout.size() > 0 && DecodeOraclesOpRet(subtx.vout[subtx.vout.size()-1].scriptPubKey,subtxid,pk,num) == 'S' && subtxid == oracletxid && pk == publisher ) { @@ -818,7 +818,7 @@ int64_t AddMyOraclesFunds(struct CCcontract_info *cp,CMutableTransaction &mtx,CP txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = it->second.satoshis; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && (numvouts=vintx.vout.size())>0) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 && (numvouts=vintx.vout.size())>0) { if ((funcid=DecodeOraclesOpRet(vintx.vout[numvouts-1].scriptPubKey,tmporacletxid,tmppk,tmpamount))!=0 && funcid=='F' && tmppk==pk && tmporacletxid==oracletxid && tmpamount==nValue && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout)==0) @@ -986,7 +986,7 @@ std::string OracleData(int64_t txfee,uint256 oracletxid,std::vector da fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - if ( GetTransaction(oracletxid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0 ) + if ( myGetTransaction(oracletxid,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0 ) { if ( DecodeOraclesCreateOpRet(tx.vout[numvouts-1].scriptPubKey,name,description,format) == 'C' ) { @@ -1061,11 +1061,11 @@ UniValue OracleDataSample(uint256 reforacletxid,uint256 txid) CPubKey pk; std::string name,description,format; int32_t numvouts; std::vector data; char str[67], *formatstr = 0; result.push_back(Pair("result","success")); - if ( GetTransaction(reforacletxid,oracletx,hashBlock,false) != 0 && (numvouts=oracletx.vout.size()) > 0 ) + if ( myGetTransaction(reforacletxid,oracletx,hashBlock) != 0 && (numvouts=oracletx.vout.size()) > 0 ) { if ( DecodeOraclesCreateOpRet(oracletx.vout[numvouts-1].scriptPubKey,name,description,format) == 'C' ) { - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0 ) { if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,btxid,pk,data) == 'D' && reforacletxid == oracletxid ) { @@ -1094,7 +1094,7 @@ UniValue OracleDataSamples(uint256 reforacletxid,char* batonaddr,int32_t num) std::vector > addressIndex; int64_t nValue; result.push_back(Pair("result","success")); - if ( GetTransaction(reforacletxid,oracletx,hashBlock,false) != 0 && (numvouts=oracletx.vout.size()) > 0 ) + if ( myGetTransaction(reforacletxid,oracletx,hashBlock) != 0 && (numvouts=oracletx.vout.size()) > 0 ) { if ( DecodeOraclesCreateOpRet(oracletx.vout[numvouts-1].scriptPubKey,name,description,format) == 'C' ) { @@ -1122,7 +1122,7 @@ UniValue OracleDataSamples(uint256 reforacletxid,char* batonaddr,int32_t num) txid=it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second; - if (vout==1 && nValue==10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0 ) + if (vout==1 && nValue==10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0 ) { if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,btxid,pk,data) == 'D' && reforacletxid == oracletxid ) { @@ -1155,14 +1155,14 @@ UniValue OracleInfo(uint256 origtxid) cp = CCinit(&C,EVAL_ORACLES); CCtxidaddr(markeraddr,origtxid); - if ( GetTransaction(origtxid,tx,hashBlock,false) == 0 ) + if ( myGetTransaction(origtxid,tx,hashBlock) == 0 ) { fprintf(stderr,"cant find oracleid\n"); result.push_back(Pair("result","error")); result.push_back(Pair("error","cant find oracleid")); return(result); } - if ( GetTransaction(origtxid,tx,hashBlock,false) != 0 ) + if ( myGetTransaction(origtxid,tx,hashBlock) != 0 ) { if ( tx.vout.size() > 0 && DecodeOraclesCreateOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,name,description,format) == 'C' ) { @@ -1177,7 +1177,7 @@ UniValue OracleInfo(uint256 origtxid) { txid = it->first.txhash; height = (int32_t)it->second.blockHeight; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && + if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && DecodeOraclesOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,oracletxid,pk,datafee) == 'R' && oracletxid == origtxid ) { if (publishers.find(pk)==publishers.end() || height>publishers[pk].second) @@ -1189,7 +1189,7 @@ UniValue OracleInfo(uint256 origtxid) } for (std::map>::iterator it = publishers.begin(); it != publishers.end(); ++it) { - if ( GetTransaction(it->second.first,tx,hashBlock,false) != 0 && DecodeOraclesOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,oracletxid,pk,datafee) == 'R') + if ( myGetTransaction(it->second.first,tx,hashBlock) != 0 && DecodeOraclesOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,oracletxid,pk,datafee) == 'R') { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("publisher",pubkey33_str(str,(uint8_t *)pk.begin()))); @@ -1222,7 +1222,7 @@ UniValue OraclesList() for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; - if ( GetTransaction(txid,createtx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,createtx,hashBlock) != 0 ) { if ( createtx.vout.size() > 0 && DecodeOraclesCreateOpRet(createtx.vout[createtx.vout.size()-1].scriptPubKey,name,description,format) == 'C' ) { diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index be4d63271..17507a80e 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -559,7 +559,7 @@ int64_t AddPaymentsInputs(bool fLockedBlocks,int8_t GetBalance,struct CCcontract txid = it->first.txhash; vout = (int32_t)it->first.index; //fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr); - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( (nValue= IsPaymentsvout(cp,vintx,vout,coinaddr,ccopret)) > PAYMENTS_TXFEE && nValue >= threshold && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 96c41b9ff..4c3d659ae 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -382,7 +382,7 @@ int64_t AddPegsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe txid = it->first.txhash; vout = (int32_t)it->first.index; // no need to prevent dup - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if (myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { @@ -413,7 +413,7 @@ int64_t AddPegsTokenInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,u txid = it->first.txhash; vout = (int32_t)it->first.index; // no need to prevent dup - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if (myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 && DecodePegsOpRet(vintx,tmppegstxid,tmptokenid)!=0 && tmppegstxid==pegstxid && tmptokenid==tokenid) { @@ -521,7 +521,7 @@ double PegsGetTokenPrice(uint256 tokenid) int64_t *tokensyn,*btcusd; double price; CTransaction tokentx; uint256 hashBlock; std::string name,desc; std::vector vorigpubkey; int32_t numvouts; - if (GetTransaction(tokenid,tokentx,hashBlock,false)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c') + if (myGetTransaction(tokenid,tokentx,hashBlock)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c') { tokensyn = (int64_t *)calloc(sizeof(*tokensyn) * 3, 1 + PRICES_DAYWINDOW * 2 + PRICES_SMOOTHWIDTH); btcusd = (int64_t *)calloc(sizeof(*btcusd) * 3, 1 + PRICES_DAYWINDOW * 2 + PRICES_SMOOTHWIDTH); @@ -539,7 +539,7 @@ std::string PegsGetTokenName(uint256 tokenid) { CTransaction tokentx; uint256 hashBlock; std::string name,desc; std::vector vorigpubkey; int32_t numvouts; - if (GetTransaction(tokenid,tokentx,hashBlock,false)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c') + if (myGetTransaction(tokenid,tokentx,hashBlock,false)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c') { return (name); } @@ -555,7 +555,7 @@ double PegsGetAccountRatio(uint256 pegstxid,uint256 tokenid,uint256 accounttxid) std::pair account; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_PEGS); - if (GetTransaction(accounttxid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && + if (myGetTransaction(accounttxid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && (funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid && tokenid==tmptokenid) { PegsDecodeAccountTx(tx,pk,amount,account); @@ -581,7 +581,7 @@ double PegsGetGlobalRatio(uint256 pegstxid) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - if (vout == 0 && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && + if (vout == 0 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && (funcid=DecodePegsOpRet(tx,tmppegstxid,tokenid))!=0 && pegstxid==tmppegstxid && (funcid=='F' || funcid=='G' || funcid=='E')) { PegsDecodeAccountTx(tx,pk,amount,account); @@ -597,7 +597,7 @@ double PegsGetGlobalRatio(uint256 pegstxid) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - if (GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && DecodePegsOpRet(tx,tmppegstxid,tokenid)!=0 && pegstxid==tmppegstxid) + if (myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && DecodePegsOpRet(tx,tmppegstxid,tokenid)!=0 && pegstxid==tmppegstxid) { globalaccounts[tokenid].first+=nValue; } @@ -660,7 +660,7 @@ std::string PegsCreate(uint64_t txfee,int64_t amount, std::vector bindt pegspk = GetUnspendable(cp,0); for(auto txid : bindtxids) { - if (GetTransaction(txid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + if (myGetTransaction(txid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find bindtxid %s",txid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -697,7 +697,7 @@ std::string PegsFund(uint64_t txfee,uint256 pegstxid, uint256 tokenid,int64_t am mypk = pubkey2pk(Mypubkey()); pegspk = GetUnspendable(cp,0); - if (GetTransaction(pegstxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + if (,yGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -711,7 +711,7 @@ std::string PegsFund(uint64_t txfee,uint256 pegstxid, uint256 tokenid,int64_t am } for(auto txid : bindtxids) { - if (GetTransaction(txid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + if (myGetTransaction(txid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find bindtxid %s",txid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -794,7 +794,7 @@ std::string PegsGet(uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64_t am txfee = 10000; mypk = pubkey2pk(Mypubkey()); pegspk = GetUnspendable(cp,0); - if (GetTransaction(pegstxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + if (myGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -855,7 +855,7 @@ std::string PegsRedeem(uint64_t txfee,uint256 pegstxid, uint256 tokenid) txfee = 10000; mypk = pubkey2pk(Mypubkey()); pegspk = GetUnspendable(cp,0); - if (GetTransaction(pegstxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + if (myGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -869,7 +869,7 @@ std::string PegsRedeem(uint64_t txfee,uint256 pegstxid, uint256 tokenid) } for(auto txid : bindtxids) { - if (GetTransaction(txid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + if (myGetTransaction(txid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find bindtxid %s",txid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -968,7 +968,7 @@ std::string PegsExchange(uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64 txfee = 10000; mypk = pubkey2pk(Mypubkey()); pegspk = GetUnspendable(cp,0); - if (GetTransaction(pegstxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + if (myGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -982,7 +982,7 @@ std::string PegsExchange(uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64 } for(auto txid : bindtxids) { - if (GetTransaction(txid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + if (myGetTransaction(txid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find bindtxid %s",txid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1026,7 +1026,7 @@ std::string PegsExchange(uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64 LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if (accounttxid!=zeroid && GetTransaction(accounttxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0 || PegsDecodeAccountTx(tx,tmppk,tmpamount,account).empty()) + if (accounttxid!=zeroid && myGetTransaction(accounttxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0 || PegsDecodeAccountTx(tx,tmppk,tmpamount,account).empty()) { CCerror = strprintf("invalid account tx from which to exchange coins to tokens %s!",accounttxid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1104,7 +1104,7 @@ std::string PegsLiquidate(uint64_t txfee,uint256 pegstxid, uint256 tokenid, uint txfee = 10000; mypk = pubkey2pk(Mypubkey()); pegspk = GetUnspendable(cp,0); - if (GetTransaction(pegstxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + if (myGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1118,7 +1118,7 @@ std::string PegsLiquidate(uint64_t txfee,uint256 pegstxid, uint256 tokenid, uint } for(auto txid : bindtxids) { - if (GetTransaction(txid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) + if (myGetTransaction(txid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find bindtxid %s",txid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1160,7 +1160,7 @@ std::string PegsLiquidate(uint64_t txfee,uint256 pegstxid, uint256 tokenid, uint LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - if (liquidatetxid!=zeroid && GetTransaction(liquidatetxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0 || PegsDecodeAccountTx(tx,tmppk,amount,account).empty()) + if (liquidatetxid!=zeroid && myGetTransaction(liquidatetxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0 || PegsDecodeAccountTx(tx,tmppk,amount,account).empty()) { CCerror = strprintf("cannot find account to liquidate or invalid tx %s!",liquidatetxid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); @@ -1235,7 +1235,7 @@ UniValue PegsAccountHistory(uint256 pegstxid) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second; - if (vout == 1 && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && + if (vout == 1 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && (funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid) { UniValue obj(UniValue::VOBJ); @@ -1272,7 +1272,7 @@ UniValue PegsAccountInfo(uint256 pegstxid) vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; //LOGSTREAM("pegscc",CCLOG_DEBUG2, stream << "txid=" << txid.GetHex() << ", vout=" << vout << ", nValue=" << nValue << std::endl); - if (vout == 1 && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && + if (vout == 1 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && (funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid) { //LOGSTREAM("pegscc",CCLOG_DEBUG2, stream << "txid=" << txid.GetHex() << ", vout=" << vout << ", nValue=" << nValue << ", tokenid=" << tmptokenid.GetHex() << std::endl); @@ -1314,7 +1314,7 @@ UniValue PegsWorstAccounts(uint256 pegstxid) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - if (vout == 0 && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && + if (vout == 0 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && (funcid=DecodePegsOpRet(tx,tmppegstxid,tokenid))!=0 && pegstxid==tmppegstxid) { PegsDecodeAccountTx(tx,pk,amount,account); @@ -1366,7 +1366,7 @@ UniValue PegsInfo(uint256 pegstxid) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - if (vout == 0 && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && + if (vout == 0 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && (funcid=DecodePegsOpRet(tx,tmppegstxid,tokenid))!=0 && pegstxid==tmppegstxid) { PegsDecodeAccountTx(tx,pk,amount,account); @@ -1382,7 +1382,7 @@ UniValue PegsInfo(uint256 pegstxid) txid = it->first.txhash; vout = (int32_t)it->first.index; nValue = (int64_t)it->second.satoshis; - if (GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && DecodePegsOpRet(tx,tmppegstxid,tokenid)!=0 && pegstxid==tmppegstxid) + if (myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && DecodePegsOpRet(tx,tmppegstxid,tokenid)!=0 && pegstxid==tmppegstxid) { globalaccounts[tokenid].first+=nValue; } diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 2c0a33b20..0fcc2e512 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -590,7 +590,7 @@ int64_t AddPricesInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, ch vout = (int32_t)it->first.index; //if (vout == exclvout && txid == excltxid) // exclude vout which is added directly to vins outside this function // continue; - if (GetTransaction(txid, vintx, hashBlock, false) != 0 && vout < vintx.vout.size()) + if (myGetTransaction(txid, vintx, hashBlock) != 0 && vout < vintx.vout.size()) { vscript_t vopret; uint8_t funcId = PricesCheckOpret(vintx, vopret); @@ -2161,7 +2161,7 @@ UniValue PricesList(uint32_t filter, CPubKey mypk) std::vector vec; CTransaction vintx; - if (GetTransaction(txid, vintx, hashBlock, false) != 0) + if (myGetTransaction(txid, vintx, hashBlock) != 0) { // TODO: forget old tx diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 2edd275ec..2d6399737 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -357,7 +357,7 @@ int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CCcont break; if ( j != mtx.vin.size() ) continue; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { if ( (funcid= DecodeRewardsOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) != 0 ) { @@ -409,7 +409,7 @@ int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CCcontra { txid = it->first.txhash; vout = (int32_t)it->first.index; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) { if ( (funcid= DecodeRewardsOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) == 'F' || funcid == 'A' || funcid == 'U' || funcid == 'L' ) { @@ -439,7 +439,7 @@ bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewa { //int height = it->first.blockHeight; txid = it->first.txhash; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 ) { //char str[65]; fprintf(stderr,"rewards plan %s\n",uint256_str(str,txid)); if ( DecodeRewardsFundingOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) == 'F' ) @@ -455,7 +455,7 @@ bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewa UniValue RewardsInfo(uint256 rewardsid) { UniValue result(UniValue::VOBJ); uint256 hashBlock; CTransaction vintx; uint64_t lockedfunds,APR,minseconds,maxseconds,mindeposit,sbits,funding; CPubKey rewardspk; struct CCcontract_info *cp,C; char str[67],numstr[65]; - if ( GetTransaction(rewardsid,vintx,hashBlock,false) == 0 ) + if ( myGetTransaction(rewardsid,vintx,hashBlock) == 0 ) { fprintf(stderr,"cant find fundingtxid\n"); result.push_back(Pair("result","error")); @@ -498,7 +498,7 @@ UniValue RewardsList() for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; - if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( vintx.vout.size() > 0 && DecodeRewardsFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) != 0 ) { @@ -657,7 +657,7 @@ std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint2 CCerror = "locktxid/v0 is spent"; return(""); } - if ( GetTransaction(locktxid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + if ( myGetTransaction(locktxid,tx,hashBlock) != 0 && tx.vout.size() > 0 && tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) { scriptPubKey = tx.vout[1].scriptPubKey; mtx.vin.push_back(CTxIn(locktxid,0,CScript())); diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 61ea6c545..8017799ba 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2730,7 +2730,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params decode_hex((uint8_t *)&txid,32,txidstr); txid = revuint256(txid); result.push_back(Pair("txid",txid.GetHex())); - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { @@ -2780,7 +2780,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != txfee || vout != 0 ) continue; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { if ( (nValue= IsCClibvout(cp,tx,vout,coinaddr)) == txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { @@ -2861,7 +2861,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params result.push_back(Pair("txid",txid.GetHex())); if ( CCgettxout(txid,0,1,0) < 0 ) result.push_back(Pair("error","already solved")); - else if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + else if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { Getscriptaddress(checkaddr,tx.vout[1].scriptPubKey); if ( strcmp(checkaddr,CCaddr) != 0 ) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 8407439ff..076e89a03 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -430,7 +430,7 @@ void CheckBurnTxSource(uint256 burntxid, UniValue &info) { CTransaction burnTx; uint256 blockHash; - if (!GetTransaction(burntxid, burnTx, blockHash, true)) + if (!myGetTransaction(burntxid, burnTx, blockHash)) throw std::runtime_error("Cannot find burn transaction"); if (blockHash.IsNull()) @@ -1157,7 +1157,7 @@ UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp) { UniValue item(UniValue::VOBJ); UniValue notaryarr(UniValue::VARR); std::vector NotarisationNotaries; uint256 hash; CTransaction tx; - if ( GetTransaction(n.first,tx,hash,false) ) + if ( myGetTransaction(n.first,tx,hash) ) { if ( is_STAKED(n.second.symbol) != 0 ) { From 6408632ab35316f1b68c035a4508c05c98d49d3b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 01:37:46 -1100 Subject: [PATCH 109/171] Fix --- src/cc/fsm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/fsm.cpp b/src/cc/fsm.cpp index dca2efd2d..58b2120cf 100644 --- a/src/cc/fsm.cpp +++ b/src/cc/fsm.cpp @@ -133,7 +133,7 @@ int64_t AddFSMInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey // prevent dup if ( it->second.satoshis < 1000000 ) continue; - if ( myGetTransaction(txid,vintx,hashBlock,false) != 0 ) + if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( (nValue= IsFSMvout(cp,vintx,(int32_t)it->first.index)) > 0 ) { From 44835832730e37df625fed255cb89d7d6d4b2855 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 01:41:12 -1100 Subject: [PATCH 110/171] -, --- src/cc/pegs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 4c3d659ae..7c64d6cd2 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -697,7 +697,7 @@ std::string PegsFund(uint64_t txfee,uint256 pegstxid, uint256 tokenid,int64_t am mypk = pubkey2pk(Mypubkey()); pegspk = GetUnspendable(cp,0); - if (,yGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) + if (myGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0) { CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); From 66468ce589a712afc00d3d2f6ebf4a09bf25c027 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 01:42:45 -1100 Subject: [PATCH 111/171] Test --- src/cc/pegs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 7c64d6cd2..002b591c4 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -539,7 +539,7 @@ std::string PegsGetTokenName(uint256 tokenid) { CTransaction tokentx; uint256 hashBlock; std::string name,desc; std::vector vorigpubkey; int32_t numvouts; - if (myGetTransaction(tokenid,tokentx,hashBlock,false)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c') + if (myGetTransaction(tokenid,tokentx,hashBlock)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c') { return (name); } From 343354a1a981560cbb584792b75d64809bf03fc3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 01:47:07 -1100 Subject: [PATCH 112/171] U. --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4e2e4a9c4..ff500591f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2230,10 +2230,10 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo if ( KOMODO_NSPV != 0 ) { int64_t rewardsum = 0; int32_t i,retval,txheight = 0,vout = 0; - for (i=0; i Date: Fri, 12 Jul 2019 01:50:19 -1100 Subject: [PATCH 113/171] Use hash --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index ff500591f..f4928b4d2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2231,7 +2231,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo { int64_t rewardsum = 0; int32_t i,retval,txheight = 0,vout = 0; for (i=0; i Date: Fri, 12 Jul 2019 02:06:48 -1100 Subject: [PATCH 114/171] +print --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 768e34fe7..91080c3f6 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -291,7 +291,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran } else { - fprintf(stderr,"vini.%d has CC signing error address.(%s)\n",i,destaddr); + fprintf(stderr,"vini.%d has CC signing error address.(%s) %s\n",i,destaddr,EncodeHexTx(mtx).c_str()); return(""); } } From fceb07f5ad5fc72fcaae0b575a8831fbdbd7e261 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 02:40:23 -1100 Subject: [PATCH 115/171] +print --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 91080c3f6..92d5f6d58 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -245,7 +245,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc tokens addr: else if (strcmp(cp->tokens1of2addr, destaddr) == 0) { - //fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); +fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); privkey = cp->tokens1of2priv;//myprivkey; if (othercond1of2tokens == 0) // NOTE: if additionalEvalcode2 is not set then it is dual-eval cc else three-eval cc From be264f0a6910229538392376924fe4515d9a3c12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 02:44:59 -1100 Subject: [PATCH 116/171] Test --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 92d5f6d58..22f2116f5 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -175,7 +175,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); - //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); + fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->tokens1of2addr); //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { From 6b6b09c4d4e5a0e65e093f6fa539ad0610f901da Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 02:54:09 -1100 Subject: [PATCH 117/171] Autodetect missing tokens address --- src/cc/CCtokens.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 289549c36..5da6e97c8 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -870,7 +870,12 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, vscript_t destpubkey, if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) + if ( cp->tokens1of2addr[0] == 0 ) + { + GetTokensCCaddress(cp, cp->tokens1of2addr, mypk); + fprintf(stderr,"set tokens1of2addr <- %s\n",cp->tokens1of2addr); + } + if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); // seems, mask is not used anymore From 8c77b7dddc8b48af0d837fd3f46a7aa1dd74c796 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 03:02:53 -1100 Subject: [PATCH 118/171] +print --- src/cc/CCtx.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 22f2116f5..2ec5d6283 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -175,11 +175,11 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); - fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->tokens1of2addr); + fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->mysingletokensaddr); //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { - //fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr); +fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr); privkey = myprivkey; cond = mycond; } @@ -187,30 +187,30 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { privkey = myprivkey; cond = mytokenscond; - //fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr); +fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr); } else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout { privkey = myprivkey; cond = mysingletokenscond; - //fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr); +fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr); } else if ( strcmp(destaddr,unspendable) == 0 ) { privkey = unspendablepriv; cond = othercond; - //fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); +fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); } else if (strcmp(destaddr, unspendabletokensaddr) == 0) { privkey = unspendablepriv; cond = othertokenscond; - //fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr); +fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr); } // check if this is the 2nd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr, cp->unspendableaddr2) == 0) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); +fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; if( othercond2 == 0 ) othercond2 = MakeCCcond1(cp->unspendableEvalcode2, cp->unspendablepk2); @@ -219,7 +219,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is 3rd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 ) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); +fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); privkey = cp->unspendablepriv3; if( othercond3 == 0 ) othercond3 = MakeCCcond1(cp->unspendableEvalcode3, cp->unspendablepk3); @@ -228,7 +228,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran // check if this is spending from 1of2 cc coins addr: else if (strcmp(cp->coins1of2addr, destaddr) == 0) { - //fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); +fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = cp->coins1of2priv;//myprivkey; if (othercond1of2 == 0) othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); @@ -236,7 +236,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran } else if ( strcmp(CC1of2CCaddr,destaddr) == 0 ) { - //fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr); +fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr); privkey = unspendablepriv; if (condCC2 == 0) condCC2 = MakeCCcond1of2(cp->evalcode,unspendablepk,unspendablepk); @@ -270,7 +270,8 @@ fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2 cond = othercond4; flag = 1; } - } + } //else privkey = myprivkey; + if ( flag == 0 ) { fprintf(stderr,"CC signing error: vini.%d has unknown CC address.(%s)\n",i,destaddr); From c1243f1beafbdd2acb557ec90132c84e07e24532 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 03:05:18 -1100 Subject: [PATCH 119/171] Add error check to getscriptaddress --- src/cc/CCutils.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 2430a9b37..3501b8652 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -208,10 +208,14 @@ void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, u bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) { CTxDestination address; txnouttype whichType; - if ( ExtractDestination(scriptPubKey,address) != 0 ) + destaddr[0] = 0; + if ( scriptPubKey.begin() != 0 ) { - strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); - return(true); + if ( ExtractDestination(scriptPubKey,address) != 0 ) + { + strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); + return(true); + } } //fprintf(stderr,"ExtractDestination failed\n"); return(false); From a599f49bc439a9363ff9382e01f0378e1464c56e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 03:05:45 -1100 Subject: [PATCH 120/171] test --- src/cc/CCtx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 2ec5d6283..84f876fb3 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -175,7 +175,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); - fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->mysingletokensaddr); + fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,mysingletokensaddr); //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { From 5f60266446ad4c334b18dcccf3b638ca8d06d87b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 03:29:06 -1100 Subject: [PATCH 121/171] Fix tokeninfo --- src/cc/CCtokens.cpp | 6 +++--- src/cc/CCtx.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 5da6e97c8..39daede80 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -870,11 +870,11 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, vscript_t destpubkey, if (txfee == 0) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - if ( cp->tokens1of2addr[0] == 0 ) + /*if ( cp->tokens1of2addr[0] == 0 ) { GetTokensCCaddress(cp, cp->tokens1of2addr, mypk); fprintf(stderr,"set tokens1of2addr <- %s\n",cp->tokens1of2addr); - } + }*/ if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) { mask = ~((1LL << mtx.vin.size()) - 1); // seems, mask is not used anymore @@ -957,7 +957,7 @@ UniValue TokenInfo(uint256 tokenid) result.push_back(Pair("error", "cant find tokenid")); return(result); } - if (hashBlock.IsNull()) { + if ( KOMODO_NSPV == 0 && hashBlock.IsNull()) { result.push_back(Pair("result", "error")); result.push_back(Pair("error", "the transaction is still in mempool")); return(result); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 84f876fb3..ab21cdc3b 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -279,12 +279,12 @@ fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2 } } uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL,utxovalues[i],consensusBranchId, &txdata); + int32_t z; + for (z=0; z<32; z++) + fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); + fprintf(stderr," sighash [%d] %.8f %x\n",i,(double)utxovalues[i]/COIN,consensusBranchId); if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 ) { - //int32_t z; - //for (z=0; z<32; z++) - // fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); - //fprintf(stderr," sighash [%d] %.8f %x\n",i,(double)utxovalues[i]/COIN,consensusBranchId); //for (z=0; z<32; z++) // fprintf(stderr,"%02x",privkey[z]); //fprintf(stderr," signed with privkey\n"); From 134b5df43987bdc5f6868323c2d52f7f8c5c3942 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 03:40:09 -1100 Subject: [PATCH 122/171] +print --- src/cryptoconditions/src/secp256k1.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/cryptoconditions/src/secp256k1.c b/src/cryptoconditions/src/secp256k1.c index 7cb557fb0..0c1f2db79 100644 --- a/src/cryptoconditions/src/secp256k1.c +++ b/src/cryptoconditions/src/secp256k1.c @@ -157,7 +157,11 @@ static int secp256k1Sign(CC *cond, CCVisitor visitor) { int rc = secp256k1_ecdsa_sign(ec_ctx_sign, &sig, visitor.msg, signing->sk, NULL, NULL); unlockSign(); - if (rc != 1) return 0; + if (rc != 1) + { + fprintf(stderr,"secp256k1Sign rc.%d\n",rc); + return 0; + } if (!cond->signature) cond->signature = calloc(1, SECP256K1_SIG_SIZE); secp256k1_ecdsa_signature_serialize_compact(ec_ctx_verify, cond->signature, &sig); @@ -188,16 +192,22 @@ int cc_signTreeSecp256k1Msg32(CC *cond, const unsigned char *privateKey, const u } // serialize pubkey - unsigned char *publicKey = calloc(1, SECP256K1_PK_SIZE); + //unsigned char *publicKey = calloc(1, SECP256K1_PK_SIZE); + unsigned char publicKeySECP256K1_PK_SIZE]; size_t ol = SECP256K1_PK_SIZE; secp256k1_ec_pubkey_serialize(ec_ctx_verify, publicKey, &ol, &spk, SECP256K1_EC_COMPRESSED); - + { + int32_t z; + for (z=0; z<33; z++) + fprintf(stderr,"%02x",publicKey[z]); + fprintf(stderr," pubkey\n"); + } // sign CCSecp256k1SigningData signing = {publicKey, privateKey, 0}; CCVisitor visitor = {&secp256k1Sign, msg32, 32, &signing}; cc_visit(cond, visitor); - free(publicKey); + //free(publicKey); return signing.nSigned; } From f8da75a8c4cd9d03e75403c67e22a3c889e60632 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 03:42:04 -1100 Subject: [PATCH 123/171] Test --- src/cc/CCtx.cpp | 8 ++++---- src/cryptoconditions/src/secp256k1.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index ab21cdc3b..89d918037 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -280,15 +280,15 @@ fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2 } uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL,utxovalues[i],consensusBranchId, &txdata); int32_t z; + for (z=0; z<32; z++) + fprintf(stderr,"%02x",privkey[z]); + fprintf(stderr," privkey, "); for (z=0; z<32; z++) fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]); fprintf(stderr," sighash [%d] %.8f %x\n",i,(double)utxovalues[i]/COIN,consensusBranchId); if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 ) { - //for (z=0; z<32; z++) - // fprintf(stderr,"%02x",privkey[z]); - //fprintf(stderr," signed with privkey\n"); - mtx.vin[i].scriptSig = CCSig(cond); + mtx.vin[i].scriptSig = CCSig(cond); } else { diff --git a/src/cryptoconditions/src/secp256k1.c b/src/cryptoconditions/src/secp256k1.c index 0c1f2db79..a16115bb8 100644 --- a/src/cryptoconditions/src/secp256k1.c +++ b/src/cryptoconditions/src/secp256k1.c @@ -193,7 +193,7 @@ int cc_signTreeSecp256k1Msg32(CC *cond, const unsigned char *privateKey, const u // serialize pubkey //unsigned char *publicKey = calloc(1, SECP256K1_PK_SIZE); - unsigned char publicKeySECP256K1_PK_SIZE]; + unsigned char publicKey[SECP256K1_PK_SIZE]; size_t ol = SECP256K1_PK_SIZE; secp256k1_ec_pubkey_serialize(ec_ctx_verify, publicKey, &ol, &spk, SECP256K1_EC_COMPRESSED); { From 0e4f4ee032b5862356b5c11ddc20a12e0aeb1015 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 05:16:22 -1100 Subject: [PATCH 124/171] Tweak MAX_ERAS --- src/komodo_defs.h | 2 +- src/komodo_globals.h | 2 +- src/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 1ee3ef788..52d76c88c 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -275,7 +275,7 @@ extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOM extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED,KOMODO_NSPV; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET; extern bool VERUS_MINTBLOCKS; -extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; +extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 533faf981..f647b76fd 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -74,7 +74,7 @@ uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0,ASSETCHAINS_CBOPRET=0; uint64_t ASSETCHAINS_LASTERA = 1; -uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_PEGSCCPARAMS[3]; +uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_PEGSCCPARAMS[3]; uint8_t ASSETCHAINS_CCDISABLES[256]; std::vector ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; diff --git a/src/main.cpp b/src/main.cpp index f4928b4d2..f883207e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2432,7 +2432,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) //uint64_t komodo_moneysupply(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS]; +extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1]; extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; From eb1bc0cc0ce2da863ce51917200fc9b3ed5b612a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 05:21:05 -1100 Subject: [PATCH 125/171] Test ASSETCHAINS_MAX_ERAS+1 --- src/komodo_defs.h | 2 +- src/komodo_globals.h | 2 +- src/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 5074b4303..748f9ee7a 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -274,7 +274,7 @@ extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOM extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET; extern bool VERUS_MINTBLOCKS; -extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; +extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 9ffa147ea..c350020b6 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -74,7 +74,7 @@ uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0,ASSETCHAINS_CBOPRET=0; uint64_t ASSETCHAINS_LASTERA = 1; -uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS]; +uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1]; uint8_t ASSETCHAINS_CCDISABLES[256]; std::vector ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; diff --git a/src/main.cpp b/src/main.cpp index a8f333aa8..34708bef7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2407,7 +2407,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) //uint64_t komodo_moneysupply(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS]; +extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1]; extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; From cc7c65173758abfe1981af38970106f1c6915db6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 05:25:22 -1100 Subject: [PATCH 126/171] Remove debug --- src/komodo_nSPV_wallet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index df0cb9a8d..124a9a680 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -84,8 +84,8 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int fprintf(stderr,"extradata %.8f vs rewards %.8f\n",dstr(extradata),dstr(rewards)); rewardsum += rewards; } - char coinaddr[64]; - Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); + //char coinaddr[64]; + //Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); //fprintf(stderr,"%s txid.%s vs hash.%s\n",coinaddr,txid.GetHex().c_str(),tx.GetHash().GetHex().c_str()); if ( skipvalidation == 0 ) From 3bcfaf37a616957492459aecac013bb7e5e5fad8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 05:38:20 -1100 Subject: [PATCH 127/171] Alt myprivkey method --- src/cc/CCtx.cpp | 24 +++++++++++++----------- src/cc/CCutils.cpp | 8 ++++++-- src/komodo_nSPV_wallet.h | 2 +- src/script/sign.cpp | 5 ++++- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 89d918037..5373d3d1d 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -175,11 +175,11 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else { Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); - fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,mysingletokensaddr); + //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,mysingletokensaddr); //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; if( strcmp(destaddr, myaddr) == 0 ) { -fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr); +//fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr); privkey = myprivkey; cond = mycond; } @@ -187,30 +187,30 @@ fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr); { privkey = myprivkey; cond = mytokenscond; -fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr); +//fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr); } else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout { privkey = myprivkey; cond = mysingletokenscond; -fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr); +//fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr); } else if ( strcmp(destaddr,unspendable) == 0 ) { privkey = unspendablepriv; cond = othercond; -fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); +//fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); } else if (strcmp(destaddr, unspendabletokensaddr) == 0) { privkey = unspendablepriv; cond = othertokenscond; -fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr); +//fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr); } // check if this is the 2nd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr, cp->unspendableaddr2) == 0) { -fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); +//fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); privkey = cp->unspendablepriv2; if( othercond2 == 0 ) othercond2 = MakeCCcond1(cp->unspendableEvalcode2, cp->unspendablepk2); @@ -219,7 +219,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2) // check if this is 3rd additional evalcode + 'unspendable' cc addr: else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 ) { -fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); +//fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); privkey = cp->unspendablepriv3; if( othercond3 == 0 ) othercond3 = MakeCCcond1(cp->unspendableEvalcode3, cp->unspendablepk3); @@ -228,7 +228,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3) // check if this is spending from 1of2 cc coins addr: else if (strcmp(cp->coins1of2addr, destaddr) == 0) { -fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); +//fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); privkey = cp->coins1of2priv;//myprivkey; if (othercond1of2 == 0) othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); @@ -236,7 +236,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr) } else if ( strcmp(CC1of2CCaddr,destaddr) == 0 ) { -fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr); +//fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr); privkey = unspendablepriv; if (condCC2 == 0) condCC2 = MakeCCcond1of2(cp->evalcode,unspendablepk,unspendablepk); @@ -245,7 +245,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr); // check if this is spending from 1of2 cc tokens addr: else if (strcmp(cp->tokens1of2addr, destaddr) == 0) { -fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); +//fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); privkey = cp->tokens1of2priv;//myprivkey; if (othercond1of2tokens == 0) // NOTE: if additionalEvalcode2 is not set then it is dual-eval cc else three-eval cc @@ -293,6 +293,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2 else { fprintf(stderr,"vini.%d has CC signing error address.(%s) %s\n",i,destaddr,EncodeHexTx(mtx).c_str()); + memset(myprivkey,0,sizeof(myprivkey)); return(""); } } @@ -320,6 +321,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2 cc_free(mysingletokenscond); if ( othertokenscond != 0 ) cc_free(othertokenscond); + memset(myprivkey,0,sizeof(myprivkey)); std::string strHex = EncodeHexTx(mtx); if ( strHex.size() > 0 ) return(strHex); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 3501b8652..97a1863bc 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -442,13 +442,16 @@ std::vector Mypubkey() return(pubkey); } -extern CKey NSPV_key; bool Myprivkey(uint8_t myprivkey[]) { char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33]; if ( KOMODO_NSPV != 0 ) { - NSPV_key.SetKey32(myprivkey); + vchSecret = DecodeSecret(NSPV_wifstr); + for (i=0; i<32; i++) + fprintf(stderr,"%02x",myprivkey[i]); + fprintf(stderr," myprivkey\n"); + memset(vchSecret.begin(),0,32); return true; } if ( Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG) != 0 ) @@ -465,6 +468,7 @@ bool Myprivkey(uint8_t myprivkey[]) if ( pwalletMain->GetKey(keyID,vchSecret) != 0 ) { memcpy(myprivkey,vchSecret.begin(),32); + memset(vchSecret.begin(),0,32); if ( 0 ) { for (i=0; i<32; i++) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 124a9a680..1657fa7c9 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -85,7 +85,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int rewardsum += rewards; } //char coinaddr[64]; - //Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); + //Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); causes crash?? //fprintf(stderr,"%s txid.%s vs hash.%s\n",coinaddr,txid.GetHex().c_str(),tx.GetHash().GetHex().c_str()); if ( skipvalidation == 0 ) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 451a63d4b..0bb746797 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -74,6 +74,8 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, return false; } vchSig = CCSigVec(cc); + if ( KOMODO_NSPV != 0 ) + memset(key.begin(),0,32); return true; } else @@ -98,7 +100,8 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, } vchSig.push_back((unsigned char)nHashType); - + if ( KOMODO_NSPV != 0 ) + memset(key.begin(),0,32); return true; } From 1d42b6eee2dde3b7103e46a5645ffbeca5020e54 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 05:41:56 -1100 Subject: [PATCH 128/171] Syntax --- src/cc/CCutils.cpp | 6 ++++-- src/script/sign.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 97a1863bc..23ae4d7df 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -442,6 +442,8 @@ std::vector Mypubkey() return(pubkey); } +extern char NSPV_wifstr[],NSPV_pubkeystr[]; + bool Myprivkey(uint8_t myprivkey[]) { char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33]; @@ -451,7 +453,7 @@ bool Myprivkey(uint8_t myprivkey[]) for (i=0; i<32; i++) fprintf(stderr,"%02x",myprivkey[i]); fprintf(stderr," myprivkey\n"); - memset(vchSecret.begin(),0,32); + memset((uint8_t *)vchSecret.begin(),0,32); return true; } if ( Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG) != 0 ) @@ -468,7 +470,7 @@ bool Myprivkey(uint8_t myprivkey[]) if ( pwalletMain->GetKey(keyID,vchSecret) != 0 ) { memcpy(myprivkey,vchSecret.begin(),32); - memset(vchSecret.begin(),0,32); + memset((uint8_t *)vchSecret.begin(),0,32); if ( 0 ) { for (i=0; i<32; i++) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 0bb746797..678a1565a 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -75,7 +75,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, } vchSig = CCSigVec(cc); if ( KOMODO_NSPV != 0 ) - memset(key.begin(),0,32); + memset((uint8_t *)key.begin(),0,32); return true; } else @@ -101,7 +101,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector& vchSig, vchSig.push_back((unsigned char)nHashType); if ( KOMODO_NSPV != 0 ) - memset(key.begin(),0,32); + memset((uint8_t *)key.begin(),0,32); return true; } From c0d756c17ba67c829296a917e0118d38adcf6af8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 05:51:27 -1100 Subject: [PATCH 129/171] Test --- src/cc/CCutils.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 23ae4d7df..12f376179 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -18,6 +18,7 @@ */ #include "CCinclude.h" #include "komodo_structs.h" +#include "key_io.h" #ifdef TESTMODE #define MIN_NON_NOTARIZED_CONFIRMS 2 From 39fdf6130fd22050385f929594913ca1d948412b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 06:01:08 -1100 Subject: [PATCH 130/171] Actually copy out privacy --- src/cc/CCutils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 12f376179..d7d6ad8a8 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -451,9 +451,10 @@ bool Myprivkey(uint8_t myprivkey[]) if ( KOMODO_NSPV != 0 ) { vchSecret = DecodeSecret(NSPV_wifstr); + memcpy(myprivkey,vchSecret.begin(),32); for (i=0; i<32; i++) fprintf(stderr,"%02x",myprivkey[i]); - fprintf(stderr," myprivkey\n"); + fprintf(stderr," myprivkey %s\n",NSPV_wifstr); memset((uint8_t *)vchSecret.begin(),0,32); return true; } From 8bc632b4e5aaa4885787e79a68d75aa833cf6953 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 06:09:46 -1100 Subject: [PATCH 131/171] Egret --- src/cc/CCtx.cpp | 10 +++++----- src/cc/CCutils.cpp | 6 +++--- src/komodo_nSPV.h | 2 +- src/komodo_nSPV_wallet.h | 1 + src/main.cpp | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 5373d3d1d..1048f7e35 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -46,7 +46,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); CTransaction vintx; std::string hex; CPubKey globalpk; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; - int32_t i,flag,utxovout,n,err = 0; + int32_t i,flag,mgret,utxovout,n,err = 0; char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], unspendabletokensaddr[64],CC1of2CCaddr[64]; uint8_t *privkey, myprivkey[32], unspendablepriv[32], /*tokensunspendablepriv[32],*/ *msg32 = 0; CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond=0, *condCC2=0,*mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; @@ -118,7 +118,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran for (i=0; i proof; + fprintf(stderr,"NSPV_gettx %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height); if ( (ptr= NSPV_txproof_find(txid)) == 0 ) { NSPV_txproof(vout,txid,height); diff --git a/src/main.cpp b/src/main.cpp index f883207e5..64459e6ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2236,7 +2236,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo txheight = NSPV_U.U.utxos[i].height; break; } - retval = NSPV_gettransaction(1,vout,hash,txheight,txOut,0,0,rewardsum); + retval = NSPV_gettransaction(txheight == 0,vout,hash,txheight,txOut,0,0,rewardsum); return(retval == 0); } // need a GetTransaction without lock so the validation code for assets can run without deadlock From 2def2d9b692f21baa79e02f6efd5d14a4a763428 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 06:15:36 -1100 Subject: [PATCH 132/171] Relax mygettx --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 64459e6ba..4dba65c1a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2237,7 +2237,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo break; } retval = NSPV_gettransaction(txheight == 0,vout,hash,txheight,txOut,0,0,rewardsum); - return(retval == 0); + return(retval != -1); } // need a GetTransaction without lock so the validation code for assets can run without deadlock { From a5b391fb8907f0a98559ea554a1c0b8209389eee Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 06:16:01 -1100 Subject: [PATCH 133/171] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 4dba65c1a..6f84e5a39 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2236,7 +2236,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo txheight = NSPV_U.U.utxos[i].height; break; } - retval = NSPV_gettransaction(txheight == 0,vout,hash,txheight,txOut,0,0,rewardsum); + retval = NSPV_gettransaction(1,vout,hash,txheight,txOut,0,0,rewardsum); return(retval != -1); } // need a GetTransaction without lock so the validation code for assets can run without deadlock From 61371dd0c0d036b16e95cbc1c3b029aec75e6b38 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 06:24:59 -1100 Subject: [PATCH 134/171] Test --- src/cc/CCtx.cpp | 9 +++++++-- src/script/script.cpp | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 1048f7e35..5799f0b18 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -99,12 +99,17 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { if (i==0 && mtx.vin[i].prevout.n==10e8) continue; - if ( myGetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock) != 0 ) + if ( myGetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock) != 0 && mtx.vin[i].prevout.n < vintx.vout.size() ) { if ( vintx.vout[mtx.vin[i].prevout.n].scriptPubKey.IsPayToCryptoCondition() == 0 && ccvins==0) normalvins++; else ccvins++; - } + } + else + { + fprintf(stderr,"vin.%d vout.%d is bigger than vintx.%d\n",i,mtx.vin[i].prevout.n,(int32_t)vintx.vout.size()); + return(""); + } } if (normalvins>1 && ccvins) { diff --git a/src/script/script.cpp b/src/script/script.cpp index 475acdfd5..c821cd3bc 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -385,7 +385,9 @@ bool CScript::IsPayToCryptoCondition(CScript *pCCSubScript, std::vector> vParams; - return IsPayToCryptoCondition(pCCSubScript, vParams); + if ( pCCSubScript != 0 ) + return IsPayToCryptoCondition(pCCSubScript, vParams); + else return(false); } bool CScript::IsPayToCryptoCondition() const From 6024c775ac435c194e86c17c9d4d23e55f83f4b3 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 11 Jul 2019 11:42:52 -0700 Subject: [PATCH 135/171] Initial port of Hush supply curve to KMD --- src/komodo_bitcoind.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 48962b015..9882ef33c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1266,6 +1266,37 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); + + if ((strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) != 0)) { + int32_t starting_commission = 125000000, HALVING1 = 340000, INTERVAL = 840000, TRANSITION = 129, BR_END = 5422111; + // HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it ourselves. + // You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25 + // but to tell the AC params, I need to say "11% of 11.25" is 1.25 + // 11% ie. 1/9th cannot be exactly represented and so the FR has tiny amounts of error unless done manually + // Transition period of 128 blocks has BR=FR=0 + if (height < TRANSITION) { + commission = 0; + } else if (height < HALVING1) { + commission = starting_commission; + } else if (height < HALVING1+1*INTERVAL) { + commission = starting_commission / 2; + } else if (height < HALVING1+2*INTERVAL) { + commission = starting_commission / 4; + } else if (height < HALVING1+3*INTERVAL) { + commission = starting_commission / 8; + } else if (height < HALVING1+4*INTERVAL) { + commission = starting_commission / 16; + } else if (height < HALVING1+5*INTERVAL) { + commission = starting_commission / 32; + } else if (height < HALVING1+6*INTERVAL) { // Block 5380000 + // Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting + commission = starting_commission / 64; + } else if (height < HALVING1+7*INTERVAL) { + // Block reward will be zero before this is ever reached + commission = starting_commission / 128; // Block 6220000 + } + } + if ( ASSETCHAINS_FOUNDERS > 1 ) { if ( (height % ASSETCHAINS_FOUNDERS) == 0 ) From 7d8928c5e9234af6102d291faf1a4b3c62574f4d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 12 Jul 2019 05:43:49 -0400 Subject: [PATCH 136/171] Use strncmp correctly --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9882ef33c..312e2eda1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1267,7 +1267,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); - if ((strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) != 0)) { + if ((strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0)) { int32_t starting_commission = 125000000, HALVING1 = 340000, INTERVAL = 840000, TRANSITION = 129, BR_END = 5422111; // HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it ourselves. // You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25 From 38064092949b722a0629653973a5576809335bee Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 12 Jul 2019 11:37:01 -0400 Subject: [PATCH 137/171] Optimize check for HUSH3 in komodo_commission --- src/komodo_bitcoind.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 312e2eda1..20e0f3b90 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1256,10 +1256,16 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); uint64_t komodo_commission(const CBlock *pblock,int32_t height) { + static bool didinit = false,ishush3 = false; // LABS fungible chains, cannot have any block reward! if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) return(0); + if (!didinit) { + ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; + didinit = true; + } + int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; if ( ASSETCHAINS_FOUNDERS != 0 ) { @@ -1267,7 +1273,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); - if ((strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0)) { + if (ishush3) { int32_t starting_commission = 125000000, HALVING1 = 340000, INTERVAL = 840000, TRANSITION = 129, BR_END = 5422111; // HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it ourselves. // You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25 From f0398720dd51b271286226d5f73b59b81a321870 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Jul 2019 10:28:01 -0700 Subject: [PATCH 138/171] Add hush convenience scripts --- src/hush-cli | 11 +++++++++++ src/hushd | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100755 src/hush-cli create mode 100755 src/hushd diff --git a/src/hush-cli b/src/hush-cli new file mode 100755 index 000000000..efa1840a6 --- /dev/null +++ b/src/hush-cli @@ -0,0 +1,11 @@ +#!/bin/bash +# Copyright (c) 2019 Hush developers + +# set working directory to the location of this script +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $DIR + +NAME=HUSH3 + +CLI=${KOMODOCLI:-./komodo-cli} +$CLI -ac_name=$NAME "$@" diff --git a/src/hushd b/src/hushd new file mode 100755 index 000000000..949779a90 --- /dev/null +++ b/src/hushd @@ -0,0 +1,52 @@ +#!/bin/bash +# Copyright (c) 2019 Hush developers + +# set working directory to the location of this script +DIR="$( cd "$( dirname "$( readlink -f "${BASH_SOURCE[0]}" )" )" && pwd )" +cd $DIR + +NAME=HUSH3 +# this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn +SCRIPT=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac + +# Chain parameters +ERAS=3 +BLOCKTIME=150 +# 6250000 - (sprout pool at block 500,000) +SUPPLY=6178674 +FOUNDERS=1 +REWARD=0,1125000000,562500000 +PERC=11111111 +HALVING=129,340000,840000 +# NOTE: keep in sync with komodo_bitcoind.h +END=128,340000,5422111 +CLIENTNAME=GoldenSandtrout +SEEDNODE1=188.165.212.101 +SEEDNODE2=136.243.227.142 +SEEDNODE3=5.9.224.250 +CCLIB=hush3 + +# CryptoConditions/Custom Consensus params +FAUCET=228 +HEIR=234 +CHANNEL=235 +ORACLE=236 +GATEWAY=241 +CCENABLE=$FAUCET,$HEIR,$CHANNEL,$ORACLE,$GATEWAY + +KMD=${KOMODOD:-./komodod} +$KMD -ac_name=$NAME -ac_sapling=1 \ + -ac_reward=$REWARD \ + -ac_halving=$HALVING \ + -ac_end=$END \ + -ac_eras=$ERAS \ + -ac_blocktime=$BLOCKTIME \ + -ac_cc=2 -ac_ccenable=$CCENABLE \ + -ac_founders=$FOUNDERS -ac_supply=$SUPPLY \ + -ac_perc=$PERC \ + -clientname=$CLIENTNAME \ + -addnode=$SEEDNODE1 \ + -addnode=$SEEDNODE2 \ + -addnode=$SEEDNODE3 \ + -ac_cclib=$CCLIB \ + -ac_script=$SCRIPT "$@" From 9b474d444756e2a84b958b3f4b0f29b9e9b0c320 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Jul 2019 10:38:27 -0700 Subject: [PATCH 139/171] Add HUSH3 to assetchains.(old|json) --- src/assetchains.json | 22 ++++++++++++++++++++++ src/assetchains.old | 1 + 2 files changed, 23 insertions(+) diff --git a/src/assetchains.json b/src/assetchains.json index 86dc77565..910f19dd3 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -268,5 +268,27 @@ "ac_supply": "64000777", "ac_staked": "10", "addnode": ["18.197.20.21"] + }, + { + "ac_name": "HUSH3", + "ac_founders": "1", + "ac_reward": "0,1125000000,562500000" + "ac_end": "128,340000,5422111", + "ac_blocktime": "150", + "ac_supply": "6178674", + "ac_halving": "129,340000,840000", + "ac_cc": "2", + "ac_cclib": "hush3", + "ac_ccenable": "228,234,235,236,241", + "ac_supply": "100000000", + "ac_eras": "3", + "ac_script": "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac", + "ac_sapling": "1", + "clientname": "GoldenSandtrout", + "addnode": [ + "188.165.212.101", + "136.243.227.142", + "5.9.224.250" + ] } ] diff --git a/src/assetchains.old b/src/assetchains.old index 1784bf2e1..8ee0b7daa 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -52,3 +52,4 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=KOIN -ac_supply=125000000 -addnode=3.0.32.10 & ./komodod -pubkey=$pubkey -ac_name=ZEXO -ac_supply=100000000 -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_ccenable=236 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02713bd85e054db923694b6b7a85306264edf4d6bd6d331814f2b40af444b3ebbc -ac_public=1 -addnode=80.240.17.222 & ./komodod -pubkey=$pubkey -ac_name=K64 -ac_supply=64000777 -ac_reward=0 -ac_staked=10 -addnode=18.197.20.211 & +./komodod -pubkey=$pubkey -ac_name=HUSH3 -ac_sapling=1 -ac_reward=0,1125000000,562500000 -ac_halving=129,340000,840000 -ac_end=128,340000,5422111 -ac_eras=3 -ac_blocktime=150 -ac_cc=2 -ac_ccenable=228,234,235,236,241 -ac_founders=1 -ac_supply=6178674 -ac_perc=11111111 -clientname=GoldenSandtrout -addnode=188.165.212.101 -addnode=136.243.227.142 -addnode=5.9.224.250 -ac_cclib=hush3 -ac_script=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac & From 8f5cbc8af21d0e1b8c04ad8405088d3fa8953ff5 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Jul 2019 10:55:31 -0700 Subject: [PATCH 140/171] Missing comma --- src/assetchains.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 910f19dd3..0b4b1644e 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -272,7 +272,7 @@ { "ac_name": "HUSH3", "ac_founders": "1", - "ac_reward": "0,1125000000,562500000" + "ac_reward": "0,1125000000,562500000", "ac_end": "128,340000,5422111", "ac_blocktime": "150", "ac_supply": "6178674", From 7d5af489141d79879710d65715137bdefe4f6eca Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Jul 2019 10:59:36 -0700 Subject: [PATCH 141/171] Remove duplicate ac_supply and add ac_perc --- src/assetchains.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index 0b4b1644e..20dd04ee2 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -271,6 +271,7 @@ }, { "ac_name": "HUSH3", + "ac_sapling": "1", "ac_founders": "1", "ac_reward": "0,1125000000,562500000", "ac_end": "128,340000,5422111", @@ -280,10 +281,9 @@ "ac_cc": "2", "ac_cclib": "hush3", "ac_ccenable": "228,234,235,236,241", - "ac_supply": "100000000", + "ac_perc": "11111111", "ac_eras": "3", "ac_script": "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac", - "ac_sapling": "1", "clientname": "GoldenSandtrout", "addnode": [ "188.165.212.101", From d9617c68fd51617d3cb005d94f6b2ea49c8fbdd9 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 12 Jul 2019 11:05:56 -0700 Subject: [PATCH 142/171] Add fiat script --- src/fiat/hush | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 src/fiat/hush diff --git a/src/fiat/hush b/src/fiat/hush new file mode 100755 index 000000000..3d7a3425d --- /dev/null +++ b/src/fiat/hush @@ -0,0 +1,7 @@ +#!/bin/bash + +#set working directory to the location of this script +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $DIR + +../komodo-cli -ac_name=HUSH3 "$@" From 152c86ce849b349b3e905a4e4e1832c80ca7a66f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 16:39:33 -1100 Subject: [PATCH 143/171] Fix MAXERAS crash (split array overflow) --- src/komodo_defs.h | 2 +- src/komodo_globals.h | 2 +- src/komodo_utils.h | 16 ++++++++-------- src/main.cpp | 2 +- src/util.cpp | 4 ++-- src/util.h | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 748f9ee7a..5074b4303 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -274,7 +274,7 @@ extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOM extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET; extern bool VERUS_MINTBLOCKS; -extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; +extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index c350020b6..9ffa147ea 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -74,7 +74,7 @@ uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0,ASSETCHAINS_CBOPRET=0; uint64_t ASSETCHAINS_LASTERA = 1; -uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1]; +uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS]; uint8_t ASSETCHAINS_CCDISABLES[256]; std::vector ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 57d652309..ab58326af 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1758,10 +1758,10 @@ void komodo_args(char *argv0) ASSETCHAINS_PUBLIC = GetArg("-ac_public",0); ASSETCHAINS_PRIVATE = GetArg("-ac_private",0); KOMODO_SNAPSHOT_INTERVAL = GetArg("-ac_snapshot",0); - Split(GetArg("-ac_nk",""), ASSETCHAINS_NK, 0); + Split(GetArg("-ac_nk",""), sizeof(ASSETCHAINS_NK)/sizeof(*ASSETCHAINS_NK), ASSETCHAINS_NK, 0); // -ac_ccactivateht=evalcode,height,evalcode,height,evalcode,height.... - Split(GetArg("-ac_ccactivateht",""), ccEnablesHeight, 0); + Split(GetArg("-ac_ccactivateht",""), sizeof(ccEnablesHeight)/sizeof(*ccEnablesHeight), ccEnablesHeight, 0); // fill map with all eval codes and activation height of 0. for ( int i = 0; i < 256; i++ ) mapHeightEvalActivate[i] = 0; @@ -1833,11 +1833,11 @@ void komodo_args(char *argv0) ASSETCHAINS_TIMEUNLOCKFROM = ASSETCHAINS_TIMEUNLOCKTO = 0; } - Split(GetArg("-ac_end",""), ASSETCHAINS_ENDSUBSIDY, 0); - Split(GetArg("-ac_reward",""), ASSETCHAINS_REWARD, 0); - Split(GetArg("-ac_halving",""), ASSETCHAINS_HALVING, 0); - Split(GetArg("-ac_decay",""), ASSETCHAINS_DECAY, 0); - Split(GetArg("-ac_notarypay",""), ASSETCHAINS_NOTARY_PAY, 0); + Split(GetArg("-ac_end",""), sizeof(ASSETCHAINS_ENDSUBSIDY)/sizeof(*ASSETCHAINS_ENDSUBSIDY), ASSETCHAINS_ENDSUBSIDY, 0); + Split(GetArg("-ac_reward",""), sizeof(ASSETCHAINS_REWARD)/sizeof(*ASSETCHAINS_REWARD), ASSETCHAINS_REWARD, 0); + Split(GetArg("-ac_halving",""), sizeof(ASSETCHAINS_HALVING)/sizeof(*ASSETCHAINS_HALVING), ASSETCHAINS_HALVING, 0); + Split(GetArg("-ac_decay",""), sizeof(ASSETCHAINS_DECAY)/sizeof(*ASSETCHAINS_DECAY), ASSETCHAINS_DECAY, 0); + Split(GetArg("-ac_notarypay",""), sizeof(ASSETCHAINS_NOTARY_PAY)/sizeof(*ASSETCHAINS_NOTARY_PAY), ASSETCHAINS_NOTARY_PAY, 0); for ( int i = 0; i < ASSETCHAINS_MAX_ERAS; i++ ) { @@ -1906,7 +1906,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_CC != 0 ) { ASSETCHAINS_CCLIB = GetArg("-ac_cclib",""); - Split(GetArg("-ac_ccenable",""), ccenables, 0); + Split(GetArg("-ac_ccenable",""), sizeof(ccenables)/sizeof(*ccenables), ccenables, 0); for (i=nonz=0; i<0x100; i++) { if ( ccenables[i] != 0 ) diff --git a/src/main.cpp b/src/main.cpp index 34708bef7..a8f333aa8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2407,7 +2407,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) //uint64_t komodo_moneysupply(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1]; +extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS]; extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; diff --git a/src/util.cpp b/src/util.cpp index 1aa079085..9daecb63e 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -414,7 +414,7 @@ void SplitStr(const std::string& strVal, std::vector &outVals) } } -void Split(const std::string& strVal, uint64_t *outVals, const uint64_t nDefault) +void Split(const std::string& strVal, int32_t outsize, uint64_t *outVals, const uint64_t nDefault) { stringstream ss(strVal); vector vec; @@ -442,7 +442,7 @@ void Split(const std::string& strVal, uint64_t *outVals, const uint64_t nDefault else nLast = nDefault; - for ( i = numVals; i < ASSETCHAINS_MAX_ERAS; i++ ) + for ( i = numVals; i < outsize; i++ ) { outVals[i] = nLast; } diff --git a/src/util.h b/src/util.h index 617faaf36..17bf19952 100644 --- a/src/util.h +++ b/src/util.h @@ -185,7 +185,7 @@ inline bool IsSwitchChar(char c) * else if the string has fewer than _MAX_ERAS entries, then the last * entry fills remaining entries */ -void Split(const std::string& strVal, uint64_t *outVals, uint64_t nDefault); +void Split(const std::string& strVal, int32_t outsize, uint64_t *outVals, uint64_t nDefault); /** * Return string argument or default value From 043199aa4a955a8896dc45f721b0aa398e7ff511 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 16:42:15 -1100 Subject: [PATCH 144/171] Merge --- src/komodo_globals.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index cd1ed5b6a..53e304a9b 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -46,11 +46,8 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = _COINBASE_MATURITY;//100; unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; uint256 KOMODO_EARLYTXID; -<<<<<<< HEAD + int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,KOMODO_NSPV; -======= -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY; ->>>>>>> dev int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA; From 5af5292f52105531ee9d44513b8c219c7d4ba5a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 16:50:50 -1100 Subject: [PATCH 145/171] sizeof(ASSETCHAINS_PEGSCCPARAMS)/sizeof(*ASSETCHAINS_PEGSCCPARAMS) --- src/komodo_nSPV.h | 1 + src/komodo_utils.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index 069ddb4ab..d7c6ebfc8 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -17,6 +17,7 @@ // todo: // myprivkey, scrub all destination buffers +// oversized tx // headers "sync" make sure it connects to prior blocks to notarization. use getinfo hdrht to get missing hdrs diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fbbe4c677..5d6f2722b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1973,7 +1973,7 @@ void komodo_args(char *argv0) } else if ( ASSETCHAINS_SELFIMPORT == "PEGSCC") { - Split(GetArg("-ac_pegsccparams",""), ASSETCHAINS_PEGSCCPARAMS, 0); + Split(GetArg("-ac_pegsccparams",""), sizeof(ASSETCHAINS_PEGSCCPARAMS)/sizeof(*ASSETCHAINS_PEGSCCPARAMS), ASSETCHAINS_PEGSCCPARAMS, 0); if (ASSETCHAINS_ENDSUBSIDY[0]!=1 || ASSETCHAINS_COMMISSION!=0) { fprintf(stderr,"when using import for pegsCC these must be set: -ac_end=1 -ac_perc=0\n"); From e4c67ed018e99702aeac1833aa225281b7716a4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 16:57:51 -1100 Subject: [PATCH 146/171] sizeof(ASSETCHAINS_PEGSCCPARAMS)/sizeof(*ASSETCHAINS_PEGSCCPARAMS) --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fbbe4c677..5d6f2722b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1973,7 +1973,7 @@ void komodo_args(char *argv0) } else if ( ASSETCHAINS_SELFIMPORT == "PEGSCC") { - Split(GetArg("-ac_pegsccparams",""), ASSETCHAINS_PEGSCCPARAMS, 0); + Split(GetArg("-ac_pegsccparams",""), sizeof(ASSETCHAINS_PEGSCCPARAMS)/sizeof(*ASSETCHAINS_PEGSCCPARAMS), ASSETCHAINS_PEGSCCPARAMS, 0); if (ASSETCHAINS_ENDSUBSIDY[0]!=1 || ASSETCHAINS_COMMISSION!=0) { fprintf(stderr,"when using import for pegsCC these must be set: -ac_end=1 -ac_perc=0\n"); From 92a8d1f89e4fd4d3dc831bf45aaf135291eae5fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 18:04:41 -1100 Subject: [PATCH 147/171] +print --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index f3b714eaa..47a39129c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8062,6 +8062,7 @@ bool ProcessMessages(CNode* pfrom) // (x) data // bool fOk = true; +fprintf(stderr,"process messages\n"); if (!pfrom->vRecvGetData.empty()) ProcessGetData(pfrom); @@ -8175,7 +8176,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Don't send anything until we get its version message if (pto->nVersion == 0) return true; - +fprintf(stderr,"send messages\n"); // // Message: ping // From 96daa77e34f044482125775b713c2b62b1b8df23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 18:12:23 -1100 Subject: [PATCH 148/171] -orint --- src/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 47a39129c..f3b714eaa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8062,7 +8062,6 @@ bool ProcessMessages(CNode* pfrom) // (x) data // bool fOk = true; -fprintf(stderr,"process messages\n"); if (!pfrom->vRecvGetData.empty()) ProcessGetData(pfrom); @@ -8176,7 +8175,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Don't send anything until we get its version message if (pto->nVersion == 0) return true; -fprintf(stderr,"send messages\n"); + // // Message: ping // From 506cf51b629036492f423a85634e8dd4e152574e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 18:18:10 -1100 Subject: [PATCH 149/171] -lock --- src/komodo_nSPV_superlite.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index 3215abab3..d8a1b8f1e 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -207,7 +207,7 @@ CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind) if ( pnode == 0 ) { memset(pnodes,0,sizeof(pnodes)); - LOCK(cs_vNodes); + //LOCK(cs_vNodes); n = 0; BOOST_FOREACH(CNode *ptr,vNodes) { From 4701a9c2f6699dc36d2bfb6960687562ecf28308 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 18:22:29 -1100 Subject: [PATCH 150/171] Longer poll --- src/komodo_nSPV_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h index c72fb2aeb..efbe7d7ae 100644 --- a/src/komodo_nSPV_defs.h +++ b/src/komodo_nSPV_defs.h @@ -17,7 +17,7 @@ #ifndef KOMODO_NSPV_DEFSH #define KOMODO_NSPV_DEFSH -#define NSPV_POLLITERS 15 +#define NSPV_POLLITERS 50 #define NSPV_POLLMICROS 100000 #define NSPV_MAXVINS 64 #define NSPV_AUTOLOGOUT 777 From eafa3f703da26769aa19515bceb4ff3d2cdd35d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 18:38:44 -1100 Subject: [PATCH 151/171] 10 second timeout --- src/komodo_nSPV_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h index efbe7d7ae..2a7a88b22 100644 --- a/src/komodo_nSPV_defs.h +++ b/src/komodo_nSPV_defs.h @@ -17,7 +17,7 @@ #ifndef KOMODO_NSPV_DEFSH #define KOMODO_NSPV_DEFSH -#define NSPV_POLLITERS 50 +#define NSPV_POLLITERS 100 #define NSPV_POLLMICROS 100000 #define NSPV_MAXVINS 64 #define NSPV_AUTOLOGOUT 777 From 223152deab0ebf0c2d0f08f48618750fc397eda8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 18:39:02 -1100 Subject: [PATCH 152/171] 5 seconds --- src/komodo_nSPV_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h index 2a7a88b22..588636dc2 100644 --- a/src/komodo_nSPV_defs.h +++ b/src/komodo_nSPV_defs.h @@ -18,7 +18,7 @@ #define KOMODO_NSPV_DEFSH #define NSPV_POLLITERS 100 -#define NSPV_POLLMICROS 100000 +#define NSPV_POLLMICROS 50000 #define NSPV_MAXVINS 64 #define NSPV_AUTOLOGOUT 777 #define NSPV_BRANCHID 0x76b809bb From faa44230c1d15fdbf6e9f256a41d34e529da35f3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 19:38:15 -1100 Subject: [PATCH 153/171] Bigtxlen --- src/komodo_nSPV.h | 11 ++++------- src/komodo_nSPV_defs.h | 6 ++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index d7c6ebfc8..84bb67af1 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -66,11 +66,11 @@ int32_t iguana_rwequihdrvec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsize return(len); } -int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsizep,uint8_t **ptrp) +int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,uint32_t *biglenp,uint8_t **ptrp) { int32_t vsize,len = 0; - len += iguana_rwnum(rwflag,&serialized[len],sizeof(*vecsizep),vecsizep); - if ( (vsize= *vecsizep) != 0 ) + len += iguana_rwnum(rwflag,&serialized[len],sizeof(*biglenp),biglenp); + if ( (vsize= *biglenp) != 0 && vsize < MAX_TX_SIZE_AFTER_SAPLING ) { if ( *ptrp == 0 ) *ptrp = (uint8_t *)calloc(1,vsize); // relies on uint16_t being "small" to prevent mem exhaustion @@ -195,7 +195,6 @@ int32_t NSPV_rwtxproof(int32_t rwflag,uint8_t *serialized,struct NSPV_txproof *p len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->unspentvalue),&ptr->unspentvalue); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad),&ptr->pad); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txlen,&ptr->tx); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txprooflen,&ptr->txproof); return(len); @@ -204,7 +203,7 @@ int32_t NSPV_rwtxproof(int32_t rwflag,uint8_t *serialized,struct NSPV_txproof *p void NSPV_txproof_copy(struct NSPV_txproof *dest,struct NSPV_txproof *ptr) { *dest = *ptr; - if ( ptr->tx != 0 ) + if ( ptr->tx != 0 && ptr->txlen < MAX_TX_SIZE_AFTER_SAPLING ) { dest->tx = (uint8_t *)malloc(ptr->txlen); memcpy(dest->tx,ptr->tx,ptr->txlen); @@ -234,7 +233,6 @@ int32_t NSPV_rwntzproofshared(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz len += iguana_rwequihdrvec(rwflag,&serialized[len],&ptr->numhdrs,&ptr->hdrs); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->prevht),&ptr->prevht); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nextht),&ptr->nextht); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad32),&ptr->pad32); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad16),&ptr->pad16); //fprintf(stderr,"rwcommon prev.%d next.%d\n",ptr->prevht,ptr->nextht); return(len); @@ -246,7 +244,6 @@ int32_t NSPV_rwntzsproofresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzs len += NSPV_rwntzproofshared(rwflag,&serialized[len],&ptr->common); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->prevtxid),(uint8_t *)&ptr->prevtxid); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->nexttxid),(uint8_t *)&ptr->nexttxid); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad32),&ptr->pad32); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->prevtxidht),&ptr->prevtxidht); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nexttxidht),&ptr->nexttxidht); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->prevtxlen,&ptr->prevntz); diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h index 588636dc2..31c53fa22 100644 --- a/src/komodo_nSPV_defs.h +++ b/src/komodo_nSPV_defs.h @@ -97,8 +97,7 @@ struct NSPV_txproof { uint256 txid; int64_t unspentvalue; - int32_t height,vout,pad; - uint16_t txlen,txprooflen; + int32_t height,vout,txlen,txprooflen; uint8_t *tx,*txproof; }; @@ -113,8 +112,7 @@ struct NSPV_ntzsproofresp { struct NSPV_ntzproofshared common; uint256 prevtxid,nexttxid; - int32_t pad32,prevtxidht,nexttxidht; - uint16_t prevtxlen,nexttxlen; + int32_t prevtxidht,nexttxidht,prevtxlen,nexttxlen; uint8_t *prevntz,*nextntz; }; From e43eb755e7ffa2c68e2673291a8542ea6c26f2c5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 19:43:37 -1100 Subject: [PATCH 154/171] Uint --- src/komodo_nSPV.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index 84bb67af1..642c6ed8d 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -66,11 +66,11 @@ int32_t iguana_rwequihdrvec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsize return(len); } -int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,uint32_t *biglenp,uint8_t **ptrp) +int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,int32_t *biglenp,uint8_t **ptrp) { int32_t vsize,len = 0; len += iguana_rwnum(rwflag,&serialized[len],sizeof(*biglenp),biglenp); - if ( (vsize= *biglenp) != 0 && vsize < MAX_TX_SIZE_AFTER_SAPLING ) + if ( (vsize= *biglenp) > 0 && vsize < MAX_TX_SIZE_AFTER_SAPLING ) { if ( *ptrp == 0 ) *ptrp = (uint8_t *)calloc(1,vsize); // relies on uint16_t being "small" to prevent mem exhaustion From 978d16a32b03d4222b73136b0289f1ed84b69834 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 19:45:04 -1100 Subject: [PATCH 155/171] int32_t --- src/komodo_nSPV_fullnode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index da15c82e1..6300a77dd 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -185,7 +185,7 @@ int32_t NSPV_getaddressutxos(struct NSPV_utxosresp *ptr,char *coinaddr,bool isCC return(0); } -uint8_t *NSPV_getrawtx(CTransaction &tx,uint256 &hashBlock,uint16_t *txlenp,uint256 txid) +uint8_t *NSPV_getrawtx(CTransaction &tx,uint256 &hashBlock,int32_t *txlenp,uint256 txid) { uint8_t *rawtx = 0; *txlenp = 0; From c7d0054214619f95958a28878f887c2f850367f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 20:42:45 -1100 Subject: [PATCH 156/171] int16 -> int32 --- src/komodo_nSPV.h | 4 ++-- src/komodo_nSPV_fullnode.h | 7 +++---- src/komodo_nSPV_superlite.h | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index 642c6ed8d..6500b9688 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -29,7 +29,7 @@ #ifndef KOMODO_NSPV_H #define KOMODO_NSPV_H -int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,uint16_t len,uint8_t *buf) +int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *buf) { if ( rwflag != 0 ) memcpy(serialized,buf,len); @@ -73,7 +73,7 @@ int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,int32_t *biglenp,ui if ( (vsize= *biglenp) > 0 && vsize < MAX_TX_SIZE_AFTER_SAPLING ) { if ( *ptrp == 0 ) - *ptrp = (uint8_t *)calloc(1,vsize); // relies on uint16_t being "small" to prevent mem exhaustion + *ptrp = (uint8_t *)calloc(1,vsize); len += iguana_rwbuf(rwflag,&serialized[len],vsize,*ptrp); } return(len); diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 6300a77dd..2479d0cdc 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -190,7 +190,6 @@ uint8_t *NSPV_getrawtx(CTransaction &tx,uint256 &hashBlock,int32_t *txlenp,uint2 uint8_t *rawtx = 0; *txlenp = 0; { - LOCK(cs_main); if (!GetTransaction(txid, tx, hashBlock, false)) return(0); string strHex = EncodeHexTx(tx); @@ -210,7 +209,7 @@ int32_t NSPV_sendrawtransaction(struct NSPV_broadcastresp *ptr,uint8_t *data,int ptr->retcode = 0; if ( NSPV_txextract(tx,data,n) == 0 ) { - LOCK(cs_main); + //LOCK(cs_main); ptr->txid = tx.GetHash(); //fprintf(stderr,"try to addmempool transaction %s\n",ptr->txid.GetHex().c_str()); if ( myAddtomempool(tx) != 0 ) @@ -496,14 +495,14 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req { if ( timestamp > pfrom->prevtimes[ind] ) { - struct NSPV_broadcastresp B; uint16_t n,offset; uint256 txid; + struct NSPV_broadcastresp B; uint32_t n,offset; uint256 txid; if ( len > 1+sizeof(txid)+sizeof(n) ) { iguana_rwbignum(0,&request[1],sizeof(txid),(uint8_t *)&txid); iguana_rwnum(0,&request[1+sizeof(txid)],sizeof(n),&n); memset(&B,0,sizeof(B)); offset = 1 + sizeof(txid) + sizeof(n); - if ( request.size() == offset+n && (slen= NSPV_sendrawtransaction(&B,&request[offset],n)) > 0 ) + if ( n < MAX_TX_SIZE_AFTER_SAPLING && request.size() == offset+n && (slen= NSPV_sendrawtransaction(&B,&request[offset],n)) > 0 ) { response.resize(1 + slen); response[0] = NSPV_BROADCASTRESP; diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index d8a1b8f1e..259f9cbc3 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -593,7 +593,7 @@ UniValue NSPV_txidhdrsproof(uint256 prevtxid,uint256 nexttxid) msg[len++] = NSPV_NTZSPROOF; len += iguana_rwbignum(1,&msg[len],sizeof(prevtxid),(uint8_t *)&prevtxid); len += iguana_rwbignum(1,&msg[len],sizeof(nexttxid),(uint8_t *)&nexttxid); - //for (iter=0; iter<3; iter++); + for (iter=0; iter<3; iter++); if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) { for (i=0; i> 1; data = (uint8_t *)malloc(n); From 2487a1079bc2c9b3f3ea678f625f06ecd75acc62 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 21:01:21 -1100 Subject: [PATCH 157/171] Test --- src/komodo_nSPV.h | 1 + src/komodo_nSPV_fullnode.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index 6500b9688..ad805848d 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -248,6 +248,7 @@ int32_t NSPV_rwntzsproofresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzs len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nexttxidht),&ptr->nexttxidht); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->prevtxlen,&ptr->prevntz); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->nexttxlen,&ptr->nextntz); + fprintf(stderr,"retlen.%d\n",len); return(len); } diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 2479d0cdc..069b974ad 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -290,7 +290,7 @@ int32_t NSPV_getntzsproofresp(struct NSPV_ntzsproofresp *ptr,uint256 prevntztxid fprintf(stderr,"illegal prevht.%d nextht.%d\n",ptr->common.prevht,ptr->common.nextht); return(-7); } - //fprintf(stderr,"%s -> prevht.%d, %s -> nexht.%d\n",ptr->prevtxid.GetHex().c_str(),ptr->common.prevht,ptr->nexttxid.GetHex().c_str(),ptr->common.nextht); + fprintf(stderr,"%s -> prevht.%d, %s -> nexht.%d\n",ptr->prevtxid.GetHex().c_str(),ptr->common.prevht,ptr->nexttxid.GetHex().c_str(),ptr->common.nextht); ptr->common.numhdrs = (ptr->common.nextht - ptr->common.prevht + 1); ptr->common.hdrs = (struct NSPV_equihdr *)calloc(ptr->common.numhdrs,sizeof(*ptr->common.hdrs)); //fprintf(stderr,"prev.%d next.%d allocate numhdrs.%d\n",prevht,nextht,ptr->common.numhdrs); @@ -426,9 +426,9 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req iguana_rwbignum(0,&request[1],sizeof(prevntz),(uint8_t *)&prevntz); iguana_rwbignum(0,&request[1+sizeof(prevntz)],sizeof(nextntz),(uint8_t *)&nextntz); memset(&P,0,sizeof(P)); - //fprintf(stderr,"msg prev.%s next.%s\n",prevntz.GetHex().c_str(),nextntz.GetHex().c_str()); if ( (slen= NSPV_getntzsproofresp(&P,prevntz,nextntz)) > 0 ) { + fprintf(stderr,"slen.%d msg prev.%s next.%s\n",slen,prevntz.GetHex().c_str(),nextntz.GetHex().c_str()); response.resize(1 + slen); response[0] = NSPV_NTZSPROOFRESP; if ( NSPV_rwntzsproofresp(1,&response[1],&P) == slen ) @@ -437,7 +437,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req pfrom->prevtimes[ind] = timestamp; } NSPV_ntzsproofresp_purge(&P); - } + } else fprintf(stderr,"err.%d\n",slen); } } } From 7a5a52c89b8a2cd932a3542784b1e037f09e08b5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 21:20:15 -1100 Subject: [PATCH 158/171] +prints --- src/komodo_nSPV_fullnode.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 069b974ad..245a9c79d 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -290,7 +290,7 @@ int32_t NSPV_getntzsproofresp(struct NSPV_ntzsproofresp *ptr,uint256 prevntztxid fprintf(stderr,"illegal prevht.%d nextht.%d\n",ptr->common.prevht,ptr->common.nextht); return(-7); } - fprintf(stderr,"%s -> prevht.%d, %s -> nexht.%d\n",ptr->prevtxid.GetHex().c_str(),ptr->common.prevht,ptr->nexttxid.GetHex().c_str(),ptr->common.nextht); + //fprintf(stderr,"%s -> prevht.%d, %s -> nexht.%d\n",ptr->prevtxid.GetHex().c_str(),ptr->common.prevht,ptr->nexttxid.GetHex().c_str(),ptr->common.nextht); ptr->common.numhdrs = (ptr->common.nextht - ptr->common.prevht + 1); ptr->common.hdrs = (struct NSPV_equihdr *)calloc(ptr->common.numhdrs,sizeof(*ptr->common.hdrs)); //fprintf(stderr,"prev.%d next.%d allocate numhdrs.%d\n",prevht,nextht,ptr->common.numhdrs); @@ -306,6 +306,7 @@ int32_t NSPV_getntzsproofresp(struct NSPV_ntzsproofresp *ptr,uint256 prevntztxid return(-1); } } + fprintf(stderr,"sizeof ptr %ld, common.%ld lens.%d %d\n",sizeof(*ptr),sizeof(ptr->common),ptr->prevtxlen,ptr->nexttxlen); return(sizeof(*ptr) + sizeof(*ptr->common.hdrs)*ptr->common.numhdrs - sizeof(ptr->common.hdrs) - sizeof(ptr->prevntz) - sizeof(ptr->nextntz) + ptr->prevtxlen + ptr->nexttxlen); } From 5bd1c6b9b1bb925222dafc5525ccc8b2de45808f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 21:34:27 -1100 Subject: [PATCH 159/171] Fix padding --- src/komodo_nSPV.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index ad805848d..24f4a221e 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -233,6 +233,7 @@ int32_t NSPV_rwntzproofshared(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz len += iguana_rwequihdrvec(rwflag,&serialized[len],&ptr->numhdrs,&ptr->hdrs); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->prevht),&ptr->prevht); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nextht),&ptr->nextht); + len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad32),&ptr->pad32); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad16),&ptr->pad16); //fprintf(stderr,"rwcommon prev.%d next.%d\n",ptr->prevht,ptr->nextht); return(len); From ef9b319f96939a4c435c7cd106a355ae9dbcae1d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 21:43:15 -1100 Subject: [PATCH 160/171] Error check --- src/komodo_nSPV.h | 15 +++++++++------ src/komodo_nSPV_fullnode.h | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index 24f4a221e..67bfd6bb0 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -249,7 +249,7 @@ int32_t NSPV_rwntzsproofresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzs len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nexttxidht),&ptr->nexttxidht); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->prevtxlen,&ptr->prevntz); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->nexttxlen,&ptr->nextntz); - fprintf(stderr,"retlen.%d\n",len); + //fprintf(stderr,"retlen.%d\n",len); return(len); } @@ -349,11 +349,14 @@ uint256 NSPV_hdrhash(struct NSPV_equihdr *hdr) int32_t NSPV_txextract(CTransaction &tx,uint8_t *data,int32_t datalen) { std::vector rawdata; - rawdata.resize(datalen); - memcpy(&rawdata[0],data,datalen); - if ( DecodeHexTx(tx,HexStr(rawdata)) != 0 ) - return(0); - else return(-1); + if ( datalen < MAX_TX_SIZE_AFTER_SAPLING ) + { + rawdata.resize(datalen); + memcpy(&rawdata[0],data,datalen); + if ( DecodeHexTx(tx,HexStr(rawdata)) != 0 ) + return(0); + } + return(-1); } bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey,uint32_t nTime); diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 245a9c79d..9e44df3a7 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -306,7 +306,7 @@ int32_t NSPV_getntzsproofresp(struct NSPV_ntzsproofresp *ptr,uint256 prevntztxid return(-1); } } - fprintf(stderr,"sizeof ptr %ld, common.%ld lens.%d %d\n",sizeof(*ptr),sizeof(ptr->common),ptr->prevtxlen,ptr->nexttxlen); + //fprintf(stderr,"sizeof ptr %ld, common.%ld lens.%d %d\n",sizeof(*ptr),sizeof(ptr->common),ptr->prevtxlen,ptr->nexttxlen); return(sizeof(*ptr) + sizeof(*ptr->common.hdrs)*ptr->common.numhdrs - sizeof(ptr->common.hdrs) - sizeof(ptr->prevntz) - sizeof(ptr->nextntz) + ptr->prevtxlen + ptr->nexttxlen); } @@ -429,7 +429,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req memset(&P,0,sizeof(P)); if ( (slen= NSPV_getntzsproofresp(&P,prevntz,nextntz)) > 0 ) { - fprintf(stderr,"slen.%d msg prev.%s next.%s\n",slen,prevntz.GetHex().c_str(),nextntz.GetHex().c_str()); + // fprintf(stderr,"slen.%d msg prev.%s next.%s\n",slen,prevntz.GetHex().c_str(),nextntz.GetHex().c_str()); response.resize(1 + slen); response[0] = NSPV_NTZSPROOFRESP; if ( NSPV_rwntzsproofresp(1,&response[1],&P) == slen ) From f9b2683ceedc47a2ab970c76efb78a0cf4d64d5a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 21:45:41 -1100 Subject: [PATCH 161/171] -sleep --- src/komodo_nSPV_wallet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 0de278539..c48358f33 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -44,7 +44,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr) if ( blockhash != ptr->common.hdrs[i].hashPrevBlock ) return(-i-13); } - sleep(1); + //sleep(1); if ( NSPV_txextract(tx,ptr->prevntz,ptr->prevtxlen) < 0 ) return(-8); else if ( tx.GetHash() != ptr->prevtxid ) From a3c673629407e4ad4d9afb11a56dfd80b55bf394 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 21:47:38 -1100 Subject: [PATCH 162/171] Revert --- src/komodo_nSPV_wallet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index c48358f33..677977723 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -44,7 +44,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr) if ( blockhash != ptr->common.hdrs[i].hashPrevBlock ) return(-i-13); } - //sleep(1); + sleep(1); // need this to get past the once per second rate limiter per message if ( NSPV_txextract(tx,ptr->prevntz,ptr->prevtxlen) < 0 ) return(-8); else if ( tx.GetHash() != ptr->prevtxid ) From 097f94b78ebe0768c93053ed6ac66832128e6621 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 21:55:38 -1100 Subject: [PATCH 163/171] -print --- src/komodo_nSPV_wallet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 677977723..d7ff5e1a7 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -61,7 +61,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr) int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum) { struct NSPV_txproof *ptr; int32_t i,offset,retval = 0; int64_t rewards = 0; uint32_t nLockTime; std::vector proof; - fprintf(stderr,"NSPV_gettx %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height); + //fprintf(stderr,"NSPV_gettx %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height); if ( (ptr= NSPV_txproof_find(txid)) == 0 ) { NSPV_txproof(vout,txid,height); From f963001d0b69cb8feca769bad5aec4e7151d97ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 22:07:56 -1100 Subject: [PATCH 164/171] Reduce getinfo footprint --- src/rpc/misc.cpp | 91 +++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 95c2cc343..384b487b2 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -222,17 +222,17 @@ UniValue getinfo(const UniValue& params, bool fHelp) + HelpExampleCli("getinfo", "") + HelpExampleRpc("getinfo", "") ); -//#ifdef ENABLE_WALLET -// LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); -//#else + //#ifdef ENABLE_WALLET + // LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); + //#else LOCK(cs_main); -//#endif - + //#endif + proxyType proxy; GetProxy(NET_IPV4, proxy); notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); - + UniValue obj(UniValue::VOBJ); obj.push_back(Pair("version", CLIENT_VERSION)); obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); @@ -243,50 +243,54 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("prevMoMheight", prevMoMheight)); obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); - txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); - if ( txid_height > 0 ) - obj.push_back(Pair("notarizedtxid_height", txid_height)); - else obj.push_back(Pair("notarizedtxid_height", "mempool")); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); - obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); - //fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL)); + if ( KOMODO_NSPV == 0 ) + { + txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); + if ( txid_height > 0 ) + obj.push_back(Pair("notarizedtxid_height", txid_height)); + else obj.push_back(Pair("notarizedtxid_height", "mempool")); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); + obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); + //fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL)); #ifdef ENABLE_WALLET - if (pwalletMain) { - obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM))); - obj.push_back(Pair("balance", ValueFromAmount(KOMODO_WALLETBALANCE))); //pwalletMain->GetBalance() + if (pwalletMain) { + obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM))); + obj.push_back(Pair("balance", ValueFromAmount(KOMODO_WALLETBALANCE))); //pwalletMain->GetBalance() + } + else + { + obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); // + } } - else - { - obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); // - } - } #endif - //fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); - obj.push_back(Pair("blocks", (int)chainActive.Height())); - if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) - longestchain = chainActive.Height(); - //fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL)); - obj.push_back(Pair("longestchain", longestchain)); + //fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); + obj.push_back(Pair("blocks", (int)chainActive.Height())); + if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) + longestchain = chainActive.Height(); + //fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL)); + obj.push_back(Pair("longestchain", longestchain)); + if ( chainActive.LastTip() != 0 ) + obj.push_back(Pair("tiptime", (int)chainActive.LastTip()->nTime)); + obj.push_back(Pair("difficulty", (double)GetDifficulty())); +#ifdef ENABLE_WALLET + if (pwalletMain) { + obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); + obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); + } + if (pwalletMain && pwalletMain->IsCrypted()) + obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); + obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); +#endif + obj.push_back(Pair("sapling", ASSETCHAINS_SAPLING)); + } obj.push_back(Pair("timeoffset", GetTimeOffset())); - if ( chainActive.LastTip() != 0 ) - obj.push_back(Pair("tiptime", (int)chainActive.LastTip()->nTime)); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()))); - obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); -#ifdef ENABLE_WALLET - if (pwalletMain) { - obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); - obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); - } - if (pwalletMain && pwalletMain->IsCrypted()) - obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); - obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); -#endif obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); if ( NOTARY_PUBKEY33[0] != 0 ) { @@ -304,7 +308,6 @@ UniValue getinfo(const UniValue& params, bool fHelp) if ( ASSETCHAINS_CC != 0 ) obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC)); obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); - obj.push_back(Pair("sapling", ASSETCHAINS_SAPLING)); obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT)); obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT)); From bb2a16729cbb72d33359cd35f7b860dc1f80c412 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 13 Jul 2019 03:29:54 -1100 Subject: [PATCH 165/171] Revert to coquicash magic, fix disable bits setting --- src/komodo_utils.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ab58326af..a9a06c80f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1905,13 +1905,15 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_CC != 0 ) { + uint8_t prevCCi = 0; ASSETCHAINS_CCLIB = GetArg("-ac_cclib",""); Split(GetArg("-ac_ccenable",""), sizeof(ccenables)/sizeof(*ccenables), ccenables, 0); for (i=nonz=0; i<0x100; i++) { - if ( ccenables[i] != 0 ) + if ( ccenables[i] != prevCCi && ccenables[i] != 0 ) { nonz++; + prevCCi = ccenables[i]; fprintf(stderr,"%d ",(uint8_t)(ccenables[i] & 0xff)); } } @@ -1923,11 +1925,12 @@ void komodo_args(char *argv0) ASSETCHAINS_CCDISABLES[i] = 1; SETBIT(disablebits,i); } - for (i=0; i<256; i++) + for (i=0; i 0 ) { From 3661d19dffe5b7db43aa46dc63dcb72aeb7d3850 Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Sun, 14 Jul 2019 01:22:13 +0800 Subject: [PATCH 166/171] Create ac.json alternative to assetchains.json with ac_name as unique key --- src/ac.json | 340 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100644 src/ac.json diff --git a/src/ac.json b/src/ac.json new file mode 100644 index 000000000..5d0052730 --- /dev/null +++ b/src/ac.json @@ -0,0 +1,340 @@ +[{ + "REVS": { + "ac_supply": "1300000" + } + }, + { + "SUPERNET": { + "ac_supply": "816061" + } + }, + { + "DEX": { + "ac_supply": "999999" + } + }, + { + "PANGEA": { + "ac_supply": "999999" + } + }, + { + "JUMBLR": { + "ac_supply": "999999" + } + }, + { + "BET": { + "ac_supply": "999999" + } + }, + { + "CRYPTO": { + "ac_supply": "999999" + } + }, + { + "HODL": { + "ac_supply": "9999999" + } + }, + { + "MSHARK": { + "ac_supply": "1400000" + } + }, + { + "BOTS": { + "ac_supply": "999999" + } + }, + { + "MGW": { + "ac_supply": "999999" + } + }, + { + "COQUI": { + "ac_supply": "72000000", + "ac_ccactivate": "200000" + } + }, + { + "WLC": { + "ac_supply": "210000000" + } + }, + { + "KV": { + "ac_supply": "1000000" + } + }, + { + "CEAL": { + "ac_supply": "366666666" + } + }, + { + "MESH": { + "ac_supply": "1000007" + } + }, + { + "AXO": { + "ac_supply": "200000000", + "ac_ccactivate": "130000" + } + }, + { + "ETOMIC": { + "ac_supply": "100000000" + } + }, + { + "BTCH": { + "ac_supply": "20998641" + } + }, + { + "PIZZA": { + "ac_supply": "100000000" + } + }, + { + "BEER": { + "ac_supply": "100000000" + } + }, + { + "NINJA": { + "ac_supply": "100000000" + } + }, + { + "OOT": { + "ac_supply": "216000000", + "ac_sapling": "5000000" + } + }, + { + "BNTN": { + "ac_supply": "500000000" + } + }, + { + "CHAIN": { + "ac_supply": "999999" + } + }, + { + "PRLPAY": { + "ac_supply": "500000000" + } + }, + { + "DSEC": { + "ac_supply": "7000000" + } + }, + { + "GLXT": { + "ac_supply": "10000000000" + } + }, + { + "EQL": { + "ac_supply": "500000000", + "ac_ccactivate": "205000" + } + }, + { + "ZILLA": { + "ac_supply": "11000000", + "ac_sapling": "5000000", + "addnode": [ + "51.68.215.104" + ] + } + }, + { + "RFOX": { + "ac_supply": "1000000000", + "ac_reward": "100000000" + } + }, + { + "SEC": { + "ac_supply": "1000000000", + "ac_cc": "333" + } + }, + { + "CCL": { + "ac_supply": "200000000", + "ac_end": "1", + "ac_cc": "2", + "addressindex": "1", + "spentindex": "1", + "addnode": [ + "142.93.136.89", + "195.201.22.89" + ] + } + }, + { + "PIRATE": { + "ac_supply": "0", + "ac_reward": "25600000000", + "ac_halving": "77777", + "ac_private": "1", + "addnode": [ + "136.243.102.225" + ] + } + }, + { + "PGT": { + "ac_supply": "10000000", + "ac_end": "1", + "addnode": [ + "190.114.254.104" + ] + } + }, + { + "DION": { + "ac_supply": "3900000000", + "ac_reward": "22260000000", + "ac_staked": "100", + "ac_cc": "1", + "ac_end": "4300000000", + "addnode": [ + "51.75.124.34" + ] + } + }, + { + "KMDICE": { + "ac_supply": "10500000", + "ac_reward": "2500000000", + "ac_halving": "210000", + "ac_cc": "2", + "addressindex": "1", + "spentindex": "1", + "addnode": [ + "144.76.217.232" + ] + } + }, + { + "KSB": { + "ac_supply": "1000000000", + "ac_end": "1", + "ac_public": "1", + "addnode": [ + "37.187.225.231" + ] + } + }, + { + "OUR": { + "ac_reward": "1478310502", + "ac_halving": "525600", + "ac_cc": "42", + "ac_supply": "100000000", + "ac_perc": "77700", + "ac_staked": "93", + "ac_pubkey": "02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c", + "ac_public": "1", + "addnode": [ + "51.255.195.65", + "217.182.129.38", + "37.187.225.231" + ] + } + }, + { + "ILN": { + "ac_supply": "10000000000", + "ac_cc": "2", + "addnode": ["51.75.122.83"] + } + }, + { + "RICK": { + "ac_supply": "90000000000", + "ac_reward": "100000000", + "ac_cc": "3", + "addnode": ["138.201.136.145"] + } + }, + { + "MORTY": { + "ac_supply": "90000000000", + "ac_reward": "100000000", + "ac_cc": "3", + "addnode": ["138.201.136.145"] + } + }, + { + "VOTE2019": { + "ac_supply": "123651638", + "ac_public": "1", + "addnode": ["95.213.238.98"] + } + }, + { + "KOIN": { + "ac_supply": "125000000", + "addnode": ["3.0.32.10"] + } + }, + { + "ZEXO": { + "ac_reward": "1478310502", + "ac_halving": "525600", + "ac_cc": "42", + "ac_ccenable": "236", + "ac_supply": "100000000", + "ac_perc": "77700", + "ac_staked": "93", + "ac_pubkey": "02713bd85e054db923694b6b7a85306264edf4d6bd6d331814f2b40af444b3ebbc", + "ac_public": "1", + "addnode": [ + "195.201.20.230", + "80.240.17.222" + ] + } + }, + { + "K64": { + "ac_reward": "0", + "ac_supply": "64000777", + "ac_staked": "10", + "addnode": ["18.197.20.21"] + } + }, + { + "HUSH3": { + "ac_sapling": "1", + "ac_founders": "1", + "ac_reward": "0,1125000000,562500000", + "ac_end": "128,340000,5422111", + "ac_blocktime": "150", + "ac_supply": "6178674", + "ac_halving": "129,340000,840000", + "ac_cc": "2", + "ac_cclib": "hush3", + "ac_ccenable": "228,234,235,236,241", + "ac_perc": "11111111", + "ac_eras": "3", + "ac_script": "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac", + "clientname": "GoldenSandtrout", + "addnode": [ + "188.165.212.101", + "136.243.227.142", + "5.9.224.250" + ] + } + } +] From 2ed03590afec86ac57b278a9bc9604a37ce8ca7f Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Sun, 14 Jul 2019 01:25:17 +0800 Subject: [PATCH 167/171] Update ac.json removed outer array --- src/ac.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ac.json b/src/ac.json index 5d0052730..d57dbb8b7 100644 --- a/src/ac.json +++ b/src/ac.json @@ -1,4 +1,4 @@ -[{ +{ "REVS": { "ac_supply": "1300000" } @@ -337,4 +337,3 @@ ] } } -] From 8a20e3a9e7e790f92e0f626fc1dd1ac65f7d3cec Mon Sep 17 00:00:00 2001 From: Dwy ! Date: Sat, 13 Jul 2019 20:15:38 +0200 Subject: [PATCH 168/171] fixed ac.json --- src/ac.json | 186 ++++++++++++++++++++++++++-------------------------- 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/src/ac.json b/src/ac.json index d57dbb8b7..4f75d2f8c 100644 --- a/src/ac.json +++ b/src/ac.json @@ -2,152 +2,152 @@ "REVS": { "ac_supply": "1300000" } - }, - { + , + "SUPERNET": { "ac_supply": "816061" } - }, - { + , + "DEX": { "ac_supply": "999999" } - }, - { + , + "PANGEA": { "ac_supply": "999999" } - }, - { + + , "JUMBLR": { "ac_supply": "999999" } - }, - { + , + "BET": { "ac_supply": "999999" } - }, - { + , + "CRYPTO": { "ac_supply": "999999" } - }, - { + , + "HODL": { "ac_supply": "9999999" } - }, - { + , + "MSHARK": { "ac_supply": "1400000" } - }, - { + , + "BOTS": { "ac_supply": "999999" } - }, - { + , + "MGW": { "ac_supply": "999999" } - }, - { + , + "COQUI": { "ac_supply": "72000000", "ac_ccactivate": "200000" } - }, - { + , + "WLC": { "ac_supply": "210000000" } - }, - { + , + "KV": { "ac_supply": "1000000" } - }, - { + , + "CEAL": { "ac_supply": "366666666" } - }, - { + , + "MESH": { "ac_supply": "1000007" } - }, - { + , + "AXO": { "ac_supply": "200000000", "ac_ccactivate": "130000" } - }, - { + , + "ETOMIC": { "ac_supply": "100000000" } - }, - { + , + "BTCH": { "ac_supply": "20998641" } - }, - { + , + "PIZZA": { "ac_supply": "100000000" } - }, - { + , + "BEER": { "ac_supply": "100000000" } - }, - { + , + "NINJA": { "ac_supply": "100000000" } - }, - { + , + "OOT": { "ac_supply": "216000000", "ac_sapling": "5000000" } - }, - { + , + "BNTN": { "ac_supply": "500000000" } - }, - { + , + "CHAIN": { "ac_supply": "999999" } - }, - { + , + "PRLPAY": { "ac_supply": "500000000" } - }, - { + , + "DSEC": { "ac_supply": "7000000" } - }, - { + , + "GLXT": { "ac_supply": "10000000000" } - }, - { + , + "EQL": { "ac_supply": "500000000", "ac_ccactivate": "205000" } - }, - { + , + "ZILLA": { "ac_supply": "11000000", "ac_sapling": "5000000", @@ -155,20 +155,20 @@ "51.68.215.104" ] } - }, - { + , + "RFOX": { "ac_supply": "1000000000", "ac_reward": "100000000" } - }, - { + , + "SEC": { "ac_supply": "1000000000", "ac_cc": "333" } - }, - { + , + "CCL": { "ac_supply": "200000000", "ac_end": "1", @@ -180,8 +180,8 @@ "195.201.22.89" ] } - }, - { + , + "PIRATE": { "ac_supply": "0", "ac_reward": "25600000000", @@ -191,8 +191,8 @@ "136.243.102.225" ] } - }, - { + , + "PGT": { "ac_supply": "10000000", "ac_end": "1", @@ -200,8 +200,8 @@ "190.114.254.104" ] } - }, - { + , + "DION": { "ac_supply": "3900000000", "ac_reward": "22260000000", @@ -212,8 +212,8 @@ "51.75.124.34" ] } - }, - { + , + "KMDICE": { "ac_supply": "10500000", "ac_reward": "2500000000", @@ -225,8 +225,8 @@ "144.76.217.232" ] } - }, - { + , + "KSB": { "ac_supply": "1000000000", "ac_end": "1", @@ -235,8 +235,8 @@ "37.187.225.231" ] } - }, - { + , + "OUR": { "ac_reward": "1478310502", "ac_halving": "525600", @@ -252,44 +252,44 @@ "37.187.225.231" ] } - }, - { + , + "ILN": { "ac_supply": "10000000000", "ac_cc": "2", "addnode": ["51.75.122.83"] } - }, - { + , + "RICK": { "ac_supply": "90000000000", "ac_reward": "100000000", "ac_cc": "3", "addnode": ["138.201.136.145"] } - }, - { + , + "MORTY": { "ac_supply": "90000000000", "ac_reward": "100000000", "ac_cc": "3", "addnode": ["138.201.136.145"] } - }, - { + , + "VOTE2019": { "ac_supply": "123651638", "ac_public": "1", "addnode": ["95.213.238.98"] } - }, - { + , + "KOIN": { "ac_supply": "125000000", "addnode": ["3.0.32.10"] } - }, - { + , + "ZEXO": { "ac_reward": "1478310502", "ac_halving": "525600", @@ -305,16 +305,16 @@ "80.240.17.222" ] } - }, - { + , + "K64": { "ac_reward": "0", "ac_supply": "64000777", "ac_staked": "10", "addnode": ["18.197.20.21"] } - }, - { + , + "HUSH3": { "ac_sapling": "1", "ac_founders": "1", @@ -336,4 +336,4 @@ "5.9.224.250" ] } - } +} \ No newline at end of file From f186490cdcbce945ea5aa6790f2a967786fd32a3 Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Sun, 14 Jul 2019 15:36:52 +0800 Subject: [PATCH 169/171] update to COQUICASH, remove VOTE2019 --- src/ac.json | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/ac.json b/src/ac.json index 4f75d2f8c..7f3f7ba03 100644 --- a/src/ac.json +++ b/src/ac.json @@ -53,13 +53,19 @@ "ac_supply": "999999" } , - - "COQUI": { + "COQUICASH": { "ac_supply": "72000000", - "ac_ccactivate": "200000" + "ac_reward": "7200000000", + "ac_staked": "50", + "ac_halving": "420000", + "ac_cc": "2", + "ac_ccenable": "227,235,236,241", + "addnode": [ + "78.47.108.168" + ] } - , - + , + "WLC": { "ac_supply": "210000000" } @@ -277,13 +283,6 @@ } , - "VOTE2019": { - "ac_supply": "123651638", - "ac_public": "1", - "addnode": ["95.213.238.98"] - } - , - "KOIN": { "ac_supply": "125000000", "addnode": ["3.0.32.10"] @@ -336,4 +335,4 @@ "5.9.224.250" ] } -} \ No newline at end of file +} From b1d53487734bc4256f51514fce039af1e80a7484 Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Sun, 14 Jul 2019 15:38:31 +0800 Subject: [PATCH 170/171] update to COQUICASH, remove VOTE2019 --- src/assetchains.json | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index 20dd04ee2..e68872d6b 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -44,9 +44,16 @@ "ac_supply": "999999" }, { - "ac_name": "COQUI", + "ac_name": "COQUICASH", "ac_supply": "72000000", - "ac_ccactivate": "200000" + "ac_reward": "7200000000", + "ac_staked": "50", + "ac_halving": "420000", + "ac_cc": "2", + "ac_ccenable": "227,235,236,241", + "addnode": [ + "78.47.108.168" + ] }, { "ac_name": "WLC", @@ -235,12 +242,6 @@ "ac_cc": "3", "addnode": ["138.201.136.145"] }, - { - "ac_name": "VOTE2019", - "ac_supply": "123651638", - "ac_public": "1", - "addnode": ["95.213.238.98"] - }, { "ac_name": "KOIN", "ac_supply": "125000000", From 2b799143f822ca302ba289b4c6b1c891d98b9b10 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Wed, 17 Jul 2019 20:33:51 +0300 Subject: [PATCH 171/171] createrawtransaction enchancement - allowing create OP_RETURN vouts (field "data" in "outputs" json) - allowing using script (hex), in "outputs" (for example, you can use any P2PK, P2PKH or P2SH script as destination) - advanced duplicates checking (users can't use same destination in various forms, for example, you can't make one vout as address and second vout, same address, but coded with P2PK script) - allowing to bypass duplicates check for notaries (for example, to manually create splitfunds txes, using daemon RPC only), for common users it's forbidden Useful usage: Don't forget that you can create raw transaction with empty vins, like createrawtransaction "[]" "{\"RKZWgNw9rvMJCHeD6mFgFNrJGxCoT2bft1\":0.777}" and then fund it (with vins) using fundrawtransaction. Duplicates testing vectors (passed): createrawtransaction "[]" "{\"RKZWgNw9rvMJCHeD6mFgFNrJGxCoT2bft1\":0.777,\"2102c42516ab9b0958f349783222c8b665314ce0f12ae513af1c15e10e8045b87544ac\":0.01}" createrawtransaction "[]" "{\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.777,\"2102c42516ab9b0958f349783222c8b665314ce0f12ae513af1c15e10e8045b87544ac\":0.01}" createrawtransaction "[]" "{\"2102c42516ab9b0958f349783222c8b665314ce0f12ae513af1c15e10e8045b87544ac\":0.777,\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.01}" createrawtransaction "[]" "{\"data\":\"010203\",\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.01}" createrawtransaction "[]" "{\"RKZWgNw9rvMJCHeD6mFgFNrJGxCoT2bft1\":0.777,\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.01}" createrawtransaction "[]" "{\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.777,\"RKZWgNw9rvMJCHeD6mFgFNrJGxCoT2bft1\":0.01}" createrawtransaction "[]" "{\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.777,\"a914fe6ac2ca169440909ab86e2e015db0938b92634787\":0.01}" createrawtransaction "[]" "{\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.777,\"a914fe6ac2ca169440909ab86e2e015db0938b92634787\":0.01,\"a914fe6ac2ca169440909ab86e2e015db0938b92634787\":0.02}" createrawtransaction "[]" "{\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.777,\"a914fe6ac2ca169440909ab86e2e015db0938b92634787\":0.01,\"data\":\"00010203\"}" --- src/rpc/rawtransaction.cpp | 91 +++++++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 7d490dff2..3895375df 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -727,27 +727,31 @@ UniValue verifytxoutproof(const UniValue& params, bool fHelp) UniValue createrawtransaction(const UniValue& params, bool fHelp) { + string examplescriptPubKey = "21021ce1eac70455c3e6c52d67c133549b8aed4a588fba594372e8048e65c4f0fcb6ac"; + if (fHelp || params.size() < 2 || params.size() > 4) throw runtime_error( "createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,...} ( locktime ) ( expiryheight )\n" - "\nCreate a transaction spending the given inputs and sending to the given addresses.\n" + "\nCreate a transaction spending the given inputs and creating new outputs.\n" + "Outputs can be addresses or standart scripts (in hex) or data.\n" "Returns hex-encoded raw transaction.\n" "Note that the transaction's inputs are not signed, and\n" "it is not stored in the wallet or transmitted to the network.\n" "\nArguments:\n" - "1. \"transactions\" (string, required) A json array of json objects\n" + "1. \"inputs\" (array, required) A json array of json objects\n" " [\n" " {\n" " \"txid\":\"id\", (string, required) The transaction id\n" - " \"vout\":n (numeric, required) The output number\n" - " \"sequence\":n (numeric, optional) The sequence number\n" - " }\n" + " \"vout\":n, (numeric, required) The output number\n" + " \"sequence\":n (numeric, optional) The sequence number\n" + " } \n" " ,...\n" " ]\n" - "2. \"addresses\" (string, required) a json object with addresses as keys and amounts as values\n" + "2. \"outputs\" (object, required) a json object with outputs\n" " {\n" - " \"address\": x.xxx (numeric, required) The key is the Komodo address, the value is the " + CURRENCY_UNIT + " amount\n" + " \"address\": x.xxx, (numeric or string, required) The key is the komodo address or script (in hex), the numeric value (can be string) is the " + CURRENCY_UNIT + " amount\n" + " \"data\": \"hex\" (string, required) The key is \"data\", the value is hex encoded data\n" " ,...\n" " }\n" "3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n" @@ -757,7 +761,11 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) "\nExamples\n" + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"{\\\"address\\\":0.01}\"") - + HelpExampleRpc("createrawtransaction", "[{\"txid\":\"myid\",\"vout\":0}], {\"address\":0.01}") + + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"{\\\""+examplescriptPubKey+"\\\":0.01}\"") + + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"{\\\"data\\\":\\\"00010203\\\"}\"") + + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"address\\\":0.01}\"") + + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\""+examplescriptPubKey+"\\\":0.01}\"") + + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"data\\\":\\\"00010203\\\"}\"") ); LOCK(cs_main); @@ -817,22 +825,61 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) } std::set destinations; + //std::set destinations; + vector addrList = sendTo.getKeys(); - for (const std::string& name_ : addrList) { - CTxDestination destination = DecodeDestination(name_); - if (!IsValidDestination(destination)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Komodo address: ") + name_); + + if (addrList.size() != sendTo.size()) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid outputs")); // for checking edge case, should never happened ... + } + + //for (const std::string& name_ : addrList) { + for (size_t idx = 0; idx < sendTo.size(); idx++) { + + const std::string& name_ = addrList[idx]; + + CScript scriptPubKey; + CTxDestination destination; + + if (name_ == "data") { + std::vector data = ParseHexV(sendTo[name_].getValStr(),"Data"); + CTxOut out(0, CScript() << OP_RETURN << data); + rawTx.vout.push_back(out); + } else { + destination = DecodeDestination(name_); + if (IsValidDestination(destination)) { + scriptPubKey = GetScriptForDestination(destination); + } else if (IsHex(name_)) { + std::vector data(ParseHex(name_)); + scriptPubKey = CScript(data.begin(), data.end()); + // destination is not valid, but we should convert it to valid anyway, to be able to check duplicates, + // so we need to get destination from existing scriptPubKey via ExtractDestination + if (!(ExtractDestination(scriptPubKey, destination) && + (scriptPubKey.IsPayToPublicKeyHash() || scriptPubKey.IsPayToPublicKey() || scriptPubKey.IsPayToScriptHash()) + )) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid script: ") + name_ + std::string(" (only P2PKH, P2PK and P2SH scripts are allowed)")); + } + } + else { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Komodo address or script: ") + name_); + } + + if (!(fExperimentalMode && IS_KOMODO_NOTARY)) { + // support of sending duplicates in createrawtransaction requires experimental features enabled and + // notary flag, to prevent common users to get messed up with duplicates + + //if (!destinations.insert(EncodeDestination(destination)).second) { + if (!destinations.insert(destination).second) { + throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated destination: ") + name_); + } + } + + // CAmount nAmount = AmountFromValue(sendTo[name_]); // operator[](const std::string& key) const; + CAmount nAmount = AmountFromValue(sendTo[idx]); // operator[](size_t index) const; + + CTxOut out(nAmount, scriptPubKey); + rawTx.vout.push_back(out); } - - if (!destinations.insert(destination).second) { - throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_); - } - - CScript scriptPubKey = GetScriptForDestination(destination); - CAmount nAmount = AmountFromValue(sendTo[name_]); - - CTxOut out(nAmount, scriptPubKey); - rawTx.vout.push_back(out); } return EncodeHexTx(rawTx);