X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fwallet.h;h=c1a987ea04846b991b52f54dd3f3e4e97e155cac;hb=056f3b1ef51d160dad763ed43cacc151735999de;hp=ff29cedab1f5f1e89635574bb3ac66fa35f15b8b;hpb=77a43545b4491b9703d803765da9059d2bdd5aaa;p=novacoin.git diff --git a/src/wallet.h b/src/wallet.h index ff29ced..c1a987e 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -27,6 +27,14 @@ class CReserveKey; class COutput; class CCoinControl; +// Set of selected transactions +typedef std::set > CoinsSet; + +// Preloaded coins metadata +// (txid, vout.n) => ((txindex, (tx, vout.n)), (block, modifier)) +typedef std::map, std::pair >, std::pair > > MetaMap; + + /** (client) version numbers for particular wallet features */ enum WalletFeature { @@ -159,10 +167,11 @@ public: // Adds an encrypted key to the store, without saving it to disk (used by LoadWallet) bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret) { SetMinVersion(FEATURE_WALLETCRYPT); return CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret); } bool AddCScript(const CScript& redeemScript); - bool LoadCScript(const CScript& redeemScript) { return CCryptoKeyStore::AddCScript(redeemScript); } + bool LoadCScript(const CScript& redeemScript); // Adds a watch-only address to the store, and saves it to disk. bool AddWatchOnly(const CScript &dest); + bool RemoveWatchOnly(const CScript &dest); // Adds a watch-only address to the store, without saving it to disk (used by LoadWallet) bool LoadWatchOnly(const CScript &dest); @@ -213,7 +222,7 @@ public: void GetStakeStats(float &nKernelsRate, float &nCoinDaysRate); void GetStakeWeightFromValue(const int64_t& nTime, const int64_t& nValue, uint64_t& nWeight); - bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CTransaction& txNew, CKey& key); + bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, uint32_t nSearchInterval, CTransaction& txNew, CKey& key); bool MergeCoins(const int64_t& nAmount, const int64_t& nMinValue, const int64_t& nMaxValue, std::list& listMerged); std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false); @@ -347,6 +356,9 @@ public: * @note called with lock cs_wallet held. */ boost::signals2::signal NotifyTransactionChanged; + + /** Watch-only address added */ + boost::signals2::signal NotifyWatchonlyChanged; }; /** A key allocated from the key pool. */ @@ -647,22 +659,37 @@ public: return nDebit; } - int64_t GetCredit(bool fUseCache=true) const + int64_t GetCredit(const isminefilter& filter) const { // Must wait until coinbase is safely deep enough in the chain before valuing it if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) return 0; - // GetBalance can assume transactions in mapWallet won't change - if (fUseCache) { + int64_t credit = 0; + if (filter & MINE_SPENDABLE) + { + // GetBalance can assume transactions in mapWallet won't change if (fCreditCached) - return nCreditCached; + credit += nCreditCached; + else + { + nCreditCached = pwallet->GetCredit(*this, MINE_SPENDABLE); + fCreditCached = true; + credit += nCreditCached; + } } - - nCreditCached = pwallet->GetCredit(*this, MINE_ALL); - fCreditCached = true; - - return nCreditCached; + if (filter & MINE_WATCH_ONLY) + { + if (fWatchCreditCached) + credit += nWatchCreditCached; + else + { + nWatchCreditCached = pwallet->GetCredit(*this, MINE_WATCH_ONLY); + fWatchCreditCached = true; + credit += nWatchCreditCached; + } + } + return credit; } int64_t GetImmatureCredit(bool fUseCache=true) const