Merge pull request #1645 from jl777/jl777

Jl777
This commit is contained in:
jl777
2019-07-30 05:16:09 -11:00
committed by GitHub
21 changed files with 101 additions and 83 deletions

View File

@@ -65,16 +65,25 @@ void komodo_passport_iteration();
uint64_t komodo_interestsum(); uint64_t komodo_interestsum();
int32_t komodo_longestchain(); int32_t komodo_longestchain();
void komodo_cbopretupdate(int32_t forceflag); void komodo_cbopretupdate(int32_t forceflag);
CBlockIndex *komodo_chainactive(int32_t height);
void WaitForShutdown(boost::thread_group* threadGroup) void WaitForShutdown(boost::thread_group* threadGroup)
{ {
int32_t i,height; bool fShutdown = ShutdownRequested(); const uint256 zeroid; int32_t i,height; CBlockIndex *pindex; bool fShutdown = ShutdownRequested(); const uint256 zeroid;
// Tell the main threads to shutdown. // 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)) 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 %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT); fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT);
StartShutdown(); StartShutdown();
} }
if ( ASSETCHAINS_STAKED == 0 && ASSETCHAINS_ADAPTIVEPOW == 0 && (pindex= komodo_chainactive(1)) != 0 )
{
if ( pindex->nTime > ADAPTIVEPOW_CHANGETO_DEFAULTON )
{
ASSETCHAINS_ADAPTIVEPOW = 1;
fprintf(stderr,"default activate adaptivepow\n");
} else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,ADAPTIVEPOW_CHANGETO_DEFAULTON);
} else fprintf(stderr,"cant find height 1\n");
if ( ASSETCHAINS_CBOPRET != 0 ) if ( ASSETCHAINS_CBOPRET != 0 )
komodo_pricesinit(); komodo_pricesinit();
while (!fShutdown) while (!fShutdown)
@@ -82,7 +91,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
//fprintf(stderr,"call passport iteration\n"); //fprintf(stderr,"call passport iteration\n");
if ( ASSETCHAINS_SYMBOL[0] == 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 )
{ {
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
komodo_passport_iteration(); komodo_passport_iteration();
for (i=0; i<10; i++) for (i=0; i<10; i++)
{ {

View File

@@ -957,7 +957,7 @@ UniValue TokenInfo(uint256 tokenid)
result.push_back(Pair("error", "cant find tokenid")); result.push_back(Pair("error", "cant find tokenid"));
return(result); return(result);
} }
if ( KOMODO_NSPV == 0 && hashBlock.IsNull()) { if ( KOMODO_NSPV <= 0 && hashBlock.IsNull()) {
result.push_back(Pair("result", "error")); result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "the transaction is still in mempool")); result.push_back(Pair("error", "the transaction is still in mempool"));
return(result); return(result);

View File

@@ -162,7 +162,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
utxovout = mtx.vin[i].prevout.n; utxovout = mtx.vin[i].prevout.n;
if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 ) if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 )
{ {
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
{ {
if ( SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey) == 0 ) 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); fprintf(stderr,"signing error for vini.%d of %llx\n",i,(long long)vinimask);
@@ -344,7 +344,7 @@ void NSPV_CCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &txids,char
void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag) void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag)
{ {
int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses; int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
NSPV_CCunspents(unspentOutputs,coinaddr,ccflag); NSPV_CCunspents(unspentOutputs,coinaddr,ccflag);
return; return;
@@ -368,7 +368,7 @@ void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValu
void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr,bool ccflag) void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr,bool ccflag)
{ {
int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses; int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
NSPV_CCtxids(addressIndex,coinaddr,ccflag); NSPV_CCtxids(addressIndex,coinaddr,ccflag);
return; return;
@@ -555,7 +555,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) 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<COutput> 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<COutput> vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,&NSPV_U)); return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,&NSPV_U));
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
assert(pwalletMain != NULL); assert(pwalletMain != NULL);
@@ -652,7 +652,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; 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<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
return(NSPV_AddNormalinputs(mtx,pubkey2pk(Mypubkey()),total,maxinputs,&NSPV_U)); return(NSPV_AddNormalinputs(mtx,pubkey2pk(Mypubkey()),total,maxinputs,&NSPV_U));
utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos));
if ( maxinputs > CC_MAXVINS ) if ( maxinputs > CC_MAXVINS )

View File

