Merge pull request #363 from svost/c++11
authorCryptoManiac <CryptoManiac@users.noreply.github.com>
Mon, 30 Jan 2017 10:42:29 +0000 (13:42 +0300)
committerGitHub <noreply@github.com>
Mon, 30 Jan 2017 10:42:29 +0000 (13:42 +0300)
Build fixes

28 files changed:
contrib/debian/examples/novacoin.conf
contrib/debian/manpages/novacoin.conf.5
contrib/debian/manpages/novacoind.1
src/init.cpp
src/kernel.h
src/kernelrecord.cpp
src/key.cpp
src/key.h
src/keystore.cpp
src/keystore.h
src/main.h
src/net.cpp
src/netbase.cpp
src/netbase.h
src/qt/addressbookpage.cpp
src/qt/addressbookpage.h
src/qt/forms/optionsdialog.ui
src/qt/multisigdialog.cpp
src/qt/optionsdialog.cpp
src/qt/optionsmodel.cpp
src/rpcmining.cpp
src/rpcrawtransaction.cpp
src/rpcwallet.cpp
src/script.cpp
src/script.h
src/serialize.h
src/timestamps.h
src/wallet.cpp

index 3e0dd1f..3ca9e02 100644 (file)
@@ -6,7 +6,7 @@
 # Run on the test network instead of the real novacoin network.
 #testnet=1
 
-# Connect via a socks4 proxy
+# Connect via a socks5 proxy
 #proxy=127.0.0.1:9050
 
 # Use as many addnode= settings as you like to connect to specific peers
index 1901e16..20590d0 100644 (file)
@@ -16,7 +16,7 @@ novacoin.conf should be located in $HOME/.novacoin
 Enable or disable run on the test network instead of the real *novacoin* network.
 .TP
 \fBproxy=\fR\fI'127.0.0.1:9050'\fR
-Connect via a socks4 proxy.
+Connect via a socks5 proxy.
 .TP
 \fBaddnode=\fR\fI'10.0.0.2:8333'\fR
 Use as many *addnode=* settings as you like to connect to specific peers.
index b8199c2..a17b398 100644 (file)
@@ -28,7 +28,7 @@ Start minimized
 Specify data directory
 .TP
 \fB\-proxy=\fR<ip:port>
-Connect through socks4 proxy
+Connect through socks5 proxy
 .TP
 \fB\-addnode=\fR<ip>
 Add a node to connect to
index 90bf8de..4b64d35 100644 (file)
@@ -239,8 +239,7 @@ std::string HelpMessage()
         "  -dbcache=<n>           " + _("Set database cache size in megabytes (default: 25)") + "\n" +
         "  -dblogsize=<n>         " + _("Set database disk log size in megabytes (default: 100)") + "\n" +
         "  -timeout=<n>           " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" +
-        "  -proxy=<ip:port>       " + _("Connect through socks proxy") + "\n" +
-        "  -socks=<n>             " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n" +
+        "  -proxy=<ip:port>       " + _("Connect through socks5 proxy") + "\n" +
         "  -tor=<ip:port>         " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n"
         "  -torname=<host.onion>  " + _("Send the specified hidden service name when connecting to Tor nodes (default: none)") + "\n"
         "  -dns                   " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n" +
@@ -629,11 +628,6 @@ bool AppInit2()
 
     // ********************************************************* Step 6: network initialization
 
-    int nSocksVersion = GetArgInt("-socks", 5);
-
-    if (nSocksVersion != 4 && nSocksVersion != 5)
-        return InitError(strprintf(_("Unknown -socks proxy version requested: %i"), nSocksVersion));
-
     if (mapArgs.count("-onlynet")) {
         std::set<enum Network> nets;
         for(std::string snet :  mapMultiArgs["-onlynet"]) {
@@ -663,14 +657,12 @@ bool AppInit2()
             return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"].c_str()));
 
         if (!IsLimited(NET_IPV4))
-            SetProxy(NET_IPV4, addrProxy, nSocksVersion);
-        if (nSocksVersion > 4) {
+            SetProxy(NET_IPV4, addrProxy);
 #ifdef USE_IPV6
             if (!IsLimited(NET_IPV6))
-                SetProxy(NET_IPV6, addrProxy, nSocksVersion);
+                SetProxy(NET_IPV6, addrProxy);
 #endif
-            SetNameProxy(addrProxy, nSocksVersion);
-        }
+            SetNameProxy(addrProxy);
         fProxy = true;
     }
 
@@ -683,7 +675,7 @@ bool AppInit2()
             addrOnion = CService(mapArgs["-tor"], nSocksDefault);
         if (!addrOnion.IsValid())
             return InitError(strprintf(_("Invalid -tor address: '%s'"), mapArgs["-tor"].c_str()));
-        SetProxy(NET_TOR, addrOnion, 5);
+        SetProxy(NET_TOR, addrOnion);
         SetReachable(NET_TOR);
     }
 
index 3649070..4d143ab 100644 (file)
@@ -4,6 +4,8 @@
 #ifndef PPCOIN_KERNEL_H
 #define PPCOIN_KERNEL_H
 
+#include <algorithm>
+
 #include "uint256.h"
 
 class CBlock;
index beb8aa7..552d060 100644 (file)
@@ -1,4 +1,5 @@
 #include "kernelrecord.h"
+#include "kernel.h"
 
 #include "wallet.h"
 #include "base58.h"
