X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fwallet.h;h=d3c25f98b4d75ced5384d53627265169291c717b;hb=0561bbd1c69263dceb24ffacf850788e6e961a13;hp=c1461b1feb5106f629556ae233ab64eb0ce5329b;hpb=6b6aaa1698838278a547f16a15e635bd58ec867d;p=novacoin.git diff --git a/src/wallet.h b/src/wallet.h index c1461b1..d3c25f9 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2011-2012 The PPCoin developers // Distributed under the MIT/X11 software license, see the accompanying -// file license.txt or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_WALLET_H #define BITCOIN_WALLET_H @@ -10,6 +11,8 @@ #include "keystore.h" #include "script.h" +extern bool fWalletUnlockStakeOnly; + class CWalletTx; class CReserveKey; class CWalletDB; @@ -59,8 +62,8 @@ public: class CWallet : public CCryptoKeyStore { private: - bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, std::set >& setCoinsRet, int64& nValueRet) const; - bool SelectCoins(int64 nTargetValue, std::set >& setCoinsRet, int64& nValueRet) const; + bool SelectCoinsMinConf(int64 nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::set >& setCoinsRet, int64& nValueRet) const; + bool SelectCoins(int64 nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64& nValueRet) const; CWalletDB *pwalletdbEncryption; @@ -145,8 +148,11 @@ public: void ResendWalletTransactions(); int64 GetBalance() const; int64 GetUnconfirmedBalance() const; + int64 GetStake() const; + int64 GetNewMint() const; bool CreateTransaction(const std::vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet); bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet); + bool CreateCoinStake(unsigned int nBits, CTransaction& txNew); bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false); std::string SendMoneyToBitcoinAddress(const CBitcoinAddress& address, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false); @@ -227,7 +233,6 @@ public: void SetBestChain(const CBlockLocator& loc); int LoadWallet(bool& fFirstRunRet); -// bool BackupWallet(const std::string& strDest); bool SetAddressBookName(const CBitcoinAddress& address, const std::string& strName); @@ -270,6 +275,10 @@ public: // get the current wallet format (the oldest client version guaranteed to understand this wallet) int GetVersion() { return nWalletVersion; } + + bool CheckSpentCoins(int& nMismatchSpent, int64& nBalanceInQuestion); + void FixSpentCoins(int& nMismatchSpent, int64& nBalanceInQuestion); + void DisableTransaction(const CTransaction &tx); }; /** A key allocated from the key pool. */ @@ -317,20 +326,15 @@ public: std::vector vfSpent; // which outputs are already spent // memory only - mutable char fDebitCached; - mutable char fCreditCached; - mutable char fAvailableCreditCached; - mutable char fChangeCached; + mutable bool fDebitCached; + mutable bool fCreditCached; + mutable bool fAvailableCreditCached; + mutable bool fChangeCached; mutable int64 nDebitCached; mutable int64 nCreditCached; mutable int64 nAvailableCreditCached; mutable int64 nChangeCached; - // memory only UI hints - mutable unsigned int nTimeDisplayed; - mutable int nLinesDisplayed; - mutable char fConfirmedDisplayed; - CWalletTx() { Init(NULL); @@ -370,9 +374,6 @@ public: nCreditCached = 0; nAvailableCreditCached = 0; nChangeCached = 0; - nTimeDisplayed = 0; - nLinesDisplayed = 0; - fConfirmedDisplayed = false; } IMPLEMENT_SERIALIZE @@ -468,6 +469,18 @@ public: } } + void MarkUnspent(unsigned int nOut) + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::MarkUnspent() : nOut out of range"); + vfSpent.resize(vout.size()); + if (vfSpent[nOut]) + { + vfSpent[nOut] = false; + fAvailableCreditCached = false; + } + } + bool IsSpent(unsigned int nOut) const { if (nOut >= vout.size()) @@ -491,7 +504,7 @@ public: int64 GetCredit(bool fUseCache=true) const { // Must wait until coinbase is safely deep enough in the chain before valuing it - if (IsCoinBase() && GetBlocksToMaturity() > 0) + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) return 0; // GetBalance can assume transactions in mapWallet won't change @@ -505,7 +518,7 @@ public: int64 GetAvailableCredit(bool fUseCache=true) const { // Must wait until coinbase is safely deep enough in the chain before valuing it - if (IsCoinBase() && GetBlocksToMaturity() > 0) + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) return 0; if (fUseCache && fAvailableCreditCached)