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..020b2b073 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1454,6 +1454,7 @@ 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); + KOMODO_EXCHANGEWALLET = GetBoolArg("-exchange", false); NOTARY_PUBKEY = GetArg("-pubkey", ""); if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c601eae47..8e9667803 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,16 @@ 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 ) + interest = 0; +//fprintf(stderr,"interest sum %.8f, interest2 %.8f\n",(double)interest/COIN,(double)interest2/COIN); 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)