index 072199b..3c4762e 100644 (file)
@@ -165,6 +165,10 @@ const unsigned char vchMaxModHalfOrder[32] = {
 
 const unsigned char *vchZero = NULL;
 
+CScriptID::CScriptID(const CScript& in) : uint160(Hash160(in.begin(), in.end()))
+{
+}
+
 void CKey::SetCompressedPubKey(bool fCompressed)
 {
     EC_KEY_set_conv_form(pkey, fCompressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED);
index c4c1c96..5c42c41 100644 (file)
--- a/src/key.h
+++ b/src/key.h
@@ -59,6 +59,7 @@ class CScriptID : public uint160
 {
 public:
     CScriptID() : uint160(0) { }
+    CScriptID(const CScript& in);
     CScriptID(const uint160 &in) : uint160(in) { }
 };
 
index 86a4cc3..e5f0ce3 100644 (file)
@@ -18,6 +18,15 @@ bool CKeyStore::GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
     return true;
 }
 
+bool CKeyStore::GetSecret(const CKeyID &address, CSecret& vchSecret, bool &fCompressed) const
+{
+    CKey key;
+    if (!GetKey(address, key))
+        return false;
+    vchSecret = key.GetSecret(fCompressed);
+    return true;
+}
+
 bool CBasicKeyStore::AddKey(const CKey& key)
 {
     bool fCompressed = false;
@@ -38,6 +47,54 @@ bool CBasicKeyStore::AddMalleableKey(const CMalleableKeyView& keyView, const CSe
     return true;
 }
 
+bool CBasicKeyStore::GetMalleableKey(const CMalleableKeyView &keyView, CMalleableKey &mKey) const
+{
+    {
+        LOCK(cs_KeyStore);
+        MalleableKeyMap::const_iterator mi = mapMalleableKeys.find(keyView);
+        if (mi != mapMalleableKeys.end())
+        {
+            mKey = mi->first.GetMalleableKey(mi->second);
+            return true;
+        }
+    }
+    return false;
+}
+
+bool CBasicKeyStore::HaveKey(const CKeyID &address) const
+{
+    bool result;
+    {
+        LOCK(cs_KeyStore);
+        result = (mapKeys.count(address) > 0);
+    }
+    return result;
+}
+
+void CBasicKeyStore::GetKeys(std::set<CKeyID> &setAddress) const
+{
+    setAddress.clear();
+    {
+        LOCK(cs_KeyStore);
+        KeyMap::const_iterator mi;
+        for (mi = mapKeys.begin(); mi != mapKeys.end(); ++mi) setAddress.insert((*mi).first);
+    }
+}
+
+bool CBasicKeyStore::GetKey(const CKeyID &address, CKey &keyOut) const
+{
+    {
+        LOCK(cs_KeyStore);
+        KeyMap::const_iterator mi = mapKeys.find(address);
+        if (mi != mapKeys.end())
+        {
+            keyOut.SetSecret((*mi).second.first, (*mi).second.second);
+            return true;
+        }
+    }
+    return false;
+}
+
 bool CBasicKeyStore::AddCScript(const CScript& redeemScript)
 {
     if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)
@@ -45,7 +102,7 @@ bool CBasicKeyStore::AddCScript(const CScript& redeemScript)
 
     {
         LOCK(cs_KeyStore);
-        mapScripts[redeemScript.GetID()] = redeemScript;
+        mapScripts[CScriptID(redeemScript)] = redeemScript;
     }
     return true;
 }
@@ -111,6 +168,77 @@ bool CBasicKeyStore::HaveWatchOnly() const
     return (!setWatchOnly.empty());
 }
 
