aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/init.cpp18
-rw-r--r--src/test/test_bitcoin.cpp2
-rw-r--r--src/ui_interface.cpp24
-rw-r--r--src/ui_interface.h8
-rw-r--r--src/wallet/wallet.cpp61
6 files changed, 56 insertions, 58 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 24744835f5..c1912dafc5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -204,6 +204,7 @@ libbitcoin_server_a_SOURCES = \
torcontrol.cpp \
txdb.cpp \
txmempool.cpp \
+ ui_interface.cpp \
validationinterface.cpp \
versionbits.cpp \
$(BITCOIN_CORE_H)
diff --git a/src/init.cpp b/src/init.cpp
index 3667820a21..038b28cc3a 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -94,7 +94,6 @@ enum BindFlags {
};
static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
-CClientUIInterface uiInterface; // Declared but not defined in ui_interface.h
//////////////////////////////////////////////////////////////////////////////
//
@@ -266,18 +265,6 @@ void HandleSIGHUP(int)
fReopenDebugLog = true;
}
-bool static InitError(const std::string &str)
-{
- uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
- return false;
-}
-
-bool static InitWarning(const std::string &str)
-{
- uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
- return true;
-}
-
bool static Bind(const CService &addr, unsigned int flags) {
if (!(flags & BF_EXPLICIT) && IsLimited(addr))
return false;
@@ -742,11 +729,6 @@ static std::string ResolveErrMsg(const char * const optname, const std::string&
return strprintf(_("Cannot resolve -%s address: '%s'"), optname, strBind);
}
-static std::string AmountErrMsg(const char * const optname, const std::string& strValue)
-{
- return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);
-}
-
void InitLogging()
{
fPrintToConsole = GetBoolArg("-printtoconsole", false);
diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp
index eb8ac01e8d..9bcb07626a 100644
--- a/src/test/test_bitcoin.cpp
+++ b/src/test/test_bitcoin.cpp
@@ -26,8 +26,6 @@
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
-CClientUIInterface uiInterface; // Declared but not defined in ui_interface.h
-
extern bool fPrintToConsole;
extern void noui_connect();
diff --git a/src/ui_interface.cpp b/src/ui_interface.cpp
new file mode 100644
index 0000000000..c778e40a90
--- /dev/null
+++ b/src/ui_interface.cpp
@@ -0,0 +1,24 @@
+// Copyright (c) 2010-2016 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include "ui_interface.h"
+#include "util.h"
+
+CClientUIInterface uiInterface;
+
+bool InitError(const std::string& str)
+{
+ uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
+ return false;
+}
+
+void InitWarning(const std::string& str)
+{
+ uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
+}
+
+std::string AmountErrMsg(const char* const optname, const std::string& strValue)
+{
+ return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);
+}
diff --git a/src/ui_interface.h b/src/ui_interface.h
index 0b51d52e65..a27918c507 100644
--- a/src/ui_interface.h
+++ b/src/ui_interface.h
@@ -100,6 +100,14 @@ public:
boost::signals2::signal<void (void)> BannedListChanged;
};
+/** Show warning message **/
+void InitWarning(const std::string& str);
+
+/** Show error message **/
+bool InitError(const std::string& str);
+
+std::string AmountErrMsg(const char* const optname, const std::string& strValue);
+
extern CClientUIInterface uiInterface;
#endif // BITCOIN_UI_INTERFACE_H
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 8161c659ab..955a0a3d60 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -23,6 +23,7 @@
#include "timedata.h"
#include "txmempool.h"
#include "util.h"
+#include "ui_interface.h"
#include "utilmoneystr.h"
#include <assert.h>
@@ -365,22 +366,6 @@ void CWallet::Flush(bool shutdown)
bitdb.Flush(shutdown);
}
-bool static UIError(const std::string &str)
-{
- uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
- return false;
-}
-
-void static UIWarning(const std::string &str)
-{
- uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
-}
-
-static std::string AmountErrMsg(const char * const optname, const std::string& strValue)
-{
- return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);
-}
-
bool CWallet::Verify()
{
std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
@@ -390,7 +375,7 @@ bool CWallet::Verify()
// Wallet file must be a plain filename without a directory
if (walletFile != boost::filesystem::basename(walletFile) + boost::filesystem::extension(walletFile))
- return UIError(strprintf(_("Wallet %s resides outside data directory %s"), walletFile, GetDataDir().string()));
+ return InitError(strprintf(_("Wallet %s resides outside data directory %s"), walletFile, GetDataDir().string()));
if (!bitdb.Open(GetDataDir()))
{
@@ -407,7 +392,7 @@ bool CWallet::Verify()
// try again
if (!bitdb.Open(GetDataDir())) {
// if it still fails, it probably means we can't even create the database env
- return UIError(strprintf(_("Error initializing wallet database environment %s!"), GetDataDir()));
+ return InitError(strprintf(_("Error initializing wallet database environment %s!"), GetDataDir()));
}
}
@@ -423,14 +408,14 @@ bool CWallet::Verify()
CDBEnv::VerifyResult r = bitdb.Verify(walletFile, CWalletDB::Recover);
if (r == CDBEnv::RECOVER_OK)
{
- UIWarning(strprintf(_("Warning: Wallet file corrupt, data salvaged!"
+ InitWarning(strprintf(_("Warning: Wallet file corrupt, data salvaged!"
" Original %s saved as %s in %s; if"
" your balance or transactions are incorrect you should"
" restore from a backup."),
walletFile, "wallet.{timestamp}.bak", GetDataDir()));
}
if (r == CDBEnv::RECOVER_FAIL)
- return UIError(strprintf(_("%s corrupt, salvage failed"), walletFile));
+ return InitError(strprintf(_("%s corrupt, salvage failed"), walletFile));
}
return true;
@@ -3075,7 +3060,7 @@ bool CWallet::InitLoadWallet()
CWallet *tempWallet = new CWallet(walletFile);
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
if (nZapWalletRet != DB_LOAD_OK) {
- return UIError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
+ return InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
}
delete tempWallet;
@@ -3091,22 +3076,22 @@ bool CWallet::InitLoadWallet()
if (nLoadWalletRet != DB_LOAD_OK)
{
if (nLoadWalletRet == DB_CORRUPT)
- return UIError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
+ return InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
else if (nLoadWalletRet == DB_NONCRITICAL_ERROR)
{
- UIWarning(strprintf(_("Error reading %s! All keys read correctly, but transaction data"
+ InitWarning(strprintf(_("Error reading %s! All keys read correctly, but transaction data"
" or address book entries might be missing or incorrect."),
walletFile));
}
else if (nLoadWalletRet == DB_TOO_NEW)
- return UIError(strprintf(_("Error loading %s: Wallet requires newer version of %s"),
+ return InitError(strprintf(_("Error loading %s: Wallet requires newer version of %s"),
walletFile, _(PACKAGE_NAME)));
else if (nLoadWalletRet == DB_NEED_REWRITE)
{
- return UIError(strprintf(_("Wallet needed to be rewritten: restart %s to complete"), _(PACKAGE_NAME)));
+ return InitError(strprintf(_("Wallet needed to be rewritten: restart %s to complete"), _(PACKAGE_NAME)));
}
else
- return UIError(strprintf(_("Error loading %s"), walletFile));
+ return InitError(strprintf(_("Error loading %s"), walletFile));
}
if (GetBoolArg("-upgradewallet", fFirstRun))
@@ -3122,7 +3107,7 @@ bool CWallet::InitLoadWallet()
LogPrintf("Allowing wallet upgrade up to %i\n", nMaxVersion);
if (nMaxVersion < walletInstance->GetVersion())
{
- return UIError(_("Cannot downgrade wallet"));
+ return InitError(_("Cannot downgrade wallet"));
}
walletInstance->SetMaxVersion(nMaxVersion);
}
@@ -3136,7 +3121,7 @@ bool CWallet::InitLoadWallet()
if (walletInstance->GetKeyFromPool(newDefaultKey)) {
walletInstance->SetDefaultKey(newDefaultKey);
if (!walletInstance->SetAddressBook(walletInstance->vchDefaultKey.GetID(), "", "receive"))
- return UIError(_("Cannot write default address") += "\n");
+ return InitError(_("Cannot write default address") += "\n");
}
walletInstance->SetBestChain(chainActive.GetLocator());
@@ -3170,7 +3155,7 @@ bool CWallet::InitLoadWallet()
block = block->pprev;
if (pindexRescan != block)
- return UIError(_("Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)"));
+ return InitError(_("Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)"));
}
uiInterface.InitMessage(_("Rescanning..."));
@@ -3220,28 +3205,28 @@ bool CWallet::ParameterInteraction()
if (ParseMoney(mapArgs["-mintxfee"], n) && n > 0)
CWallet::minTxFee = CFeeRate(n);
else
- return UIError(AmountErrMsg("mintxfee", mapArgs["-mintxfee"]));
+ return InitError(AmountErrMsg("mintxfee", mapArgs["-mintxfee"]));
}
if (mapArgs.count("-fallbackfee"))
{
CAmount nFeePerK = 0;
if (!ParseMoney(mapArgs["-fallbackfee"], nFeePerK))
- return UIError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), mapArgs["-fallbackfee"]));
+ return InitError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), mapArgs["-fallbackfee"]));
if (nFeePerK > HIGH_TX_FEE_PER_KB)
- UIWarning(_("-fallbackfee is set very high! This is the transaction fee you may pay when fee estimates are not available."));
+ InitWarning(_("-fallbackfee is set very high! This is the transaction fee you may pay when fee estimates are not available."));
CWallet::fallbackFee = CFeeRate(nFeePerK);
}
if (mapArgs.count("-paytxfee"))
{
CAmount nFeePerK = 0;
if (!ParseMoney(mapArgs["-paytxfee"], nFeePerK))
- return UIError(AmountErrMsg("paytxfee", mapArgs["-paytxfee"]));
+ return InitError(AmountErrMsg("paytxfee", mapArgs["-paytxfee"]));
if (nFeePerK > HIGH_TX_FEE_PER_KB)
- UIWarning(_("-paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
+ InitWarning(_("-paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
payTxFee = CFeeRate(nFeePerK, 1000);
if (payTxFee < ::minRelayTxFee)
{
- return UIError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)"),
+ return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)"),
mapArgs["-paytxfee"], ::minRelayTxFee.ToString()));
}
}
@@ -3249,13 +3234,13 @@ bool CWallet::ParameterInteraction()
{
CAmount nMaxFee = 0;
if (!ParseMoney(mapArgs["-maxtxfee"], nMaxFee))
- return UIError(AmountErrMsg("maxtxfee", mapArgs["-maxtxfee"]));
+ return InitError(AmountErrMsg("maxtxfee", mapArgs["-maxtxfee"]));
if (nMaxFee > HIGH_MAX_TX_FEE)
- UIWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
+ InitWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
maxTxFee = nMaxFee;
if (CFeeRate(maxTxFee, 1000) < ::minRelayTxFee)
{
- return UIError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"),
+ return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"),
mapArgs["-maxtxfee"], ::minRelayTxFee.ToString()));
}
}