#include "serialize.h"
#include "uint256.h"
+#include "version.h"
#include <openssl/bn.h>
#include "interface.h"
#include "sync.h"
#include "util.h"
+#include "wallet.h"
#undef printf
#include "ipcollector.h"
#include "interface.h"
#include "checkpoints.h"
+#include "wallet.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#ifndef BITCOIN_INIT_H
#define BITCOIN_INIT_H
-#include "wallet.h"
+#include <string>
+
+class CWallet;
extern CWallet* pwalletMain;
extern std::string strWalletFileName;
#include "interface.h"
#include "checkqueue.h"
#include "kernel.h"
+#include "wallet.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
return AcceptToMemoryPool(txdb);
}
-
-
-bool CWalletTx::AcceptWalletTransaction(CTxDB& txdb, bool fCheckInputs)
-{
-
- {
- LOCK(mempool.cs);
- // Add previous supporting transactions first
- for (CMerkleTx& tx : vtxPrev)
- {
- if (!(tx.IsCoinBase() || tx.IsCoinStake()))
- {
- uint256 hash = tx.GetHash();
- if (!mempool.exists(hash) && !txdb.ContainsTx(hash))
- tx.AcceptToMemoryPool(txdb, fCheckInputs);
- }
- }
- return AcceptToMemoryPool(txdb, fCheckInputs);
- }
- return false;
-}
-
-bool CWalletTx::AcceptWalletTransaction()
-{
- CTxDB txdb("r");
- return AcceptWalletTransaction(txdb);
-}
-
int CTxIndex::GetDepthInMainChain() const
{
// Read block header
#include "init.h"
#include "addrman.h"
#include "interface.h"
+#include "main.h"
#include "miner.h"
#include "ntp.h"
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef __cplusplus
-# error This header can only be compiled as C++.
-#endif
-
#ifndef __INCLUDED_PROTOCOL_H__
#define __INCLUDED_PROTOCOL_H__
#include "serialize.h"
#include "netbase.h"
-#include <string>
-#include <limits>
#include "uint256.h"
+#include "version.h"
extern bool fTestNet;
inline unsigned short GetDefaultPort()
#include "guiconstants.h"
#include "init.h"
+#include "main.h"
#include "interface.h"
#include "qtipcserver.h"
#include "intro.h"
#include "optionsmodel.h"
#include "coincontrol.h"
#include "dialogwindowflags.h"
+#include "wallet.h"
#include <QApplication>
#include <QCheckBox>
#include "init.h"
#include "walletdb.h"
#include "guiutil.h"
+#include "wallet.h"
OptionsModel::OptionsModel(QObject *parent) :
QAbstractListModel(parent)
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include "init.h" // for pwalletMain
+#include "init.h"
#include "bitcoinrpc.h"
#include "interface.h"
#include "base58.h"
+#include "wallet.h"
#define printf OutputDebugStringF
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include "main.h"
#include "db.h"
#include "txdb-leveldb.h"
#include "init.h"
#include "miner.h"
#include "kernel.h"
#include "bitcoinrpc.h"
+#include "wallet.h"
using namespace json_spirit;
using namespace std;
#ifndef BITCOIN_SERIALIZE_H
#define BITCOIN_SERIALIZE_H
-#include "version.h"
-
#include <cassert>
#include <vector>
#include <set>
#include "serialize.h"
#include "streams.h"
-
-#include <map>
-#include <string>
-#include <vector>
+#include "version.h"
#include <leveldb/db.h>
#include <leveldb/write_batch.h>
reverse(vtxPrev.begin(), vtxPrev.end());
}
+bool CWalletTx::AcceptWalletTransaction(CTxDB& txdb, bool fCheckInputs)
+{
+
+ {
+ LOCK(mempool.cs);
+ // Add previous supporting transactions first
+ for (CMerkleTx& tx : vtxPrev)
+ {
+ if (!(tx.IsCoinBase() || tx.IsCoinStake()))
+ {
+ uint256 hash = tx.GetHash();
+ if (!mempool.exists(hash) && !txdb.ContainsTx(hash))
+ tx.AcceptToMemoryPool(txdb, fCheckInputs);
+ }
+ }
+ return AcceptToMemoryPool(txdb, fCheckInputs);
+ }
+ return false;
+}
+
+bool CWalletTx::AcceptWalletTransaction()
+{
+ CTxDB txdb("r");
+ return AcceptWalletTransaction(txdb);
+}
+
bool CWalletTx::WriteToDisk()
{
return CWalletDB(pwallet->strWalletFile).WriteTx(GetHash(), *this);
SelectCoinsMinConf(nTargetValue, nSpendTime, 0, 1, vCoins, setCoinsRet, nValueRet));
}
+CWallet::CWallet()
+{
+ SetNull();
+}
+
+CWallet::CWallet(std::string strWalletFileIn)
+{
+ SetNull();
+
+ strWalletFile = strWalletFileIn;
+ fFileBacked = true;
+}
+
+void CWallet::SetNull()
+{
+ nWalletVersion = FEATURE_BASE;
+ nWalletMaxVersion = FEATURE_BASE;
+ fFileBacked = false;
+ nMasterKeyMaxID = 0;
+ pwalletdbEncryption = NULL;
+ pwalletdbDecryption = NULL;
+ nNextResend = 0;
+ nLastResend = 0;
+ nOrderPosNext = 0;
+ nKernelsTried = 0;
+ nCoinDaysTried = 0;
+ nTimeFirstKey = 0;
+}
+
// Select some coins without random shuffle or best subset approximation
bool CWallet::SelectCoinsSimple(int64_t nTargetValue, int64_t nMinValue, int64_t nMaxValue, unsigned int nSpendTime, int nMinConf, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
{
printf("\n");
}
+void CWallet::Inventory(const uint256 &hash)
+{
+ {
+ LOCK(cs_wallet);
+ std::map<uint256, int>::iterator mi = mapRequestCount.find(hash);
+ if (mi != mapRequestCount.end())
+ (*mi).second++;
+ }
+}
+
+unsigned int CWallet::GetKeyPoolSize()
+{
+ return (unsigned int)(setKeyPool.size());
+}
+
bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx)
{
{
vchPubKey = CPubKey();
}
+CReserveKey::CReserveKey(CWallet *pwalletIn)
+{
+ nIndex = -1;
+ pwallet = pwalletIn;
+}
+
+CReserveKey::~CReserveKey()
+{
+ if (!fShutdown)
+ ReturnKey();
+}
+
void CReserveKey::ReturnKey()
{
if (nIndex != -1)
EraseFromWallet(*it);
}
+
+void CWalletTx::Init(const CWallet *pwalletIn)
+{
+ pwallet = pwalletIn;
+ vtxPrev.clear();
+ mapValue.clear();
+ vOrderForm.clear();
+ fTimeReceivedIsTxTime = false;
+ nTimeReceived = 0;
+ nTimeSmart = 0;
+ fFromMe = false;
+ strFromAccount.clear();
+ vfSpent.clear();
+ fDebitCached = false;
+ fWatchDebitCached = false;
+ fCreditCached = false;
+ fWatchCreditCached = false;
+ fAvailableCreditCached = false;
+ fAvailableWatchCreditCached = false;
+ fImmatureCreditCached = false;
+ fImmatureWatchCreditCached = false;
+ fChangeCached = false;
+ nDebitCached = 0;
+ nWatchDebitCached = 0;
+ nCreditCached = 0;
+ nWatchCreditCached = 0;
+ nAvailableCreditCached = 0;
+ nAvailableWatchCreditCached = 0;
+ nImmatureCreditCached = 0;
+ nImmatureWatchCreditCached = 0;
+ nChangeCached = 0;
+ nOrderPos = -1;
+}
+
+COutput::COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn)
+{
+ tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn;
+}
+
+string COutput::ToString() const
+{
+ return strprintf("COutput(%s, %d, %d, %d) [%s]", tx->GetHash().ToString().substr(0,10).c_str(), i, fSpendable, nDepth, FormatMoney(tx->vout[i].nValue).c_str());
+}
+
+CAccount::CAccount()
+{
+ SetNull();
+}
+
+void CAccount::SetNull()
+{
+ vchPubKey = CPubKey();
+}
+
+CAccountingEntry::CAccountingEntry()
+{
+ SetNull();
+}
+
+void CAccountingEntry::SetNull()
+{
+ nCreditDebit = 0;
+ nTime = 0;
+ strAccount.clear();
+ strOtherAccount.clear();
+ strComment.clear();
+ nOrderPos = -1;
+}
+
+CWalletKey::CWalletKey(int64_t nExpires)
+{
+ nTimeCreated = (nExpires ? GetTime() : 0);
+ nTimeExpires = nExpires;
+}
+
+CKeyPool::CKeyPool()
+{
+ nTime = GetTime();
+}
+
+CKeyPool::CKeyPool(const CPubKey &vchPubKeyIn)
+{
+ nTime = GetTime();
+ vchPubKey = vchPubKeyIn;
+}
int64_t nTime;
CPubKey vchPubKey;
- CKeyPool()
- {
- nTime = GetTime();
- }
+ CKeyPool();
- CKeyPool(const CPubKey& vchPubKeyIn)
- {
- nTime = GetTime();
- vchPubKey = vchPubKeyIn;
- }
+ CKeyPool(const CPubKey& vchPubKeyIn);
IMPLEMENT_SERIALIZE
(
MasterKeyMap mapMasterKeys;
unsigned int nMasterKeyMaxID;
- CWallet()
- {
- SetNull();
- }
- CWallet(std::string strWalletFileIn)
- {
- SetNull();
-
- strWalletFile = strWalletFileIn;
- fFileBacked = true;
- }
- void SetNull()
- {
- nWalletVersion = FEATURE_BASE;
- nWalletMaxVersion = FEATURE_BASE;
- fFileBacked = false;
- nMasterKeyMaxID = 0;
- pwalletdbEncryption = NULL;
- pwalletdbDecryption = NULL;
- nNextResend = 0;
- nLastResend = 0;
- nOrderPosNext = 0;
- nKernelsTried = 0;
- nCoinDaysTried = 0;
- nTimeFirstKey = 0;
- }
+ CWallet();
+ CWallet(std::string strWalletFileIn);
+ void SetNull();
std::map<uint256, CWalletTx> mapWallet;
std::vector<uint256> vMintingWalletUpdated;
void UpdatedTransaction(const uint256 &hashTx);
void PrintWallet(const CBlock& block);
- void Inventory(const uint256 &hash)
- {
- {
- LOCK(cs_wallet);
- std::map<uint256, int>::iterator mi = mapRequestCount.find(hash);
- if (mi != mapRequestCount.end())
- (*mi).second++;
- }
- }
+ void Inventory(const uint256 &hash);
- unsigned int GetKeyPoolSize()
- {
- return (unsigned int)(setKeyPool.size());
- }
+ unsigned int GetKeyPoolSize();
bool GetTransaction(const uint256 &hashTx, CWalletTx& wtx);
bool SetDefaultKey(const CPubKey &vchPubKey);
int64_t nIndex;
CPubKey vchPubKey;
public:
- CReserveKey(CWallet* pwalletIn)
- {
- nIndex = -1;
- pwallet = pwalletIn;
- }
+ CReserveKey(CWallet* pwalletIn);
- ~CReserveKey()
- {
- if (!fShutdown)
- ReturnKey();
- }
+ ~CReserveKey();
void ReturnKey();
CPubKey GetReservedKey();
Init(pwalletIn);
}
- void Init(const CWallet* pwalletIn)
- {
- pwallet = pwalletIn;
- vtxPrev.clear();
- mapValue.clear();
- vOrderForm.clear();
- fTimeReceivedIsTxTime = false;
- nTimeReceived = 0;
- nTimeSmart = 0;
- fFromMe = false;
- strFromAccount.clear();
- vfSpent.clear();
- fDebitCached = false;
- fWatchDebitCached = false;
- fCreditCached = false;
- fWatchCreditCached = false;
- fAvailableCreditCached = false;
- fAvailableWatchCreditCached = false;
- fImmatureCreditCached = false;
- fImmatureWatchCreditCached = false;
- fChangeCached = false;
- nDebitCached = 0;
- nWatchDebitCached = 0;
- nCreditCached = 0;
- nWatchCreditCached = 0;
- nAvailableCreditCached = 0;
- nAvailableWatchCreditCached = 0;
- nImmatureCreditCached = 0;
- nImmatureWatchCreditCached = 0;
- nChangeCached = 0;
- nOrderPos = -1;
- }
+ void Init(const CWallet* pwalletIn);
IMPLEMENT_SERIALIZE
(
int nDepth;
bool fSpendable;
- COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn)
- {
- tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn;
- }
+ COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn);
- std::string ToString() const
- {
- return strprintf("COutput(%s, %d, %d, %d) [%s]", tx->GetHash().ToString().substr(0,10).c_str(), i, fSpendable, nDepth, FormatMoney(tx->vout[i].nValue).c_str());
- }
+ std::string ToString() const;
};
//// todo: add something to note what created it (user, getnewaddress, change)
//// maybe should have a map<string, string> property map
- CWalletKey(int64_t nExpires=0)
- {
- nTimeCreated = (nExpires ? GetTime() : 0);
- nTimeExpires = nExpires;
- }
+ CWalletKey(int64_t nExpires=0);
IMPLEMENT_SERIALIZE
(
public:
CPubKey vchPubKey;
- CAccount()
- {
- SetNull();
- }
+ CAccount();
- void SetNull()
- {
- vchPubKey = CPubKey();
- }
+ void SetNull();
IMPLEMENT_SERIALIZE
(
int64_t nOrderPos; // position in ordered transaction list
uint64_t nEntryNo;
- CAccountingEntry()
- {
- SetNull();
- }
+ CAccountingEntry();
- void SetNull()
- {
- nCreditDebit = 0;
- nTime = 0;
- strAccount.clear();
- strOtherAccount.clear();
- strComment.clear();
- nOrderPos = -1;
- }
+ void SetNull();
IMPLEMENT_SERIALIZE
(