+bool CBasicKeyStore::CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R) const
+{
+    {
+        LOCK(cs_KeyStore);
+        for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
+        {
+            if (mi->first.CheckKeyVariant(R, pubKeyVariant))
+                return true;
+        }
+    }
+    return false;
+}
+
+bool CBasicKeyStore::CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R, CMalleableKeyView &view) const
+{
+    {
+        LOCK(cs_KeyStore);
+        for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
+        {
+            if (mi->first.CheckKeyVariant(R, pubKeyVariant))
+            {
+                view = mi->first;
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+bool CBasicKeyStore::CreatePrivKey(const CPubKey &pubKeyVariant, const CPubKey &R, CKey &privKey) const
+{
+    {
+        LOCK(cs_KeyStore);
+        for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
+        {
+            if (mi->first.CheckKeyVariant(R, pubKeyVariant))
+            {
+                CMalleableKey mKey = mi->first.GetMalleableKey(mi->second);
+                return mKey.CheckKeyVariant(R, pubKeyVariant, privKey);
+            }
+        }
+    }
+    return false;
+}
+
+void CBasicKeyStore::ListMalleableViews(std::list<CMalleableKeyView> &malleableViewList) const
+{
+    malleableViewList.clear();
+    {
+        LOCK(cs_KeyStore);
+        for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
+            malleableViewList.push_back(CMalleableKeyView(mi->first));
+    }
+}
+
+bool CBasicKeyStore::GetMalleableView(const CMalleablePubKey &mpk, CMalleableKeyView &view)
+{
+    const CKeyID &mpkID = mpk.GetID();
+    {
+        LOCK(cs_KeyStore);
+        for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
+            if (mi->first.GetID() == mpkID)
+            {
+                view = CMalleableKeyView(mi->first);
+                return true;
+            }
+    }
+    return false;
+}
+
+
 bool CCryptoKeyStore::SetCrypted()
 {
     {
@@ -124,6 +252,27 @@ bool CCryptoKeyStore::SetCrypted()
     return true;
 }
 
+CCryptoKeyStore::CCryptoKeyStore() : fUseCrypto(false), fDecryptionThoroughlyChecked(false)
+{
+}
+
+bool CCryptoKeyStore::IsCrypted() const
+{
+    return fUseCrypto;
+}
+
+bool CCryptoKeyStore::IsLocked() const
+{
+    if (!IsCrypted())
+        return false;
+    bool result;
+    {
+        LOCK(cs_KeyStore);
+        result = vMasterKey.empty();
+    }
+    return result;
+}
+
 bool CCryptoKeyStore::Lock()
 {
     if (!SetCrypted())
@@ -266,6 +415,16 @@ bool CCryptoKeyStore::AddMalleableKey(const CMalleableKeyView& keyView, const CS
     return true;
 }
 
+bool CCryptoKeyStore::HaveKey(const CKeyID &address) const
+{
+    {
+        LOCK(cs_KeyStore);
+        if (!IsCrypted())
+            return CBasicKeyStore::HaveKey(address);
+        return mapCryptedKeys.count(address) > 0;
+    }
+}
+
 bool CCryptoKeyStore::AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret)
 {
     {
@@ -385,6 +544,90 @@ bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) co
     return false;
 }
 
+void CCryptoKeyStore::GetKeys(std::set<CKeyID> &setAddress) const
+{
+    if (!IsCrypted())
+    {
+        CBasicKeyStore::GetKeys(setAddress);
+        return;
+    }
+    setAddress.clear();
+    CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin();
+    while (mi != mapCryptedKeys.end())
+    {
+        setAddress.insert((*mi).first);
+        mi++;
+    }
+}
+
+bool CCryptoKeyStore::CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R) const
+{
+    {
+        LOCK(cs_KeyStore);
+        if (!IsCrypted())
+            return CBasicKeyStore::CheckOwnership(pubKeyVariant, R);
+        for (CryptedMalleableKeyMap::const_iterator mi = mapCryptedMalleableKeys.begin(); mi != mapCryptedMalleableKeys.end(); mi++)
+        {
+            if (mi->first.CheckKeyVariant(R, pubKeyVariant))
+                return true;
+        }
+    }
+    return false;
+}
+
+bool CCryptoKeyStore::CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R, CMalleableKeyView &view) const
+{
+    {
+        LOCK(cs_KeyStore);
+        if (!IsCrypted())
+            return CBasicKeyStore::CheckOwnership(pubKeyVariant, R, view);
+        for (CryptedMalleableKeyMap::const_iterator mi = mapCryptedMalleableKeys.begin(); mi != mapCryptedMalleableKeys.end(); mi++)
+        {
+            if (mi->first.CheckKeyVariant(R, pubKeyVariant))
+            {
+                view = mi->first;
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+bool CCryptoKeyStore::CheckOwnership(const CMalleablePubKey &mpk)
+{
+    CMalleableKeyView view;
+    return GetMalleableView(mpk, view);
+}
+
+void CCryptoKeyStore::ListMalleableViews(std::list<CMalleableKeyView> &malleableViewList) const
+{
+    malleableViewList.clear();
+    {
+        LOCK(cs_KeyStore);
+        if (!IsCrypted())
+            return CBasicKeyStore::ListMalleableViews(malleableViewList);
+        for (CryptedMalleableKeyMap::const_iterator mi = mapCryptedMalleableKeys.begin(); mi != mapCryptedMalleableKeys.end(); mi++)
+            malleableViewList.push_back(CMalleableKeyView(mi->first));
+    }
+}
+
+bool CCryptoKeyStore::GetMalleableView(const CMalleablePubKey &mpk, CMalleableKeyView &view)
+{
+    const CKeyID &mpkID = mpk.GetID();
+    {
+        LOCK(cs_KeyStore);
+        if (!IsCrypted())
+            return CBasicKeyStore::GetMalleableView(mpk, view);
+        for (CryptedMalleableKeyMap::const_iterator mi = mapCryptedMalleableKeys.begin(); mi != mapCryptedMalleableKeys.end(); mi++)
+            if (mi->first.GetID() == mpkID)
+            {
+                view = CMalleableKeyView(mi->first);
+                return true;
+            }
+    }
+    return false;
+}
+
 bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
 {
     {
index 65398a1..a1080ad 100644 (file)
@@ -60,14 +60,7 @@ public:
     virtual bool HaveWatchOnly(const CScript &dest) const =0;
     virtual bool HaveWatchOnly() const =0;
 
-    virtual bool GetSecret(const CKeyID &address, CSecret& vchSecret, bool &fCompressed) const
-    {
-        CKey key;
-        if (!GetKey(address, key))
-            return false;
-        vchSecret = key.GetSecret(fCompressed);
-        return true;
-    }
+    virtual bool GetSecret(const CKeyID &address, CSecret& vchSecret, bool &fCompressed) const;
 
     virtual bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R) const =0;
     virtual bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R, CMalleableKeyView &view) const =0;
@@ -93,51 +86,10 @@ protected:
 public:
     bool AddKey(const CKey& key);
     bool AddMalleableKey(const CMalleableKeyView& keyView, const CSecret &vchSecretH);
-    bool GetMalleableKey(const CMalleableKeyView &keyView, CMalleableKey &mKey) const
-    {
-        {
-            LOCK(cs_KeyStore);
-            MalleableKeyMap::const_iterator mi = mapMalleableKeys.find(keyView);
-            if (mi != mapMalleableKeys.end())
-            {
-                mKey = mi->first.GetMalleableKey(mi->second);
-                return true;
-            }
-        }
-        return false;
-    }
-
-    bool HaveKey(const CKeyID &address) const
-    {
-        bool result;
-        {
-            LOCK(cs_KeyStore);
-            result = (mapKeys.count(address) > 0);
-        }
-        return result;
-    }
-    void GetKeys(std::set<CKeyID> &setAddress) const
-    {
-        setAddress.clear();
-        {
-            LOCK(cs_KeyStore);
-            KeyMap::const_iterator mi;
-            for (mi = mapKeys.begin(); mi != mapKeys.end(); ++mi) setAddress.insert((*mi).first);
-        }
-    }
-    bool GetKey(const CKeyID &address, CKey &keyOut) const
-    {
-        {
-            LOCK(cs_KeyStore);
-            KeyMap::const_iterator mi = mapKeys.find(address);
-            if (mi != mapKeys.end())
-            {
-                keyOut.SetSecret((*mi).second.first, (*mi).second.second);
-                return true;
-            }
-        }
-        return false;
-    }
+    bool GetMalleableKey(const CMalleableKeyView &keyView, CMalleableKey &mKey) const;
+    bool HaveKey(const CKeyID &address) const;
+    void GetKeys(std::set<CKeyID> &setAddress) const;
+    bool GetKey(const CKeyID &address, CKey &keyOut) const;
     virtual bool AddCScript(const CScript& redeemScript);
     virtual bool HaveCScript(const CScriptID &hash) const;
     virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const;
@@ -147,76 +99,11 @@ public:
     virtual bool HaveWatchOnly(const CScript &dest) const;
     virtual bool HaveWatchOnly() const;
 
-    bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R) const
-    {
-        {
-            LOCK(cs_KeyStore);
-            for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
-            {
-                if (mi->first.CheckKeyVariant(R, pubKeyVariant))
-                    return true;
-            }
-        }
-        return false;
-    }
-
-    bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R, CMalleableKeyView &view) const
-    {
-        {
-            LOCK(cs_KeyStore);
-            for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
-            {
-                if (mi->first.CheckKeyVariant(R, pubKeyVariant))
-                {
-                    view = mi->first;
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    bool CreatePrivKey(const CPubKey &pubKeyVariant, const CPubKey &R, CKey &privKey) const
-    {
-        {
-            LOCK(cs_KeyStore);
-            for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
-            {
-                if (mi->first.CheckKeyVariant(R, pubKeyVariant))
-                {
-                    CMalleableKey mKey = mi->first.GetMalleableKey(mi->second);
-                    return mKey.CheckKeyVariant(R, pubKeyVariant, privKey);
-                }
-            }
-        }
-        return false;
-    }
-
-    void ListMalleableViews(std::list<CMalleableKeyView> &malleableViewList) const
-    {
-        malleableViewList.clear();
-        {
-            LOCK(cs_KeyStore);
-            for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
-                malleableViewList.push_back(CMalleableKeyView(mi->first));
-        }
-    }
-
-    bool GetMalleableView(const CMalleablePubKey &mpk, CMalleableKeyView &view)
-    {
-        const CKeyID &mpkID = mpk.GetID();
-        {
-            LOCK(cs_KeyStore);
-            for (MalleableKeyMap::const_iterator mi = mapMalleableKeys.begin(); mi != mapMalleableKeys.end(); mi++)
-                if (mi->first.GetID() == mpkID)
-                {
-                    view = CMalleableKeyView(mi->first);
-                    return true;
-                }
-        }
-
-        return false;
-    }
+    bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R) const;
+    bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R, CMalleableKeyView &view) const;
+    bool CreatePrivKey(const CPubKey &pubKeyVariant, const CPubKey &R, CKey &privKey) const;
+    void ListMalleableViews(std::list<CMalleableKeyView> &malleableViewList) const;
+    bool GetMalleableView(const CMalleablePubKey &mpk, CMalleableKeyView &view);
 };
 
 typedef std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char> > > CryptedKeyMap;
@@ -250,25 +137,10 @@ protected:
     bool Unlock(const CKeyingMaterial& vMasterKeyIn);
 
 public:
-    CCryptoKeyStore() : fUseCrypto(false), fDecryptionThoroughlyChecked(false) { }
-
-    bool IsCrypted() const
-    {
-        return fUseCrypto;
-    }
-
-    bool IsLocked() const
-    {
-        if (!IsCrypted())
-            return false;
-        bool result;
-        {
-            LOCK(cs_KeyStore);
-            result = vMasterKey.empty();
-        }
-        return result;
-    }
+    CCryptoKeyStore();
 
+    bool IsCrypted() const;
+    bool IsLocked() const;
     bool Lock();
 
     virtual bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
@@ -276,106 +148,17 @@ public:
 
     bool AddKey(const CKey& key);
     bool AddMalleableKey(const CMalleableKeyView& keyView, const CSecret &vchSecretH);
-    bool HaveKey(const CKeyID &address) const
-    {
-        {
-            LOCK(cs_KeyStore);
-            if (!IsCrypted())
-                return CBasicKeyStore::HaveKey(address);
-            return mapCryptedKeys.count(address) > 0;
-        }
-    }
+    bool HaveKey(const CKeyID &address) const;
     bool GetKey(const CKeyID &address, CKey& keyOut) const;
     bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const;
-    void GetKeys(std::set<CKeyID> &setAddress) const
-    {
-        if (!IsCrypted())
-        {
-            CBasicKeyStore::GetKeys(setAddress);
-            return;
-        }
-        setAddress.clear();
-        CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin();
-        while (mi != mapCryptedKeys.end())
-        {
-            setAddress.insert((*mi).first);
-            mi++;
-        }
-    }
-
+    void GetKeys(std::set<CKeyID> &setAddress) const;
     bool GetMalleableKey(const CMalleableKeyView &keyView, CMalleableKey &mKey) const;
-
-    bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R) const
-    {
-        {
-            LOCK(cs_KeyStore);
-            if (!IsCrypted())
-                return CBasicKeyStore::CheckOwnership(pubKeyVariant, R);
-            for (CryptedMalleableKeyMap::const_iterator mi = mapCryptedMalleableKeys.begin(); mi != mapCryptedMalleableKeys.end(); mi++)
-            {
-                if (mi->first.CheckKeyVariant(R, pubKeyVariant))
-                    return true;
-            }
-        }
-        return false;
-    }
-
-    bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R, CMalleableKeyView &view) const
-    {
-        {
-            LOCK(cs_KeyStore);
-            if (!IsCrypted())
-                return CBasicKeyStore::CheckOwnership(pubKeyVariant, R, view);
-            for (CryptedMalleableKeyMap::const_iterator mi = mapCryptedMalleableKeys.begin(); mi != mapCryptedMalleableKeys.end(); mi++)
-            {
-                if (mi->first.CheckKeyVariant(R, pubKeyVariant))
-                {
-                    view = mi->first;
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    bool CheckOwnership(const CMalleablePubKey &mpk)
-    {
-        CMalleableKeyView view;
-        return GetMalleableView(mpk, view);
-    }
-
+    bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R) const;
+    bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R, CMalleableKeyView &view) const;
+    bool CheckOwnership(const CMalleablePubKey &mpk);
     bool CreatePrivKey(const CPubKey &pubKeyVariant, const CPubKey &R, CKey &privKey) const;
-
-    void ListMalleableViews(std::list<CMalleableKeyView> &malleableViewList) const
-    {
-        malleableViewList.clear();
-        {
-            LOCK(cs_KeyStore);
-            if (!IsCrypted())
-                return CBasicKeyStore::ListMalleableViews(malleableViewList);
-            for (CryptedMalleableKeyMap::const_iterator mi = mapCryptedMalleableKeys.begin(); mi != mapCryptedMalleableKeys.end(); mi++)
-                malleableViewList.push_back(CMalleableKeyView(mi->first));
-        }
-    }
-
-    bool GetMalleableView(const CMalleablePubKey &mpk, CMalleableKeyView &view)
-    {
-        const CKeyID &mpkID = mpk.GetID();
-        {
-            LOCK(cs_KeyStore);
-            if (!IsCrypted())
-                return CBasicKeyStore::GetMalleableView(mpk, view);
-            for (CryptedMalleableKeyMap::const_iterator mi = mapCryptedMalleableKeys.begin(); mi != mapCryptedMalleableKeys.end(); mi++)
-                if (mi->first.GetID() == mpkID)
-                {
-                    view = CMalleableKeyView(mi->first);
-                    return true;
-                }
-        }
-
-        return false;
-    }
-
+    void ListMalleableViews(std::list<CMalleableKeyView> &malleableViewList) const;
+    bool GetMalleableView(const CMalleablePubKey &mpk, CMalleableKeyView &view);
     /* Wallet status (encrypted, locked) changed.
      * Note: Called without locks held.
      */
index 62417c7..1a61a63 100644 (file)
@@ -54,8 +54,6 @@ static const int64_t MIN_TXOUT_AMOUNT = CENT/100;
 
 inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
 inline bool MoneyRange(CBigNum nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
-// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
-static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov  5 00:53:20 1985 UTC
 // Maximum number of script-checking threads allowed
 static const int MAX_SCRIPTCHECK_THREADS = 16;
 
index bf2f38b..7137f1d 100644 (file)
@@ -789,13 +789,6 @@ void CNode::copyStats(CNodeStats &stats)
 }
 #undef X
 
-void Release(CNode* node) {
-    node->Release();
-}
-
-
-
-
 
 void ThreadSocketHandler(void* parg)
 {
@@ -1143,7 +1136,8 @@ void ThreadSocketHandler2(void* parg)
         }
         {
             LOCK(cs_vNodes);
-            for_each(vNodesCopy.begin(), vNodesCopy.end(), Release);
+            for(CNode* pnode :  vNodesCopy)
+                pnode->Release();
         }
 
         Sleep(10);
@@ -1716,7 +1710,8 @@ void ThreadMessageHandler2(void* parg)
 
         {
             LOCK(cs_vNodes);
-            for_each(vNodesCopy.begin(), vNodesCopy.end(), Release);
+            for(CNode* pnode :  vNodesCopy)
+                pnode->Release();
         }
 
         // Wait and allow messages to bunch up.
index ebc5f9f..79c5b2a 100644 (file)
@@ -25,7 +25,7 @@ using namespace std;
 
 // Settings
 static proxyType proxyInfo[NET_MAX];
-static proxyType nameproxyInfo;
+static CService nameProxy;
 static CCriticalSection cs_proxyInfos;
 int nConnectTimeout = 5000;
 bool fNameLookup = false;
@@ -179,50 +179,6 @@ bool LookupNumeric(const char *pszName, CService& addr, uint16_t portDefault)
     return Lookup(pszName, addr, portDefault, false);
 }
 
-bool static Socks4(const CService &addrDest, SOCKET& hSocket)
-{
-    printf("SOCKS4 connecting %s\n", addrDest.ToString().c_str());
-    if (!addrDest.IsIPv4())
-    {
-        CloseSocket(hSocket);
-        return error("Proxy destination is not IPv4");
-    }
-    char pszSocks4IP[] = "\4\1\0\0\0\0\0\0user";
-    struct sockaddr_in addr;
-    socklen_t len = sizeof(addr);
-    if (!addrDest.GetSockAddr((struct sockaddr*)&addr, &len) || addr.sin_family != AF_INET)
-    {
-        CloseSocket(hSocket);
-        return error("Cannot get proxy destination address");
-    }
-    memcpy(pszSocks4IP + 2, &addr.sin_port, 2);
-    memcpy(pszSocks4IP + 4, &addr.sin_addr, 4);
-    char* pszSocks4 = pszSocks4IP;
-    int nSize = sizeof(pszSocks4IP);
-
-    int ret = send(hSocket, pszSocks4, nSize, MSG_NOSIGNAL);
-    if (ret != nSize)
-    {
-        CloseSocket(hSocket);
-        return error("Error sending to proxy");
-    }
-    char pchRet[8];
-    if (recv(hSocket, pchRet, 8, 0) != 8)
-    {
-        CloseSocket(hSocket);
-        return error("Error reading proxy response");
-    }
-    if (pchRet[1] != 0x5a)
-    {
-        CloseSocket(hSocket);
-        if (pchRet[1] != 0x5b)
-            printf("ERROR: Proxy returned error %d\n", pchRet[1]);
-        return false;
-    }
-    printf("SOCKS4 connected %s\n", addrDest.ToString().c_str());
-    return true;
-}
-
 bool static Socks5(string strDest, uint16_t port, SOCKET& hSocket)
 {
     printf("SOCKS5 connecting %s\n", strDest.c_str());
@@ -435,53 +391,49 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
     return true;
 }
 
-bool SetProxy(enum Network net, CService addrProxy, int nSocksVersion) {
+bool SetProxy(enum Network net, CService addrProxy) {
     assert(net >= 0 && net < NET_MAX);
-    if (nSocksVersion != 0 && nSocksVersion != 4 && nSocksVersion != 5)
-        return false;
-    if (nSocksVersion != 0 && !addrProxy.IsValid())
+    if (!addrProxy.IsValid())
         return false;
     LOCK(cs_proxyInfos);
-    proxyInfo[net] = std::make_pair(addrProxy, nSocksVersion);
+    proxyInfo[net] = addrProxy;
     return true;
 }
 
 bool GetProxy(enum Network net, proxyType &proxyInfoOut) {
     assert(net >= 0 && net < NET_MAX);
     LOCK(cs_proxyInfos);
-    if (!proxyInfo[net].second)
+    if (!proxyInfo[net].IsValid())
         return false;
     proxyInfoOut = proxyInfo[net];
     return true;
 }
 
-bool SetNameProxy(CService addrProxy, int nSocksVersion) {
-    if (nSocksVersion != 0 && nSocksVersion != 5)
-        return false;
-    if (nSocksVersion != 0 && !addrProxy.IsValid())
+bool SetNameProxy(CService addrProxy) {
+    if (!addrProxy.IsValid())
         return false;
     LOCK(cs_proxyInfos);
-    nameproxyInfo = std::make_pair(addrProxy, nSocksVersion);
+    nameProxy = addrProxy;
     return true;
 }
 
-bool GetNameProxy(proxyType &nameproxyInfoOut) {
+bool GetNameProxy(CService &nameProxyOut) {
     LOCK(cs_proxyInfos);
-    if (!nameproxyInfo.second)
+    if (!nameProxy.IsValid())
         return false;
-    nameproxyInfoOut = nameproxyInfo;
+    nameProxyOut = nameProxy;
     return true;
 }
 
 bool HaveNameProxy() {
     LOCK(cs_proxyInfos);
-    return nameproxyInfo.second != 0;
+    return nameProxy.IsValid();
 }
 
 bool IsProxy(const CNetAddr &addr) {
     LOCK(cs_proxyInfos);
     for (int i = 0; i < NET_MAX; i++) {
-        if (proxyInfo[i].second && (addr == (CNetAddr)proxyInfo[i].first))
+        if (addr == (CNetAddr)proxyInfo[i])
             return true;
     }
     return false;
@@ -498,23 +450,12 @@ bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
     SOCKET hSocket = INVALID_SOCKET;
 
     // first connect to proxy server
-    if (!ConnectSocketDirectly(proxy.first, hSocket, nTimeout))
+    if (!ConnectSocketDirectly(proxy, hSocket, nTimeout))
         return false;
 
     // do socks negotiation
-    switch (proxy.second) {
-    case 4:
-        if (!Socks4(addrDest, hSocket))
-            return false;
-        break;
-    case 5:
-        if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket))
-            return false;
-        break;
-    default:
-        CloseSocket(hSocket);
+    if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket))
         return false;
-    }
 
     hSocketRet = hSocket;
     return true;
@@ -528,30 +469,23 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest
 
     SOCKET hSocket = INVALID_SOCKET;
 
-    proxyType nameproxy;
-    GetNameProxy(nameproxy);
+    CService nameProxy;
+    GetNameProxy(nameProxy);
 
-    CService addrResolved(CNetAddr(strDest, fNameLookup && !nameproxy.second), port);
+    CService addrResolved(CNetAddr(strDest, fNameLookup && !HaveNameProxy()), port);
     if (addrResolved.IsValid()) {
         addr = addrResolved;
         return ConnectSocket(addr, hSocketRet, nTimeout);
     }
     addr = CService("0.0.0.0:0");
-    if (!nameproxy.second)
+    if (!HaveNameProxy)
         return false;
-    if (!ConnectSocketDirectly(nameproxy.first, hSocket, nTimeout))
+    // first connect to name proxy server
+    if (!ConnectSocketDirectly(nameProxy, hSocket, nTimeout))
+        return false;
+    // do socks negotiation
+    if (!Socks5(strDest, port, hSocket))
         return false;
-
-    switch(nameproxy.second) {
-        default:
-        case 4:
-            CloseSocket(hSocket);
-            return false;
-        case 5:
-            if (!Socks5(strDest, port, hSocket))
-                return false;
-            break;
-    }
 
     hSocketRet = hSocket;
     return true;
index 14c632e..e6f3e6d 100644 (file)
@@ -126,14 +126,14 @@ class CService : public CNetAddr
             )
 };
 
-typedef std::pair<CService, int> proxyType;
+typedef CService proxyType;
 
 enum Network ParseNetwork(std::string net);
 void SplitHostPort(std::string in, uint16_t &portOut, std::string &hostOut);
-bool SetProxy(enum Network net, CService addrProxy, int nSocksVersion = 5);
+bool SetProxy(enum Network net, CService addrProxy);
 bool GetProxy(enum Network net, proxyType &proxyInfoOut);
 bool IsProxy(const CNetAddr &addr);
-bool SetNameProxy(CService addrProxy, int nSocksVersion = 5);
+bool SetNameProxy(CService addrProxy);
 bool HaveNameProxy();
 bool LookupHost(const std::string& strName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0, bool fAllowLookup = true);
 bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0, bool fAllowLookup = true);
index 9460657..16cdf3a 100644 (file)
@@ -339,9 +339,9 @@ void AddressBookPage::exportClicked()
     }
 }
 