@@ -450,7 +450,7 @@ extern uint32_t NSPV_logintime;
bool Myprivkey(uint8_t myprivkey[]) 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]; 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 ) if ( KOMODO_NSPV > 0 )
{ {
if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT ) if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT )
{ {
@@ -590,7 +590,7 @@ int32_t NSPV_coinaddr_inmempool(char const *logcategory,char *coinaddr,uint8_t C
int32_t myIs_coinaddr_inmempoolvout(char const *logcategory,char *coinaddr) int32_t myIs_coinaddr_inmempoolvout(char const *logcategory,char *coinaddr)
{ {
int32_t i,n; char destaddr[64]; int32_t i,n; char destaddr[64];
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
return(NSPV_coinaddr_inmempool(logcategory,coinaddr,1)); return(NSPV_coinaddr_inmempool(logcategory,coinaddr,1));
BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx)
{ {
@@ -619,7 +619,7 @@ int32_t myGet_mempool_txs(std::vector<CTransaction> &txs,uint8_t evalcode,uint8_
{ {
int i=0; int i=0;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
CTransaction tx; uint256 hashBlock; CTransaction tx; uint256 hashBlock;

View File

@@ -101,7 +101,7 @@ int CurrentEpoch(int nHeight, const Consensus::Params& params) {
uint32_t CurrentEpochBranchId(int nHeight, const Consensus::Params& params) uint32_t CurrentEpochBranchId(int nHeight, const Consensus::Params& params)
{ {
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
return(NSPV_BRANCHID); return(NSPV_BRANCHID);
return NetworkUpgradeInfo[CurrentEpoch(nHeight, params)].nBranchId; return NetworkUpgradeInfo[CurrentEpoch(nHeight, params)].nBranchId;
} }

View File

@@ -1066,7 +1066,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
RegisterAllCoreRPCCommands(tableRPC); RegisterAllCoreRPCCommands(tableRPC);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
bool fDisableWallet = GetBoolArg("-disablewallet", false); bool fDisableWallet = GetBoolArg("-disablewallet", false);
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
fDisableWallet = true; fDisableWallet = true;
nLocalServices = 0; nLocalServices = 0;
@@ -1147,7 +1147,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// Option to startup with mocktime set (used for regression testing): // Option to startup with mocktime set (used for regression testing):
SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
{ {
if (GetBoolArg("-peerbloomfilters", true)) if (GetBoolArg("-peerbloomfilters", true))
nLocalServices |= NODE_BLOOM; nLocalServices |= NODE_BLOOM;
@@ -1306,7 +1306,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
libsnark::inhibit_profiling_info = true; libsnark::inhibit_profiling_info = true;
libsnark::inhibit_profiling_counters = true; libsnark::inhibit_profiling_counters = true;
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
{ {
// Initialize Zcash circuit parameters // Initialize Zcash circuit parameters
ZC_LoadParams(chainparams); ZC_LoadParams(chainparams);
@@ -1487,7 +1487,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
#endif #endif
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
std::vector<boost::filesystem::path> vImportFiles; std::vector<boost::filesystem::path> vImportFiles;
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles)); threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));

View File

@@ -1418,14 +1418,17 @@ uint32_t komodo_stakehash(uint256 *hashp,char *address,uint8_t *hashbuf,uint256
arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime) arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime)
{ {
arith_uint256 origtarget,easy; int32_t diff; int64_t mult; bool fNegative,fOverflow; CBlockIndex *tipindex; arith_uint256 origtarget,easy; int32_t diff,tipdiff; int64_t mult; bool fNegative,fOverflow; CBlockIndex *tipindex;
if ( height > 10 && (tipindex= komodo_chainactive(height - 1)) != 0 ) if ( height > 10 && (tipindex= komodo_chainactive(height - 1)) != 0 )
{ {
diff = (nTime - tipindex->GetMedianTimePast()); diff = (nTime - tipindex->GetMedianTimePast());
if ( diff > 20 * ASSETCHAINS_BLOCKTIME ) tipdiff = (nTime - tipindex->nTime);
if ( tipdiff > 13*ASSETCHAINS_BLOCKTIME )
diff = 13*ASSETCHAINS_BLOCKTIME;
if ( diff > 13 * ASSETCHAINS_BLOCKTIME )
{ {
mult = diff - 19 * ASSETCHAINS_BLOCKTIME; mult = diff - 12 * ASSETCHAINS_BLOCKTIME;
mult = (mult / ASSETCHAINS_BLOCKTIME) * ASSETCHAINS_BLOCKTIME + ASSETCHAINS_BLOCKTIME / 3; mult = (mult / ASSETCHAINS_BLOCKTIME) * ASSETCHAINS_BLOCKTIME + ASSETCHAINS_BLOCKTIME / 2;
origtarget = bnTarget; origtarget = bnTarget;
bnTarget = bnTarget * arith_uint256(mult * mult); bnTarget = bnTarget * arith_uint256(mult * mult);
easy.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); easy.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
@@ -1434,8 +1437,8 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui
bnTarget = easy; bnTarget = easy;
fprintf(stderr,"miner overflowed mult.%lld, set to mindiff\n",(long long)mult); fprintf(stderr,"miner overflowed mult.%lld, set to mindiff\n",(long long)mult);
} else fprintf(stderr,"miner elapsed %d, adjust by factor of %lld\n",diff,(long long)mult); } else fprintf(stderr,"miner elapsed %d, adjust by factor of %lld\n",diff,(long long)mult);
} } else fprintf(stderr,"diff %d, vs 120\n",diff);
} //else fprintf(stderr,"cant find height.%d\n",height); } else fprintf(stderr,"cant find height.%d\n",height);
return(bnTarget); return(bnTarget);
} }
@@ -2283,7 +2286,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
if ( height == 0 ) if ( height == 0 )
return(0); return(0);
} }
if ( ASSETCHAINS_ADAPTIVEPOW != 0 ) if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
bnTarget = komodo_adaptivepow_target(height,bnTarget,pblock->nTime); bnTarget = komodo_adaptivepow_target(height,bnTarget,pblock->nTime);
if ( ASSETCHAINS_LWMAPOS != 0 && bhash > bnTarget ) if ( ASSETCHAINS_LWMAPOS != 0 && bhash > bnTarget )
{ {

View File

@@ -20,6 +20,7 @@
#include "komodo_nk.h" #include "komodo_nk.h"
#define KOMODO_EARLYTXID_HEIGHT 100 #define KOMODO_EARLYTXID_HEIGHT 100
#define ADAPTIVEPOW_CHANGETO_DEFAULTON 1572480000
#define ASSETCHAINS_MINHEIGHT 128 #define ASSETCHAINS_MINHEIGHT 128
#define ASSETCHAINS_MAX_ERAS 7 #define ASSETCHAINS_MAX_ERAS 7
#define KOMODO_ELECTION_GAP 2000 #define KOMODO_ELECTION_GAP 2000
@@ -263,7 +264,8 @@ static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] =
//#define PRICES_DAYWINDOW (7) //#define PRICES_DAYWINDOW (7)
//#endif //#endif
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC,ASSETCHAINS_ADAPTIVEPOW; extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
extern int8_t ASSETCHAINS_ADAPTIVEPOW;
int32_t MAX_BLOCK_SIZE(int32_t height); int32_t MAX_BLOCK_SIZE(int32_t height);
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;

View File

@@ -50,7 +50,8 @@ 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,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,KOMODO_NSPV;
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; 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; 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,ASSETCHAINS_ADAPTIVEPOW; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA;
int8_t ASSETCHAINS_ADAPTIVEPOW;
bool VERUS_MINTBLOCKS; bool VERUS_MINTBLOCKS;
std::vector<uint8_t> Mineropret; std::vector<uint8_t> Mineropret;
std::vector<std::string> vWhiteListAddress; std::vector<std::string> vWhiteListAddress;

View File

@@ -18,8 +18,8 @@
#define KOMODO_NSPV_DEFSH #define KOMODO_NSPV_DEFSH
#define NSPV_PROTOCOL_VERSION 0x00000002 #define NSPV_PROTOCOL_VERSION 0x00000002
#define NSPV_POLLITERS 100 #define NSPV_POLLITERS 200
#define NSPV_POLLMICROS 30000 #define NSPV_POLLMICROS 50000
#define NSPV_MAXVINS 64 #define NSPV_MAXVINS 64
#define NSPV_AUTOLOGOUT 777 #define NSPV_AUTOLOGOUT 777
#define NSPV_BRANCHID 0x76b809bb #define NSPV_BRANCHID 0x76b809bb

View File

@@ -214,7 +214,7 @@ void komodo_nSPVresp(CNode *pfrom,std::vector<uint8_t> response) // received a r
CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind) CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind)
{ {
int32_t n,flag = 0; CNode *pnodes[64]; uint32_t timestamp = (uint32_t)time(NULL); int32_t n,flag = 0; CNode *pnodes[64]; uint32_t timestamp = (uint32_t)time(NULL);
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
return(0); return(0);
if ( pnode == 0 ) if ( pnode == 0 )
{ {
@@ -243,7 +243,7 @@ CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind)
std::vector<uint8_t> request; std::vector<uint8_t> request;
request.resize(len); request.resize(len);
memcpy(&request[0],msg,len); memcpy(&request[0],msg,len);
if ( (0) && KOMODO_NSPV != 0 ) if ( (0) && KOMODO_NSPV > 0 )
fprintf(stderr,"pushmessage [%d] len.%d\n",msg[0],len); fprintf(stderr,"pushmessage [%d] len.%d\n",msg[0],len);
pnode->PushMessage("getnSPV",request); pnode->PushMessage("getnSPV",request);
pnode->prevtimes[ind] = timestamp; pnode->prevtimes[ind] = timestamp;
@@ -279,7 +279,7 @@ void komodo_nSPV(CNode *pto) // polling loop from SendMessages
return; return;
if ( pto->prevtimes[NSPV_INFO>>1] > timestamp ) if ( pto->prevtimes[NSPV_INFO>>1] > timestamp )
pto->prevtimes[NSPV_INFO>>1] = 0; pto->prevtimes[NSPV_INFO>>1] = 0;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
if ( timestamp > NSPV_lastinfo + ASSETCHAINS_BLOCKTIME/2 && timestamp > pto->prevtimes[NSPV_INFO>>1] + 2*ASSETCHAINS_BLOCKTIME/3 ) if ( timestamp > NSPV_lastinfo + ASSETCHAINS_BLOCKTIME/2 && timestamp > pto->prevtimes[NSPV_INFO>>1] + 2*ASSETCHAINS_BLOCKTIME/3 )
{ {
@@ -537,7 +537,7 @@ UniValue NSPV_login(char *wifstr)
result.push_back(Pair("address",NSPV_address)); result.push_back(Pair("address",NSPV_address));
result.push_back(Pair("pubkey",HexStr(pubkey))); result.push_back(Pair("pubkey",HexStr(pubkey)));
strcpy(NSPV_pubkeystr,HexStr(pubkey).c_str()); strcpy(NSPV_pubkeystr,HexStr(pubkey).c_str());
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
decode_hex(NOTARY_PUBKEY33,33,NSPV_pubkeystr); decode_hex(NOTARY_PUBKEY33,33,NSPV_pubkeystr);
result.push_back(Pair("wifprefix",(int64_t)data[0])); result.push_back(Pair("wifprefix",(int64_t)data[0]));
result.push_back(Pair("compressed",(int64_t)(data[len-5] == 1))); result.push_back(Pair("compressed",(int64_t)(data[len-5] == 1)));

View File

@@ -2227,7 +2227,7 @@ bool myAddtomempool(CTransaction &tx, CValidationState *pstate, bool fSkipExpiry
bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock) bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock)
{ {
memset(&hashBlock,0,sizeof(hashBlock)); memset(&hashBlock,0,sizeof(hashBlock));
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
int64_t rewardsum = 0; int32_t i,retval,txheight,currentheight,height=0,vout = 0; int64_t rewardsum = 0; int32_t i,retval,txheight,currentheight,height=0,vout = 0;
for (i=0; i<NSPV_U.U.numutxos; i++) for (i=0; i<NSPV_U.U.numutxos; i++)
@@ -2281,7 +2281,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo
bool NSPV_myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, int32_t &txheight, int32_t &currentheight) bool NSPV_myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, int32_t &txheight, int32_t &currentheight)
{ {
memset(&hashBlock,0,sizeof(hashBlock)); memset(&hashBlock,0,sizeof(hashBlock));
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
int64_t rewardsum = 0; int32_t i,retval,height=0,vout = 0; int64_t rewardsum = 0; int32_t i,retval,height=0,vout = 0;
for (i=0; i<NSPV_U.U.numutxos; i++) for (i=0; i<NSPV_U.U.numutxos; i++)
@@ -3427,7 +3427,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
{ {
CDiskBlockPos blockPos; CDiskBlockPos blockPos;
const CChainParams& chainparams = Params(); const CChainParams& chainparams = Params();
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
return(true); return(true);
if ( KOMODO_STOPAT != 0 && pindex->GetHeight() > KOMODO_STOPAT ) if ( KOMODO_STOPAT != 0 && pindex->GetHeight() > KOMODO_STOPAT )
return(false); return(false);
@@ -4011,7 +4011,7 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
void FlushStateToDisk() { void FlushStateToDisk() {
CValidationState state; CValidationState state;
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
FlushStateToDisk(state, FLUSH_STATE_ALWAYS); FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
} }
@@ -4162,7 +4162,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight(),true) != 0))) if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight(),true) != 0)))
{ {
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if ( !GetBoolArg("-disablewallet", false) && KOMODO_NSPV == 0 ) if ( !GetBoolArg("-disablewallet", false) && KOMODO_NSPV <= 0 )
pwalletMain->EraseFromWallet(tx.GetHash()); pwalletMain->EraseFromWallet(tx.GetHash());
#endif #endif
} }
@@ -4267,7 +4267,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
// Get the current commitment tree // Get the current commitment tree
SproutMerkleTree oldSproutTree; SproutMerkleTree oldSproutTree;
SaplingMerkleTree oldSaplingTree; SaplingMerkleTree oldSaplingTree;
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
{ {
assert(pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), oldSproutTree)); assert(pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), oldSproutTree));
assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), oldSaplingTree)); assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), oldSaplingTree));
@@ -4296,13 +4296,13 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
mapBlockSource.erase(pindexNew->GetBlockHash()); mapBlockSource.erase(pindexNew->GetBlockHash());
nTime3 = GetTimeMicros(); nTimeConnectTotal += nTime3 - nTime2; nTime3 = GetTimeMicros(); nTimeConnectTotal += nTime3 - nTime2;
LogPrint("bench", " - Connect total: %.2fms [%.2fs]\n", (nTime3 - nTime2) * 0.001, nTimeConnectTotal * 0.000001); LogPrint("bench", " - Connect total: %.2fms [%.2fs]\n", (nTime3 - nTime2) * 0.001, nTimeConnectTotal * 0.000001);
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
assert(view.Flush()); assert(view.Flush());
} }
int64_t nTime4 = GetTimeMicros(); nTimeFlush += nTime4 - nTime3; int64_t nTime4 = GetTimeMicros(); nTimeFlush += nTime4 - nTime3;
LogPrint("bench", " - Flush: %.2fms [%.2fs]\n", (nTime4 - nTime3) * 0.001, nTimeFlush * 0.000001); LogPrint("bench", " - Flush: %.2fms [%.2fs]\n", (nTime4 - nTime3) * 0.001, nTimeFlush * 0.000001);
// Write the chain state to disk, if necessary. // Write the chain state to disk, if necessary.
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
{ {
if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED)) if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED))
return false; return false;
@@ -4318,7 +4318,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
// Update chainActive & related variables. // Update chainActive & related variables.
UpdateTip(pindexNew); UpdateTip(pindexNew);
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
{ {
// Tell wallet about transactions that went from mempool // Tell wallet about transactions that went from mempool
// to conflicted: // to conflicted:
@@ -4346,7 +4346,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
komodo_broadcast(pblock,8); komodo_broadcast(pblock,8);
else if ( ASSETCHAINS_SYMBOL[0] != 0 ) else if ( ASSETCHAINS_SYMBOL[0] != 0 )
komodo_broadcast(pblock,4);*/ komodo_broadcast(pblock,4);*/
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
{ {
if ( ASSETCHAINS_CBOPRET != 0 ) if ( ASSETCHAINS_CBOPRET != 0 )
komodo_pricesupdate(pindexNew->GetHeight(),pblock); komodo_pricesupdate(pindexNew->GetHeight(),pblock);
@@ -6547,7 +6547,7 @@ bool InitBlockIndex() {
if (!ActivateBestChain(true, state, &block)) if (!ActivateBestChain(true, state, &block))
return error("LoadBlockIndex(): genesis block cannot be activated"); return error("LoadBlockIndex(): genesis block cannot be activated");
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data // Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS); return FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
else return(true); else return(true);
} catch (const std::runtime_error& e) { } catch (const std::runtime_error& e) {
@@ -7107,7 +7107,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{ {
const CChainParams& chainparams = Params(); const CChainParams& chainparams = Params();
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id); LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
//if ( KOMODO_NSPV != 0 ) //if ( KOMODO_NSPV > 0 )
//if ( strCommand != "version" && strCommand != "verack" ) //if ( strCommand != "version" && strCommand != "verack" )
// fprintf(stderr, "recv: %s (%u bytes) peer=%d\n", SanitizeString(strCommand).c_str(), (int32_t)vRecv.size(), (int32_t)pfrom->GetId()); // fprintf(stderr, "recv: %s (%u bytes) peer=%d\n", SanitizeString(strCommand).c_str(), (int32_t)vRecv.size(), (int32_t)pfrom->GetId());
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
@@ -7282,7 +7282,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{ {
pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
if ( (pfrom->nServices & NODE_NSPV) == 0 ) if ( (pfrom->nServices & NODE_NSPV) == 0 )
{ {
@@ -7482,14 +7482,17 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
else if (strCommand == "getnSPV") else if (strCommand == "getnSPV")
{ {
std::vector<uint8_t> payload; if ( KOMODO_NSPV == 0 )
vRecv >> payload; {
komodo_nSPVreq(pfrom,payload); std::vector<uint8_t> payload;
vRecv >> payload;
komodo_nSPVreq(pfrom,payload);
}
return(true); return(true);
} }
else if (strCommand == "nSPV") else if (strCommand == "nSPV")
{ {
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
std::vector<uint8_t> payload; std::vector<uint8_t> payload;
vRecv >> payload; vRecv >> payload;
@@ -7497,7 +7500,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
return(true); return(true);
} }
else if ( KOMODO_NSPV != 0 ) else if ( KOMODO_NSPV > 0 )
return(true); return(true);
else if (strCommand == "inv") else if (strCommand == "inv")
{ {
@@ -8287,7 +8290,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
} }
state.fShouldBan = false; state.fShouldBan = false;
} }
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
komodo_nSPV(pto); komodo_nSPV(pto);
return(true); return(true);
@@ -8498,7 +8501,7 @@ extern "C" const char* getDataDir()
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight) CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight)
{ {
CMutableTransaction mtx; CMutableTransaction mtx;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
mtx.fOverwintered = true; mtx.fOverwintered = true;
mtx.nExpiryHeight = 0; mtx.nExpiryHeight = 0;

View File

@@ -1447,7 +1447,7 @@ void static BitcoinMiner_noeq()
HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED); LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED);
} }
else if ( ASSETCHAINS_ADAPTIVEPOW != 0 && ASSETCHAINS_STAKED == 0 ) else if ( ASSETCHAINS_ADAPTIVEPOW > 0 && ASSETCHAINS_STAKED == 0 )
HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime);
while (true) while (true)
@@ -1482,7 +1482,7 @@ void static BitcoinMiner_noeq()
} }
else if ( ASSETCHAINS_STAKED == 100 && Mining_height > 100 ) else if ( ASSETCHAINS_STAKED == 100 && Mining_height > 100 )
hashTarget = HASHTarget; hashTarget = HASHTarget;
else if ( ASSETCHAINS_ADAPTIVEPOW != 0 && ASSETCHAINS_STAKED == 0 ) else if ( ASSETCHAINS_ADAPTIVEPOW > 0 && ASSETCHAINS_STAKED == 0 )
hashTarget = HASHTarget_POW; hashTarget = HASHTarget_POW;
// for speed check NONCEMASK at a time // for speed check NONCEMASK at a time
@@ -1820,7 +1820,7 @@ void static BitcoinMiner()
if ( ASSETCHAINS_STAKED < 100 ) if ( ASSETCHAINS_STAKED < 100 )
LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED);
} }
else if ( ASSETCHAINS_ADAPTIVEPOW != 0 ) else if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime);
gotinvalid = 0; gotinvalid = 0;
while (true) while (true)
@@ -1849,7 +1849,7 @@ void static BitcoinMiner()
arith_uint256 hashTarget; arith_uint256 hashTarget;
if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 )
hashTarget = HASHTarget_POW; hashTarget = HASHTarget_POW;
else if ( ASSETCHAINS_ADAPTIVEPOW != 0 ) else if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
hashTarget = HASHTarget_POW; hashTarget = HASHTarget_POW;
else hashTarget = HASHTarget; else hashTarget = HASHTarget;
std::function<bool(std::vector<unsigned char>)> validBlock = std::function<bool(std::vector<unsigned char>)> validBlock =
@@ -2040,7 +2040,7 @@ void static BitcoinMiner()
// Update nNonce and nTime // Update nNonce and nTime
pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1); pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1);
pblock->nBits = savebits; pblock->nBits = savebits;
if ( ASSETCHAINS_ADAPTIVEPOW != 0 ) if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev); UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
/*if ( NOTARY_PUBKEY33[0] == 0 ) /*if ( NOTARY_PUBKEY33[0] == 0 )
{ {

View File

@@ -1843,7 +1843,7 @@ bool StopNode()
for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++) for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++)
semOutbound->post(); semOutbound->post();
if (KOMODO_NSPV == 0 && fAddressesInitialized) if (KOMODO_NSPV <= 0 && fAddressesInitialized)
{ {
DumpAddresses(); DumpAddresses();
fAddressesInitialized = false; fAddressesInitialized = false;

View File

@@ -453,7 +453,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
arith_uint256 bnMaxPoSdiff; arith_uint256 bnMaxPoSdiff;
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
} }
else if ( ASSETCHAINS_ADAPTIVEPOW != 0 && ASSETCHAINS_STAKED == 0 ) else if ( ASSETCHAINS_ADAPTIVEPOW > 0 && ASSETCHAINS_STAKED == 0 )
bnTarget = komodo_adaptivepow_target(height,bnTarget,blkHeader.nTime); bnTarget = komodo_adaptivepow_target(height,bnTarget,blkHeader.nTime);
// Check proof of work matches claimed amount // Check proof of work matches claimed amount
if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget && !blkHeader.IsVerusPOSBlock() ) if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget && !blkHeader.IsVerusPOSBlock() )

View File

@@ -396,7 +396,7 @@ bool NSPV_inmempool(uint256 txid);
bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout) bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout)
{ {
int32_t vini = 0; int32_t vini = 0;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
return(NSPV_spentinmempool(spenttxid,spentvini,txid,vout)); return(NSPV_spentinmempool(spenttxid,spentvini,txid,vout));
BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx)
{ {
@@ -420,7 +420,7 @@ bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,
bool mytxid_inmempool(uint256 txid) bool mytxid_inmempool(uint256 txid)
{ {
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
} }

View File

@@ -243,7 +243,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("prevMoMheight", prevMoMheight)); obj.push_back(Pair("prevMoMheight", prevMoMheight));
obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); obj.push_back(Pair("notarizedhash", notarized_hash.ToString()));
obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString()));
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
{ {
txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height);
if ( txid_height > 0 ) if ( txid_height > 0 )

View File

@@ -374,7 +374,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
const CTxOut& txout = tx.vout[i]; const CTxOut& txout = tx.vout[i];
UniValue out(UniValue::VOBJ); UniValue out(UniValue::VOBJ);
out.push_back(Pair("value", ValueFromAmount(txout.nValue))); out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
if ( KOMODO_NSPV == 0 && ASSETCHAINS_SYMBOL[0] == 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.LastTip()) != 0 ) if ( KOMODO_NSPV <= 0 && ASSETCHAINS_SYMBOL[0] == 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.LastTip()) != 0 )
{ {
int64_t interest; int32_t txheight; uint32_t locktime; int64_t interest; int32_t txheight; uint32_t locktime;
interest = komodo_accrued_interest(&txheight,&locktime,tx.GetHash(),i,0,txout.nValue,(int32_t)tipindex->GetHeight()); interest = komodo_accrued_interest(&txheight,&locktime,tx.GetHash(),i,0,txout.nValue,(int32_t)tipindex->GetHeight());
@@ -1366,7 +1366,7 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp)
bool fOverrideFees = false; bool fOverrideFees = false;
if (params.size() > 1) if (params.size() > 1)
fOverrideFees = params[1].get_bool(); fOverrideFees = params[1].get_bool();
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
{ {
CCoinsViewCache &view = *pcoinsTip; CCoinsViewCache &view = *pcoinsTip;
const CCoins* existingCoins = view.AccessCoins(hashTx); const CCoins* existingCoins = view.AccessCoins(hashTx);

View File

@@ -53,7 +53,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
} }
} }
SIG_TXHASH = hash; SIG_TXHASH = hash;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
key = DecodeSecret(NSPV_wifstr); key = DecodeSecret(NSPV_wifstr);
else if (pprivKey) else if (pprivKey)
key = *pprivKey; key = *pprivKey;
@@ -74,7 +74,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
return false; return false;
} }
vchSig = CCSigVec(cc); vchSig = CCSigVec(cc);
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
memset((uint8_t *)key.begin(),0,32); memset((uint8_t *)key.begin(),0,32);
return true; return true;
} }
@@ -100,7 +100,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
} }
vchSig.push_back((unsigned char)nHashType); vchSig.push_back((unsigned char)nHashType);
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
memset((uint8_t *)key.begin(),0,32); memset((uint8_t *)key.begin(),0,32);
return true; return true;
} }
@@ -381,7 +381,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP
} }
else else
{ {
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
{ {
CPubKey vch; CPubKey vch;
creator.KeyStore().GetPubKey(keyID, vch); creator.KeyStore().GetPubKey(keyID, vch);

View File

@@ -993,7 +993,7 @@ UniValue nspv_getinfo(const UniValue& params, bool fHelp)
int32_t reqht = 0; int32_t reqht = 0;
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("nspv_getinfo [hdrheight]\n"); throw runtime_error("nspv_getinfo [hdrheight]\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( params.size() == 1 ) if ( params.size() == 1 )
reqht = atoi((char *)params[0].get_str().c_str()); reqht = atoi((char *)params[0].get_str().c_str());
@@ -1004,7 +1004,7 @@ UniValue nspv_logout(const UniValue& params, bool fHelp)
{ {
if ( fHelp || params.size() != 0 ) if ( fHelp || params.size() != 0 )
throw runtime_error("nspv_logout\n"); throw runtime_error("nspv_logout\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
return(NSPV_logout()); return(NSPV_logout());
} }
@@ -1013,7 +1013,7 @@ UniValue nspv_login(const UniValue& params, bool fHelp)
{ {
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("nspv_login wif\n"); throw runtime_error("nspv_login wif\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
return(NSPV_login((char *)params[0].get_str().c_str())); return(NSPV_login((char *)params[0].get_str().c_str()));
} }
@@ -1023,7 +1023,7 @@ UniValue nspv_listunspent(const UniValue& params, bool fHelp)
int32_t skipcount = 0,CCflag = 0; int32_t skipcount = 0,CCflag = 0;
if ( fHelp || params.size() > 3 ) if ( fHelp || params.size() > 3 )
throw runtime_error("nspv_listunspent [address [isCC [skipcount]]]\n"); throw runtime_error("nspv_listunspent [address [isCC [skipcount]]]\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( params.size() == 0 ) if ( params.size() == 0 )
{ {
@@ -1048,7 +1048,7 @@ UniValue nspv_mempool(const UniValue& params, bool fHelp)
memset(&txid,0,sizeof(txid)); memset(&txid,0,sizeof(txid));
if ( fHelp || params.size() > 5 ) if ( fHelp || params.size() > 5 )
throw runtime_error("nspv_mempool func(0 all, 1 address recv, 2 txid/vout spent, 3 txid inmempool) address isCC [txid vout]]]\n"); throw runtime_error("nspv_mempool func(0 all, 1 address recv, 2 txid/vout spent, 3 txid inmempool) address isCC [txid vout]]]\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
funcid = atoi((char *)params[0].get_str().c_str()); funcid = atoi((char *)params[0].get_str().c_str());
coinaddr = (char *)params[1].get_str().c_str(); coinaddr = (char *)params[1].get_str().c_str();
@@ -1068,7 +1068,7 @@ UniValue nspv_listtransactions(const UniValue& params, bool fHelp)
int32_t skipcount = 0,CCflag = 0; int32_t skipcount = 0,CCflag = 0;
if ( fHelp || params.size() > 3 ) if ( fHelp || params.size() > 3 )
throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n"); throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( params.size() == 0 ) if ( params.size() == 0 )
{ {
@@ -1093,7 +1093,7 @@ UniValue nspv_spentinfo(const UniValue& params, bool fHelp)
uint256 txid; int32_t vout; uint256 txid; int32_t vout;
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_spentinfo txid vout\n"); throw runtime_error("nspv_spentinfo txid vout\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
vout = atoi((char *)params[1].get_str().c_str()); vout = atoi((char *)params[1].get_str().c_str());
@@ -1105,7 +1105,7 @@ UniValue nspv_notarizations(const UniValue& params, bool fHelp)
int32_t height; int32_t height;
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("nspv_notarizations height\n"); throw runtime_error("nspv_notarizations height\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
height = atoi((char *)params[0].get_str().c_str()); height = atoi((char *)params[0].get_str().c_str());
return(NSPV_notarizations(height)); return(NSPV_notarizations(height));
@@ -1116,7 +1116,7 @@ UniValue nspv_hdrsproof(const UniValue& params, bool fHelp)
int32_t prevheight,nextheight; int32_t prevheight,nextheight;
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_hdrsproof prevheight nextheight\n"); throw runtime_error("nspv_hdrsproof prevheight nextheight\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
prevheight = atoi((char *)params[0].get_str().c_str()); prevheight = atoi((char *)params[0].get_str().c_str());
nextheight = atoi((char *)params[1].get_str().c_str()); nextheight = atoi((char *)params[1].get_str().c_str());
@@ -1128,7 +1128,7 @@ UniValue nspv_txproof(const UniValue& params, bool fHelp)
uint256 txid; int32_t height; uint256 txid; int32_t height;
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_txproof txid height\n"); throw runtime_error("nspv_txproof txid height\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
height = atoi((char *)params[1].get_str().c_str()); height = atoi((char *)params[1].get_str().c_str());
@@ -1140,7 +1140,7 @@ UniValue nspv_spend(const UniValue& params, bool fHelp)
uint64_t satoshis; uint64_t satoshis;
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_spend address amount\n"); throw runtime_error("nspv_spend address amount\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( NSPV_address.size() == 0 ) if ( NSPV_address.size() == 0 )
throw runtime_error("to nspv_send you need an active nspv_login\n"); throw runtime_error("to nspv_send you need an active nspv_login\n");
@@ -1155,7 +1155,7 @@ UniValue nspv_broadcast(const UniValue& params, bool fHelp)
{ {
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("nspv_broadcast hex\n"); throw runtime_error("nspv_broadcast hex\n");
if ( KOMODO_NSPV == 0 ) if ( KOMODO_NSPV <= 0 )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
return(NSPV_broadcast((char *)params[0].get_str().c_str())); return(NSPV_broadcast((char *)params[0].get_str().c_str()));
} }

View File

@@ -162,7 +162,7 @@ void OS_randombytes(unsigned char *x,long xlen);
UniValue getnewaddress(const UniValue& params, bool fHelp) UniValue getnewaddress(const UniValue& params, bool fHelp)
{ {
if ( KOMODO_NSPV == 0 && !EnsureWalletIsAvailable(fHelp) ) if ( KOMODO_NSPV <= 0 && !EnsureWalletIsAvailable(fHelp) )
return NullUniValue; return NullUniValue;
if (fHelp || params.size() > 1) if (fHelp || params.size() > 1)
@@ -178,7 +178,7 @@ UniValue getnewaddress(const UniValue& params, bool fHelp)
+ HelpExampleRpc("getnewaddress", "") + HelpExampleRpc("getnewaddress", "")
); );
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV > 0 )
{ {
UniValue result(UniValue::VOBJ); uint8_t priv32[32]; UniValue result(UniValue::VOBJ); uint8_t priv32[32];
#ifndef __WIN32 #ifndef __WIN32
@@ -2974,7 +2974,7 @@ UniValue listunspent(const UniValue& params, bool fHelp)
uint64_t komodo_interestsum() uint64_t komodo_interestsum()
{ {
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if ( ASSETCHAINS_SYMBOL[0] == 0 && GetBoolArg("-disablewallet", false) == 0 && KOMODO_NSPV == 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 && GetBoolArg("-disablewallet", false) == 0 && KOMODO_NSPV <= 0 )
{ {
uint64_t interest,sum = 0; int32_t txheight; uint32_t locktime; uint64_t interest,sum = 0; int32_t txheight; uint32_t locktime;
vector<COutput> vecOutputs; vector<COutput> vecOutputs;
@@ -7002,7 +7002,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("faucetfund amount\n"); throw runtime_error("faucetfund amount\n");
funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999;
if ( (0) && KOMODO_NSPV != 0 ) if ( (0) && KOMODO_NSPV > 0 )
{ {
char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v; char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v;
cp = CCinit(&C,EVAL_FAUCET); cp = CCinit(&C,EVAL_FAUCET);