BN_zero -> BN_set_word
[novacoin.git] / src / wallet.cpp
index 044f3e2..f94240b 100644 (file)
@@ -13,7 +13,7 @@
 #include "coincontrol.h"
 #include <boost/algorithm/string/replace.hpp>
 #include <openssl/bio.h>
-
+#include <random>
 #include "main.h"
 
 using namespace std;
@@ -526,19 +526,6 @@ bool CWallet::DecryptWallet(const SecureString& strWalletPassphrase)
     return true;
 }
 
-bool CWallet::GetPEM(const CKeyID &keyID, const std::string &fileName, const SecureString &strPassKey) const
-{
-    BIO *pemOut = BIO_new_file(fileName.c_str(), "w");
-    if (pemOut == NULL)
-        return error("GetPEM() : failed to create file %s\n", fileName.c_str());
-    CKey key;
-    if (!GetKey(keyID, key))
-        return error("GetPEM() : failed to get key for address=%s\n", CBitcoinAddress(keyID).ToString().c_str());
-    bool result = key.WritePEM(pemOut, strPassKey);
-    BIO_free(pemOut);
-    return result;
-}
-
 int64_t CWallet::IncOrderPosNext(CWalletDB *pwalletdb)
 {
     int64_t nRet = nOrderPosNext++;
@@ -1829,7 +1816,9 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime,
     vector<pair<int64_t, pair<const CWalletTx*,unsigned int> > > vValue;
     int64_t nTotalLower = 0;
 
-    random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt);
+    std::random_device rd;
+    std::mt19937 g(rd());
+    shuffle(vCoins.begin(), vCoins.end(), g);
 
     BOOST_FOREACH(const COutput &output, vCoins)
     {
@@ -1888,7 +1877,8 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime,
     }
 
     // Solve subset sum by stochastic approximation
-    sort(vValue.rbegin(), vValue.rend(), CompareValueOnly());
+    std::sort(vValue.begin(), vValue.end(), CompareValueOnly());
+    std::reverse(vValue.begin(), vValue.end());
     vector<char> vfBest;
     int64_t nBest;
 
@@ -2909,7 +2899,7 @@ set< set<CBitcoinAddress> > CWallet::GetAddressGroupings()
                     CBitcoinAddress txoutAddr;
                     if(!ExtractAddress(*this, txout.scriptPubKey, txoutAddr))
                         continue;
-                        grouping.insert(txoutAddr);
+                    grouping.insert(txoutAddr);
                 }
             }
             if (!grouping.empty())