+#ifdef USE_QRCODE
 void AddressBookPage::on_showQRCode_clicked()
 {
- #ifdef USE_QRCODE
     QTableView *table = ui->tableView;
     QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
 
@@ -355,8 +355,8 @@ void AddressBookPage::on_showQRCode_clicked()
         dialog->setAttribute(Qt::WA_DeleteOnClose);
         dialog->show();
     }
-#endif
 }
+#endif
 
 void AddressBookPage::contextualMenu(const QPoint &point)
 {
index df87486..87ad27b 100644 (file)
@@ -65,7 +65,9 @@ private slots:
     void on_signMessage_clicked();
     void on_verifyMessage_clicked();
     void selectionChanged();
+#ifdef USE_QRCODE
     void on_showQRCode_clicked();
+#endif
     /** Spawn contextual menu (right mouse menu) for address book entry */
     void contextualMenu(const QPoint &point);
 
index 7cf60cf..d843ffe 100644 (file)
           </widget>
          </item>
          <item>
-          <widget class="QLabel" name="socksVersionLabel">
-           <property name="text">
-            <string>SOCKS &amp;Version:</string>
-           </property>
-           <property name="textFormat">
-            <enum>Qt::PlainText</enum>
-           </property>
-           <property name="buddy">
-            <cstring>socksVersion</cstring>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QValueComboBox" name="socksVersion">
-           <property name="toolTip">
-            <string>SOCKS version of the proxy (e.g. 5)</string>
-           </property>
-          </widget>
-         </item>
-         <item>
           <spacer name="horizontalSpacer_Network">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
index 6f0851c..3f4c93f 100644 (file)
@@ -190,7 +190,7 @@ void MultisigDialog::on_createAddressButton_clicked()
         QMessageBox::warning(this, tr("Error"), tr("Redeem script exceeds size limit: %1 > %2\nReduce the number of addresses involved in the address creation.").arg(script.size()).arg(MAX_SCRIPT_ELEMENT_SIZE), QMessageBox::Ok);
         return;
     }
