diff --git a/README.md b/README.md index 2dbfc2729..463c3f983 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Dependencies ``` #The following packages are needed: -sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libboost-all-dev libssl-dev libprotobuf-dev protobuf-compiler libqt4-dev libqrencode-dev libdb++-dev ntp ntpdate +sudo apt-get install build-essential pkg-config libcurl-gnutls libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libboost-all-dev libssl-dev libprotobuf-dev protobuf-compiler libqt4-dev libqrencode-dev libdb++-dev ntp ntpdate ``` Komodo diff --git a/src/komodo_globals.h b/src/komodo_globals.h index b908e0669..afe589e21 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -38,7 +38,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = 100; -int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX; +int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 62d26d75b..d66eecaff 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1454,6 +1454,8 @@ void komodo_args() extern int64_t MAX_MONEY; std::string name,addn; char *dirname,fname[512],magicstr[9]; uint8_t magic[4]; FILE *fp; int32_t i,baseid,len; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); + if ( (KOMODO_EXCHANGEWALLET= GetBoolArg("-exchange", false)) != 0 ) + fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n"); NOTARY_PUBKEY = GetArg("-pubkey", ""); if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) { diff --git a/src/main.cpp b/src/main.cpp index 2defb8571..42dff0ffa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1269,7 +1269,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa dFreeCount += nSize; } - if (fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000 && nFees > COIN ) + if (fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000 && nFees > nValueOut/20 ) { fprintf(stderr,"accept failure.8\n"); return error("AcceptToMemoryPool: absurdly high fees %s, %d > %d",hash.ToString(), nFees, ::minRelayTxFee.GetFee(nSize) * 10000); diff --git a/src/miner.cpp b/src/miner.cpp index 307125da1..f7851e75d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -616,7 +616,7 @@ void static BitcoinMiner(CWallet *pwallet) // // Search // - uint8_t pubkeys[66][33]; int mids[66],nonzpkeys,i,j; uint32_t savebits; int64_t nStart = GetTime(); + uint8_t pubkeys[66][33]; int mids[66],nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime(); savebits = pblock->nBits; arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits); if ( ASSETCHAINS_SYMBOL[0] == 0 && notaryid >= 0 )//komodo_is_special(pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 ) @@ -626,24 +626,28 @@ void static BitcoinMiner(CWallet *pwallet) komodo_eligiblenotary(pubkeys,mids,&nonzpkeys,pindexPrev->nHeight); if ( nonzpkeys > 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 && notaryid < 1 ) + for (i=0; i<33; i++) + if( pubkeys[0][i] != 0 ) + break; + if ( i == 33 ) + externalflag = 1; + else externalflag = 0; + if ( NOTARY_PUBKEY33[0] != 0 && notaryid < 3 ) { for (i=1; i<66; i++) if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 ) break; - if ( i != 66 ) - { + if ( externalflag == 0 && i != 66 ) printf("VIOLATION at %d\n",i); - for (i=0; i<66; i++) - { - for (j=0; j<33; j++) - printf("%02x",pubkeys[i][j]); - printf(" p%d -> %d\n",i,komodo_minerid(pindexPrev->nHeight-i,pubkeys[i])); - } - for (j=0; j<65; j++) - fprintf(stderr,"%d ",mids[j]); - fprintf(stderr," <- prev minerids from ht.%d notary.%d VIOLATION\n",pindexPrev->nHeight,notaryid); + for (i=0; i<66; i++) + { + for (j=0; j<33; j++) + printf("%02x",pubkeys[i][j]); + printf(" p%d -> %d\n",i,komodo_minerid(pindexPrev->nHeight-i,pubkeys[i])); } + for (j=0; j<65; j++) + fprintf(stderr,"%d ",mids[j]); + fprintf(stderr," <- prev minerids from ht.%d notary.%d\n",pindexPrev->nHeight,notaryid); } for (j=0; j<65; j++) if ( mids[j] == notaryid ) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c601eae47..e7034f851 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -37,6 +37,7 @@ unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET; bool bSpendZeroConfChange = true; bool fSendFreeTransactions = false; bool fPayAtLeastCustomFee = true; +extern int32_t KOMODO_EXCHANGEWALLET; /** * Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) @@ -2242,28 +2243,35 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const !IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) && (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) { -#ifdef KOMODO_ENABLE_INTEREST - extern char ASSETCHAINS_SYMBOL[16]; - uint32_t locktime; int32_t txheight; CBlockIndex *tipindex; - if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 ) + if ( KOMODO_EXCHANGEWALLET == 0 ) { - if ( pcoin->vout[i].nValue >= 10*COIN ) + extern char ASSETCHAINS_SYMBOL[16]; + uint32_t locktime; int32_t txheight; CBlockIndex *tipindex; + if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 ) { - komodo_accrued_interest(&txheight,&locktime,wtxid,i,0,pcoin->vout[i].nValue); - if ( (tipindex= chainActive.Tip()) != 0 ) + if ( pcoin->vout[i].nValue >= 10*COIN ) { - interest = komodo_interest(txheight,pcoin->vout[i].nValue,locktime,tipindex->nTime); - } else interest = 0; - //interest = komodo_interest(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime); - if ( interest != 0 ) - { - //printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u/%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,txheight,locktime,pcoin->nLockTime,tipindex->nTime); - //fprintf(stderr,"wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,pcoin->nLockTime,chainActive.Tip()->nTime); - //ptr = (uint64_t *)&pcoin->vout[i].nValue; - //(*ptr) += interest; - ptr = (uint64_t *)&pcoin->vout[i].interest; - (*ptr) = interest; - //pcoin->vout[i].nValue += interest; + komodo_accrued_interest(&txheight,&locktime,wtxid,i,0,pcoin->vout[i].nValue); + if ( (tipindex= chainActive.Tip()) != 0 ) + { + interest = komodo_interest(txheight,pcoin->vout[i].nValue,locktime,tipindex->nTime); + } else interest = 0; + //interest = komodo_interest(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime); + if ( interest != 0 ) + { + //printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u/%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,txheight,locktime,pcoin->nLockTime,tipindex->nTime); + //fprintf(stderr,"wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,pcoin->nLockTime,chainActive.Tip()->nTime); + //ptr = (uint64_t *)&pcoin->vout[i].nValue; + //(*ptr) += interest; + ptr = (uint64_t *)&pcoin->vout[i].interest; + (*ptr) = interest; + //pcoin->vout[i].nValue += interest; + } + else + { + ptr = (uint64_t *)&pcoin->vout[i].interest; + (*ptr) = 0; + } } else { @@ -2277,12 +2285,6 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const (*ptr) = 0; } } - else - { - ptr = (uint64_t *)&pcoin->vout[i].interest; - (*ptr) = 0; - } -#endif vCoins.push_back(COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO)); } } @@ -2337,7 +2339,7 @@ static void ApproximateBestSubset(vector vCoins,set >& setCoinsRet, CAmount& nValueRet, uint64_t *interestp) const { - uint64_t interests[512],lowest_interest = 0; int32_t count = 0; + uint64_t interests[1024],lowest_interest = 0; int32_t count = 0; setCoinsRet.clear(); memset(interests,0,sizeof(interests)); nValueRet = 0; @@ -2370,14 +2372,15 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(coin.second); nValueRet += coin.first; - *interestp += pcoin->vout[i].interest; + if ( KOMODO_EXCHANGEWALLET == 0 ) + *interestp += pcoin->vout[i].interest; return true; } else if (n < nTargetValue + CENT) { vValue.push_back(coin); nTotalLower += n; - if ( count < sizeof(interests)/sizeof(*interests) ) + if ( KOMODO_EXCHANGEWALLET == 0 && count < sizeof(interests)/sizeof(*interests) ) { //fprintf(stderr,"count.%d %.8f\n",count,(double)pcoin->vout[i].interest/COIN); interests[count++] = pcoin->vout[i].interest; @@ -2386,7 +2389,8 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int else if (n < coinLowestLarger.first) { coinLowestLarger = coin; - lowest_interest = pcoin->vout[i].interest; + if ( KOMODO_EXCHANGEWALLET == 0 ) + lowest_interest = pcoin->vout[i].interest; } } @@ -2396,7 +2400,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(vValue[i].second); nValueRet += vValue[i].first; - if ( i < count ) + if ( KOMODO_EXCHANGEWALLET == 0 && i < count ) *interestp += interests[i]; } return true; @@ -2408,7 +2412,8 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int return false; setCoinsRet.insert(coinLowestLarger.second); nValueRet += coinLowestLarger.first; - *interestp += lowest_interest; + if ( KOMODO_EXCHANGEWALLET == 0 ) + *interestp += lowest_interest; return true; } @@ -2428,7 +2433,8 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(coinLowestLarger.second); nValueRet += coinLowestLarger.first; - *interestp += lowest_interest; + if ( KOMODO_EXCHANGEWALLET == 0 ) + *interestp += lowest_interest; } else { for (unsigned int i = 0; i < vValue.size(); i++) @@ -2436,7 +2442,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(vValue[i].second); nValueRet += vValue[i].first; - if ( i < count ) + if ( KOMODO_EXCHANGEWALLET == 0 && i < count ) *interestp += interests[i]; } @@ -2495,7 +2501,8 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout[out.i].nValue; - *interestp += out.tx->vout[out.i].interest; + if ( KOMODO_EXCHANGEWALLET == 0 ) + *interestp += out.tx->vout[out.i].interest; setCoinsRet.insert(make_pair(out.tx, out.i)); } return (nValueRet >= nTargetValue); @@ -2634,13 +2641,18 @@ bool CWallet::CreateTransaction(const vector& vecSend, //a chance at a free transaction. //But mempool inputs might still be in the mempool, so their age stays 0 //fprintf(stderr,"nCredit %.8f interest %.8f\n",(double)nCredit/COIN,(double)pcoin.first->vout[pcoin.second].interest/COIN); - interest2 += pcoin.first->vout[pcoin.second].interest; + if ( KOMODO_EXCHANGEWALLET == 0 ) + interest2 += pcoin.first->vout[pcoin.second].interest; int age = pcoin.first->GetDepthInMainChain(); if (age != 0) age += 1; dPriority += (double)nCredit * age; } - //fprintf(stderr,"interest sum %.8f, interest2 %.8f\n",(double)interest/COIN,(double)interest2/COIN); + if ( KOMODO_EXCHANGEWALLET != 0 ) + { + //fprintf(stderr,"KOMODO_EXCHANGEWALLET disable interest sum %.8f, interest2 %.8f\n",(double)interest/COIN,(double)interest2/COIN); + interest = 0; + } CAmount nChange = (nValueIn - nValue + interest); //fprintf(stderr,"wallet change %.8f (%.8f - %.8f) interest %.8f total %.8f\n",(double)nChange/COIN,(double)nValueIn/COIN,(double)nValue/COIN,(double)interest/COIN,(double)nTotalValue/COIN); if (nSubtractFeeFromAmount == 0)