Includes cleanup
authorsvost <ya.nowa@yandex.ru>
Fri, 11 Feb 2022 13:30:42 +0000 (16:30 +0300)
committersvost <ya.nowa@yandex.ru>
Fri, 11 Feb 2022 13:30:42 +0000 (16:30 +0300)
16 files changed:
src/bignum.h
src/bitcoinrpc.cpp
src/init.cpp
src/init.h
src/main.cpp
src/net.cpp
src/protocol.h
src/qt/bitcoin.cpp
src/qt/coincontroldialog.cpp
src/qt/optionsmodel.cpp
src/rpcdump.cpp
src/rpcmining.cpp
src/serialize.h
src/txdb-leveldb.h
src/wallet.cpp
src/wallet.h

index 8c6b588..418f343 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "serialize.h"
 #include "uint256.h"
+#include "version.h"
 
 #include <openssl/bn.h>
 
index 4bda0c9..dafacef 100644 (file)
@@ -10,6 +10,7 @@
 #include "interface.h"
 #include "sync.h"
 #include "util.h"
+#include "wallet.h"
 
 #undef printf
 
index 84749d3..9d42a55 100644 (file)
@@ -11,6 +11,7 @@
 #include "ipcollector.h"
 #include "interface.h"
 #include "checkpoints.h"
+#include "wallet.h"
 
 #include <boost/filesystem.hpp>
 #include <boost/filesystem/fstream.hpp>
index 84f2712..e2f3d25 100644 (file)
@@ -5,7 +5,9 @@
 #ifndef BITCOIN_INIT_H
 #define BITCOIN_INIT_H
 
-#include "wallet.h"
+#include <string>
+
+class CWallet;
 
 extern CWallet* pwalletMain;
 extern std::string strWalletFileName;
index 8cf70d1..805c043 100644 (file)
@@ -12,6 +12,7 @@
 #include "interface.h"
 #include "checkqueue.h"
 #include "kernel.h"
+#include "wallet.h"
 
 #include <boost/filesystem.hpp>
 #include <boost/filesystem/fstream.hpp>
@@ -862,34 +863,6 @@ bool CMerkleTx::AcceptToMemoryPool()
     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
index 00bf067..28f40b8 100644 (file)
@@ -9,6 +9,7 @@
 #include "init.h"
 #include "addrman.h"
 #include "interface.h"
+#include "main.h"
 #include "miner.h"
 #include "ntp.h"
 
index fcc8c9e..675c0d8 100644 (file)
@@ -3,18 +3,13 @@
 // 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()
index 4c9af3a..f856c39 100644 (file)
@@ -9,6 +9,7 @@
 #include "guiconstants.h"
 
 #include "init.h"
+#include "main.h"
 #include "interface.h"
 #include "qtipcserver.h"
 #include "intro.h"
index e288f1f..25b2d6e 100644 (file)
@@ -10,6 +10,7 @@
 #include "optionsmodel.h"
 #include "coincontrol.h"
 #include "dialogwindowflags.h"
+#include "wallet.h"
 
 #include <QApplication>
 #include <QCheckBox>
index 59553c3..386a2cd 100644 (file)
@@ -5,6 +5,7 @@
 #include "init.h"
 #include "walletdb.h"
 #include "guiutil.h"
+#include "wallet.h"
 
 OptionsModel::OptionsModel(QObject *parent) :
     QAbstractListModel(parent)
index 44615a1..1bdc3cc 100644 (file)
@@ -2,10 +2,11 @@
 // 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
 
index 18c3134..c00c356 100644 (file)
@@ -3,13 +3,13 @@
 // 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;
index f24fd5c..e9b6120 100644 (file)
@@ -5,8 +5,6 @@
 #ifndef BITCOIN_SERIALIZE_H
 #define BITCOIN_SERIALIZE_H
 
-#include "version.h"
-
 #include <cassert>
 #include <vector>
 #include <set>
index 50b390b..ef8b1fd 100644 (file)
@@ -8,10 +8,7 @@
 
 #include "serialize.h"
 #include "streams.h"
-
-#include <map>
-#include <string>
-#include <vector>
+#include "version.h"
 
 #include <leveldb/db.h>
 #include <leveldb/write_batch.h>
index 1b4025d..3ed6c9e 100644 (file)
@@ -1374,6 +1374,32 @@ void CWalletTx::AddSupportingTransactions(CTxDB& txdb)
     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);
@@ -1939,6 +1965,35 @@ bool CWallet::SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, set<pai
             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
 {
@@ -2628,6 +2683,21 @@ void CWallet::PrintWallet(const CBlock& block)
     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)
 {
     {
@@ -3066,6 +3136,18 @@ void CReserveKey::KeepKey()
     vchPubKey = CPubKey();
 }
 
+CReserveKey::CReserveKey(CWallet *pwalletIn)
+{
+    nIndex = -1;
+    pwallet = pwalletIn;
+}
+
+CReserveKey::~CReserveKey()
+{
+    if (!fShutdown)
+        ReturnKey();
+}
+
 void CReserveKey::ReturnKey()
 {
     if (nIndex != -1)
@@ -3164,3 +3246,88 @@ void CWallet::ClearOrphans()
         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;
+}
index 138446b..208e261 100644 (file)
@@ -49,16 +49,9 @@ public:
     int64_t nTime;
     CPubKey vchPubKey;
 
-    CKeyPool()
-    {
-        nTime = GetTime();
-    }
+    CKeyPool();
 
-    CKeyPool(const CPubKey& vchPubKeyIn)
-    {
-        nTime = GetTime();
-        vchPubKey = vchPubKeyIn;
-    }
+    CKeyPool(const CPubKey& vchPubKeyIn);
 
     IMPLEMENT_SERIALIZE
     (
@@ -110,32 +103,9 @@ public:
     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;
@@ -280,20 +250,9 @@ public:
     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);
@@ -332,17 +291,9 @@ protected:
     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();
@@ -432,38 +383,7 @@ public:
         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
     (
@@ -580,15 +500,9 @@ public:
     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;
 };
 
 
@@ -605,11 +519,7 @@ public:
     //// 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
     (
@@ -635,15 +545,9 @@ class CAccount
 public:
     CPubKey vchPubKey;
 
-    CAccount()
-    {
-        SetNull();
-    }
+    CAccount();
 
-    void SetNull()
-    {
-        vchPubKey = CPubKey();
-    }
+    void SetNull();
 
     IMPLEMENT_SERIALIZE
     (
@@ -670,20 +574,9 @@ public:
     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
     (