-    CScriptID scriptID = script.GetID();
+    CScriptID scriptID(script);
     CBitcoinAddress address(scriptID);
 
     ui->multisigAddress->setText(address.ToString().c_str());
@@ -216,7 +216,7 @@ void MultisigDialog::on_saveRedeemScriptButton_clicked()
     std::string redeemScript = ui->redeemScript->text().toStdString();
     std::vector<unsigned char> scriptData(ParseHex(redeemScript));
     CScript script(scriptData.begin(), scriptData.end());
-    CScriptID scriptID = script.GetID();
+    CScriptID scriptID(script);
 
     LOCK(wallet->cs_wallet);
     if(!wallet->HaveCScript(scriptID))
@@ -238,7 +238,7 @@ void MultisigDialog::on_saveMultisigAddressButton_clicked()
 
     std::vector<unsigned char> scriptData(ParseHex(redeemScript));
     CScript script(scriptData.begin(), scriptData.end());
-    CScriptID scriptID = script.GetID();
+    CScriptID scriptID(script);
 
     LOCK(wallet->cs_wallet);
     if(!wallet->HaveCScript(scriptID))
index adb6ffb..dc3122a 100644 (file)
@@ -47,14 +47,8 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
     ui->TorOnly->setEnabled(false);
     ui->torName->setEnabled(false);
 
-    ui->socksVersion->setEnabled(false);
-    ui->socksVersion->addItem("5", 5);
-    ui->socksVersion->addItem("4", 4);
-    ui->socksVersion->setCurrentIndex(0);
-
     connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool)));
     connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool)));
-    connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->socksVersion, SLOT(setEnabled(bool)));
     connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning_Proxy()));
 
     connect(ui->connectTor, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning_Tor()));
@@ -164,7 +158,6 @@ void OptionsDialog::setMapper()
     mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse);
     mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP);
     mapper->addMapping(ui->proxyPort, OptionsModel::ProxyPort);
-    mapper->addMapping(ui->socksVersion, OptionsModel::ProxySocksVersion);
 
     mapper->addMapping(ui->connectTor, OptionsModel::TorUse);
     mapper->addMapping(ui->torIp, OptionsModel::TorIP);
index 80fc84f..7e80615 100644 (file)
@@ -16,25 +16,21 @@ bool static ApplyProxySettings()
 {
     QSettings settings;
     CService addrProxy(settings.value("addrProxy", "127.0.0.1:9050").toString().toStdString());
-    int nSocksVersion(settings.value("nSocksVersion", 5).toInt());
     if (!settings.value("fUseProxy", false).toBool()) {
         addrProxy = CService();
-        nSocksVersion = 0;
         return false;
     }
-    if (nSocksVersion && !addrProxy.IsValid())
+    if (!addrProxy.IsValid())
         return false;
 
     if (!IsLimited(NET_IPV4))
-        SetProxy(NET_IPV4, addrProxy, nSocksVersion);
-    if (nSocksVersion > 4) {
+        SetProxy(NET_IPV4, addrProxy);
 #ifdef USE_IPV6
         if (!IsLimited(NET_IPV6))
-            SetProxy(NET_IPV6, addrProxy, nSocksVersion);
+            SetProxy(NET_IPV6, addrProxy);
 #endif
-    }
 
-    SetNameProxy(addrProxy, nSocksVersion);
+    SetNameProxy(addrProxy);
 
     return true;
 }
@@ -50,7 +46,7 @@ bool static ApplyTorSettings()
     if (!addrTor.IsValid())
         return false;
 
-    SetProxy(NET_TOR, addrTor, 5);
+    SetProxy(NET_TOR, addrTor);
     SetReachable(NET_TOR);
 
     return true;
@@ -132,32 +128,30 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
         case ProxyIP: {
             proxyType proxy;
             if (GetProxy(NET_IPV4, proxy))
-                return QVariant(QString::fromStdString(proxy.first.ToStringIP()));
+                return QVariant(QString::fromStdString(proxy.ToStringIP()));
             else
                 return QVariant(QString::fromStdString("127.0.0.1"));
         }
         case ProxyPort: {
             proxyType proxy;
             if (GetProxy(NET_IPV4, proxy))
-                return QVariant(proxy.first.GetPort());
+                return QVariant(proxy.GetPort());
             else
                 return QVariant(nSocksDefault);
         }
-        case ProxySocksVersion:
-            return settings.value("nSocksVersion", 5);
         case TorUse:
             return settings.value("fUseTor", false);
         case TorIP: {
             proxyType proxy;
             if (GetProxy(NET_TOR, proxy))
-                return QVariant(QString::fromStdString(proxy.first.ToStringIP()));
+                return QVariant(QString::fromStdString(proxy.ToStringIP()));
             else
                 return QVariant(QString::fromStdString("127.0.0.1"));
         }
         case TorPort: {
             proxyType proxy;
             if (GetProxy(NET_TOR, proxy))
-                return QVariant(proxy.first.GetPort());
+                return QVariant(proxy.GetPort());
             else
                 return QVariant(nSocksDefault);
         }
@@ -213,32 +207,22 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
             break;
         case ProxyIP: {
             proxyType proxy;
-            proxy.first = CService("127.0.0.1", nSocksDefault);
+            proxy = CService("127.0.0.1", nSocksDefault);
             GetProxy(NET_IPV4, proxy);
 
             CNetAddr addr(value.toString().toStdString());
-            proxy.first.SetIP(addr);
-            settings.setValue("addrProxy", proxy.first.ToStringIPPort().c_str());
+            proxy.SetIP(addr);
+            settings.setValue("addrProxy", proxy.ToStringIPPort().c_str());
             successful = ApplyProxySettings();
         }
         break;
         case ProxyPort: {
             proxyType proxy;
-            proxy.first = CService("127.0.0.1", nSocksDefault);
-            GetProxy(NET_IPV4, proxy);
-
-            proxy.first.SetupPort(value.toInt());
-            settings.setValue("addrProxy", proxy.first.ToStringIPPort().c_str());
-            successful = ApplyProxySettings();
-        }
-        break;
-        case ProxySocksVersion: {
-            proxyType proxy;
-            proxy.second = 5;
+            proxy = CService("127.0.0.1", nSocksDefault);
             GetProxy(NET_IPV4, proxy);
 
-            proxy.second = value.toInt();
-            settings.setValue("nSocksVersion", proxy.second);
+            proxy.SetupPort(value.toInt());
+            settings.setValue("addrProxy", proxy.ToStringIPPort().c_str());
             successful = ApplyProxySettings();
         }
         break;
@@ -249,22 +233,22 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
         break;
         case TorIP: {
             proxyType proxy;
-            proxy.first = CService("127.0.0.1", nSocksDefault);
+            proxy = CService("127.0.0.1", nSocksDefault);
             GetProxy(NET_TOR, proxy);
 
             CNetAddr addr(value.toString().toStdString());
-            proxy.first.SetIP(addr);
-            settings.setValue("addrTor", proxy.first.ToStringIPPort().c_str());
+            proxy.SetIP(addr);
+            settings.setValue("addrTor", proxy.ToStringIPPort().c_str());
             successful = ApplyTorSettings();
         }
         break;
         case TorPort: {
             proxyType proxy;
-            proxy.first = CService("127.0.0.1", nSocksDefault);
+            proxy = CService("127.0.0.1", nSocksDefault);
             GetProxy(NET_TOR, proxy);
 
-            proxy.first.SetupPort((uint16_t)value.toUInt());
-            settings.setValue("addrTor", proxy.first.ToStringIPPort().c_str());
+            proxy.SetupPort((uint16_t)value.toUInt());
+            settings.setValue("addrTor", proxy.ToStringIPPort().c_str());
             successful = ApplyTorSettings();
         }
         break;
index 9092655..03b13be 100644 (file)
@@ -29,7 +29,7 @@ Value getsubsidy(const Array& params, bool fHelp)
 
     if (params.size() != 0)
     {
-        CBigNum bnTarget(uint256(params[0].get_str()));
+        uint256 bnTarget(params[0].get_str());
         nBits = bnTarget.GetCompact();
     }
     else
@@ -104,7 +104,7 @@ Value scaninput(const Array& params, bool fHelp)
         if (dDiff <= 0)
             throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, diff must be greater than zero");
 
-        CBigNum bnTarget(nPoWBase);
+        uint256 bnTarget(nPoWBase);
         bnTarget *= 1000;
         bnTarget /= (int) (dDiff * 1000);
         nBits = bnTarget.GetCompact();
@@ -292,13 +292,13 @@ Value getworkex(const Array& params, bool fHelp)
         char phash1[64];
         FormatHashBuffers(pblock, pmidstate, pdata, phash1);
 
-        auto hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
+        auto hashTarget = uint256().SetCompact(pblock->nBits);
 
         auto coinbaseTx = pblock->vtx[0];
         auto merkle = pblock->GetMerkleBranch(0);
 
         Object result;
-        result.push_back(Pair("data",     HexStr(BEGIN(pdata), END(pdata))));
+        result.push_back(Pair("data",     HexStr(begin(pdata), end(pdata))));
         result.push_back(Pair("target",   HexStr(hashTarget.begin(), hashTarget.end())));
 
         CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
@@ -431,12 +431,12 @@ Value getwork(const Array& params, bool fHelp)
         char phash1[64];
         FormatHashBuffers(pblock, pmidstate, pdata, phash1);
 
-        auto hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
+        auto hashTarget = uint256().SetCompact(pblock->nBits);
 
         Object result;
-        result.push_back(Pair("midstate", HexStr(BEGIN(pmidstate), END(pmidstate)))); // deprecated
-        result.push_back(Pair("data",     HexStr(BEGIN(pdata), END(pdata))));
-        result.push_back(Pair("hash1",    HexStr(BEGIN(phash1), END(phash1)))); // deprecated
+        result.push_back(Pair("midstate", HexStr(begin(pmidstate), end(pmidstate)))); // deprecated
+        result.push_back(Pair("data",     HexStr(begin(pdata), end(pdata))));
+        result.push_back(Pair("hash1",    HexStr(begin(phash1), end(phash1)))); // deprecated
         result.push_back(Pair("target",   HexStr(hashTarget.begin(), hashTarget.end())));
         return result;
     }
@@ -595,7 +595,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
     Object aux;
     aux.push_back(Pair("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end())));
 
-    auto hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
+    auto hashTarget = uint256().SetCompact(pblock->nBits);
 
     static Array aMutable;
     if (aMutable.empty())
index b3b3c31..3359338 100644 (file)
@@ -368,7 +368,7 @@ Value decodescript(const Array& params, bool fHelp)
     }
     ScriptPubKeyToJSON(script, r, false);
 
-    r.push_back(Pair("p2sh", CBitcoinAddress(script.GetID()).ToString()));
+    r.push_back(Pair("p2sh", CBitcoinAddress(CScriptID(script)).ToString()));
     return r;
 }
 
@@ -690,7 +690,7 @@ Value createmultisig(const Array& params, bool fHelp)
         throw runtime_error(
             strprintf("redeemScript exceeds size limit: %" PRIszu " > %d", inner.size(), MAX_SCRIPT_ELEMENT_SIZE));
 
-    auto innerID = inner.GetID();
+    auto innerID = CScriptID(inner);
     CBitcoinAddress address(innerID);
 
     Object result;
index ef9276c..8f82c97 100644 (file)
@@ -95,7 +95,7 @@ Value getinfo(const Array& params, bool fHelp)
 
     obj.push_back(Pair("moneysupply",   ValueFromAmount(pindexBest->nMoneySupply)));
     obj.push_back(Pair("connections",   (int)vNodes.size()));
-    obj.push_back(Pair("proxy",         (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string())));
+    obj.push_back(Pair("proxy",         (proxy.IsValid() ? proxy.ToStringIPPort() : string())));
     obj.push_back(Pair("ip",            addrSeenByPeer.ToStringIP()));
 
     diff.push_back(Pair("proof-of-work",  GetDifficulty()));
@@ -889,7 +889,7 @@ Value addmultisigaddress(const Array& params, bool fHelp)
         strprintf("redeemScript exceeds size limit: %" PRIszu " > %d", inner.size(), MAX_SCRIPT_ELEMENT_SIZE));
 
     pwalletMain->AddCScript(inner);
-    CBitcoinAddress address(inner.GetID());
+    CBitcoinAddress address{ CScriptID(inner) }; // "most vexing parse"
 
     pwalletMain->SetAddressBookName(address, strAccount);
     return address.ToString();
@@ -913,7 +913,7 @@ Value addredeemscript(const Array& params, bool fHelp)
     auto innerData = ParseHexV(params[0], "redeemScript");
     CScript inner(innerData.begin(), innerData.end());
     pwalletMain->AddCScript(inner);
-    CBitcoinAddress address(inner.GetID());
+    CBitcoinAddress address{ CScriptID(inner) }; // "most vexing parse"
 
     pwalletMain->SetAddressBookName(address, strAccount);
     return address.ToString();
index b18d4fe..c4f8d3b 100644 (file)
@@ -1710,7 +1710,11 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet)
 
     if (whichType == TX_PUBKEY)
     {
-        addressRet = CPubKey(vSolutions[0]).GetID();
+        CPubKey pubKey(vSolutions[0]);
+        if (!pubKey.IsValid())
+            return false;
+
+        addressRet = pubKey.GetID();
         return true;
     }
     else if (whichType == TX_PUBKEYHASH)
@@ -1819,9 +1823,16 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto
         nRequiredRet = vSolutions.front()[0];
         for (unsigned int i = 1; i < vSolutions.size()-1; i++)
         {
-            CTxDestination address = CPubKey(vSolutions[i]).GetID();
+            CPubKey pubKey(vSolutions[i]);
+            if (!pubKey.IsValid())
+                continue;
+
+            CTxDestination address = pubKey.GetID();
             addressRet.push_back(address);
         }
+
+        if (addressRet.empty())
+            return false;
     }
     else
     {
@@ -2478,8 +2489,3 @@ void CScript::print() const
 {
     printf("%s\n", ToString().c_str());
 }
-
-CScriptID CScript::GetID() const
-{
-    return CScriptID(Hash160(*this));
-}
index 28def01..17e3d36 100644 (file)
@@ -375,7 +375,6 @@ public:
     void PrintHex() const;
     std::string ToString(bool fShort=false) const;
     void print() const;
-    CScriptID GetID() const;
 };
 
 bool IsCanonicalPubKey(const std::vector<unsigned char> &vchPubKey, unsigned int flags);
index ddff706..c0471bb 100644 (file)
@@ -103,8 +103,6 @@ enum
 
 
 
-
-
 //
 // Basic types
 //
@@ -160,8 +158,6 @@ template<typename Stream> inline void Unserialize(Stream& s, bool& a, int, int=0
 
 
 
-
-
 //
 // Compact size
 //  size <  253          -- 1 byte
@@ -349,11 +345,6 @@ template<typename T0, typename T1, typename T2> unsigned int GetSerializeSize(co
 template<typename Stream, typename T0, typename T1, typename T2> void Serialize(Stream& os, const std::tuple<T0, T1, T2>& item, int nType, int nVersion);
 template<typename Stream, typename T0, typename T1, typename T2> void Unserialize(Stream& is, std::tuple<T0, T1, T2>& item, int nType, int nVersion);
 
-// 4 tuple
-template<typename T0, typename T1, typename T2, typename T3> unsigned int GetSerializeSize(const std::tuple<T0, T1, T2, T3>& item, int nType, int nVersion);
-template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Serialize(Stream& os, const std::tuple<T0, T1, T2, T3>& item, int nType, int nVersion);
-template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Unserialize(Stream& is, std::tuple<T0, T1, T2, T3>& item, int nType, int nVersion);
-
 // map
 template<typename K, typename T, typename Pred, typename A> unsigned int GetSerializeSize(const std::map<K, T, Pred, A>& m, int nType, int nVersion);
 template<typename Stream, typename K, typename T, typename Pred, typename A> void Serialize(Stream& os, const std::map<K, T, Pred, A>& m, int nType, int nVersion);
@@ -367,7 +358,6 @@ template<typename Stream, typename K, typename Pred, typename A> void Unserializ
 
 
 
-
 //
 // If none of the specialized versions above matched, default to calling member function.
 // "int nType" is changed to "long nType" to keep from getting an ambiguous overload error.
@@ -395,7 +385,6 @@ inline void Unserialize(Stream& is, T& a, long nType, int nVersion)
 
 
 
-
 //
 // string
 //
@@ -593,40 +582,6 @@ void Unserialize(Stream& is, std::tuple<T0, T1, T2>& item, int nType, int nVersi
 
 
 //
-// 4 tuple
-//
-template<typename T0, typename T1, typename T2, typename T3>
-unsigned int GetSerializeSize(const std::tuple<T0, T1, T2, T3>& item, int nType, int nVersion)
-{
-    unsigned int nSize = 0;
-    nSize += GetSerializeSize(std::get<0>(item), nType, nVersion);
-    nSize += GetSerializeSize(std::get<1>(item), nType, nVersion);
-    nSize += GetSerializeSize(std::get<2>(item), nType, nVersion);
-    nSize += GetSerializeSize(std::get<3>(item), nType, nVersion);
-    return nSize;
-}
-
-template<typename Stream, typename T0, typename T1, typename T2, typename T3>
-void Serialize(Stream& os, const std::tuple<T0, T1, T2, T3>& item, int nType, int nVersion)
-{
-    Serialize(os, std::get<0>(item), nType, nVersion);
-    Serialize(os, std::get<1>(item), nType, nVersion);
-    Serialize(os, std::get<2>(item), nType, nVersion);
-    Serialize(os, std::get<3>(item), nType, nVersion);
-}
-
-template<typename Stream, typename T0, typename T1, typename T2, typename T3>
-void Unserialize(Stream& is, std::tuple<T0, T1, T2, T3>& item, int nType, int nVersion)
-{
-    Unserialize(is, std::get<0>(item), nType, nVersion);
-    Unserialize(is, std::get<1>(item), nType, nVersion);
-    Unserialize(is, std::get<2>(item), nType, nVersion);
-    Unserialize(is, std::get<3>(item), nType, nVersion);
-}
-
-
-
-//
 // map
 //
 template<typename K, typename T, typename Pred, typename A>
@@ -734,13 +689,6 @@ struct ser_streamplaceholder
 
 
 
-
-
-
-
-
-
-
 typedef std::vector<char, zero_after_free_allocator<char> > CSerializeData;
 
 /** Double ended buffer combining vector and stream-like interfaces.
index 57382bd..218a429 100644 (file)
@@ -3,4 +3,6 @@
 
 static const unsigned int TARGETS_SWITCH_TIME = 1374278400; // Saturday, 20-Jul-2013 00:00:00 UTC
 static const unsigned int CHECKLOCKTIMEVERIFY_SWITCH_TIME = 1461110400; // Wednesday, 20-Apr-16 00:00:00 UTC
+// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
+static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov  5 00:53:20 1985 UTC
 #endif
index 9baa959..c90b374 100644 (file)
@@ -229,7 +229,7 @@ bool CWallet::LoadCScript(const CScript& redeemScript)
      * these. Do not add them to the wallet and warn. */
     if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)
     {
-        auto strAddr = CBitcoinAddress(redeemScript.GetID()).ToString();
+        auto strAddr = CBitcoinAddress(CScriptID(redeemScript)).ToString();
         printf("LoadCScript() : Warning: This wallet contains a redeemScript of size %" PRIszu " which exceeds maximum size %i thus can never be redeemed. Do not use address %s.\n",
           redeemScript.size(), MAX_SCRIPT_ELEMENT_SIZE, strAddr.c_str());
           return true;