aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/addrman.h4
-rw-r--r--src/init.cpp31
-rw-r--r--src/main.cpp6
-rw-r--r--src/qt/paymentrequestplus.cpp3
-rw-r--r--src/qt/paymentserver.cpp16
-rw-r--r--src/qt/sendcoinsdialog.cpp108
-rw-r--r--src/qt/sendcoinsdialog.h10
-rw-r--r--src/util.cpp17
-rw-r--r--src/util.h1
9 files changed, 111 insertions, 85 deletions
diff --git a/src/addrman.h b/src/addrman.h
index 081543ace4..d703e1091e 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -419,7 +419,7 @@ public:
Check();
}
if (fRet)
- LogPrint("addr", "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort().c_str(), source.ToString().c_str(), nTried, nNew);
+ LogPrint("addrman", "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort().c_str(), source.ToString().c_str(), nTried, nNew);
return fRet;
}
@@ -435,7 +435,7 @@ public:
Check();
}
if (nAdd)
- LogPrint("addr", "Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString().c_str(), nTried, nNew);
+ LogPrint("addrman", "Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString().c_str(), nTried, nNew);
return nAdd > 0;
}
diff --git a/src/init.cpp b/src/init.cpp
index 72b53ebecc..647b8d52ea 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -215,8 +215,18 @@ std::string HelpMessage(HelpMessageMode hmm)
#endif
#endif
strUsage += " -paytxfee=<amt> " + _("Fee per KB to add to transactions you send") + "\n";
- strUsage += " -debug " + _("Output extra debugging information. Implies all other -debug* options") + "\n";
- strUsage += " -debugnet " + _("Output extra network debugging information") + "\n";
+ strUsage += " -debug=<category> " + _("Output debugging information (default: 0, supplying <category> is optional)") + "\n";
+ strUsage += _("If <category> is not supplied, output all debugging information.") + "\n";
+ strUsage += _("<category> can be:");
+ strUsage += " addrman, alert, coindb, db, lock, rand, rpc, selectcoins, mempool, net"; // Don't translate these and qt below
+ if (hmm == HMM_BITCOIN_QT)
+ {
+ strUsage += ", qt.\n";
+ }
+ else
+ {
+ strUsage += ".\n";
+ }
strUsage += " -logtimestamps " + _("Prepend debug output with timestamp") + "\n";
strUsage += " -shrinkdebugfile " + _("Shrink debug.log file on client startup (default: 1 when no -debug)") + "\n";
strUsage += " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n";
@@ -457,7 +467,16 @@ bool AppInit2(boost::thread_group& threadGroup)
// ********************************************************* Step 3: parameter-to-internal-flags
- if (mapMultiArgs.count("-debug")) fDebug = true;
+ fDebug = !mapMultiArgs["-debug"].empty();
+ // Special-case: if -debug=0/-nodebug is set, turn off debugging messages
+ const vector<string>& categories = mapMultiArgs["-debug"];
+ if (GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), string("0")) != categories.end())
+ fDebug = false;
+
+ // Check for -debugnet (deprecated)
+ if (GetBoolArg("-debugnet", false))
+ InitWarning(_("Warning: Deprecated argument -debugnet ignored, use -debug=net"));
+
fBenchmark = GetBoolArg("-benchmark", false);
mempool.fChecks = GetBoolArg("-checkmempool", RegTest());
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
@@ -471,12 +490,6 @@ bool AppInit2(boost::thread_group& threadGroup)
else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS)
nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS;
- // -debug implies fDebug*
- if (fDebug)
- fDebugNet = true;
- else
- fDebugNet = GetBoolArg("-debugnet", false);
-
if (fDaemon)
fServer = true;
else
diff --git a/src/main.cpp b/src/main.cpp
index 3d339b4fdd..640fbac8bb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3544,10 +3544,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
return error("message getdata size() = %"PRIszu"", vInv.size());
}
- if (fDebugNet || (vInv.size() != 1))
+ if (fDebug || (vInv.size() != 1))
LogPrint("net", "received getdata (%"PRIszu" invsz)\n", vInv.size());
- if ((fDebugNet && vInv.size() > 0) || (vInv.size() == 1))
+ if ((fDebug && vInv.size() > 0) || (vInv.size() == 1))
LogPrint("net", "received getdata for: %s\n", vInv[0].ToString().c_str());
pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end());
@@ -4213,7 +4213,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
const CInv& inv = (*pto->mapAskFor.begin()).second;
if (!AlreadyHave(inv))
{
- if (fDebugNet)
+ if (fDebug)
LogPrint("net", "sending getdata: %s\n", inv.ToString().c_str());
vGetData.push_back(inv);
if (vGetData.size() >= 1000)
diff --git a/src/qt/paymentrequestplus.cpp b/src/qt/paymentrequestplus.cpp
index f6a898ff7c..c8afd837d2 100644
--- a/src/qt/paymentrequestplus.cpp
+++ b/src/qt/paymentrequestplus.cpp
@@ -75,8 +75,7 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
digestAlgorithm = EVP_sha1();
}
else if (paymentRequest.pki_type() == "none") {
- if (fDebug)
- qDebug() << "PaymentRequestPlus::getMerchant : Payment request: pki_type == none";
+ qDebug() << "PaymentRequestPlus::getMerchant : Payment request: pki_type == none";
return false;
}
else {
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index 43c4bdd191..0f386680ac 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -87,9 +87,7 @@ static QList<QString> savedPaymentRequests;
static void ReportInvalidCertificate(const QSslCertificate& cert)
{
- if (fDebug) {
- qDebug() << "ReportInvalidCertificate : Payment server found an invalid certificate: " << cert.subjectInfo(QSslCertificate::CommonName);
- }
+ qDebug() << "ReportInvalidCertificate : Payment server found an invalid certificate: " << cert.subjectInfo(QSslCertificate::CommonName);
}
//
@@ -160,8 +158,7 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store)
continue;
}
}
- if (fDebug)
- qDebug() << "PaymentServer::LoadRootCAs : Loaded " << nRootCerts << " root certificates";
+ qDebug() << "PaymentServer::LoadRootCAs : Loaded " << nRootCerts << " root certificates";
// Project for another day:
// Fetch certificate revocation lists, and add them to certStore.
@@ -375,8 +372,7 @@ void PaymentServer::handleURIOrFile(const QString& s)
QString decoded = QUrl::fromPercentEncoding(temp);
QUrl fetchUrl(decoded, QUrl::StrictMode);
- if (fDebug)
- qDebug() << "PaymentServer::handleURIOrFile : fetchRequest(" << fetchUrl << ")";
+ qDebug() << "PaymentServer::handleURIOrFile : fetchRequest(" << fetchUrl << ")";
if (fetchUrl.isValid())
fetchRequest(fetchUrl);
@@ -475,8 +471,7 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen
if (request.getMerchant(PaymentServer::certStore, recipients[0].authenticatedMerchant)) {
recipients[0].paymentRequest = request;
recipients[0].amount = totalAmount;
- if (fDebug)
- qDebug() << "PaymentServer::processPaymentRequest : Payment request from " << recipients[0].authenticatedMerchant;
+ qDebug() << "PaymentServer::processPaymentRequest : Payment request from " << recipients[0].authenticatedMerchant;
}
else {
recipients.clear();
@@ -493,8 +488,7 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen
if (i == 0) // Tie request to first pay-to, we don't want multiple ACKs
recipients[i].paymentRequest = request;
recipients[i].address = QString::fromStdString(CBitcoinAddress(dest).ToString());
- if (fDebug)
- qDebug() << "PaymentServer::processPaymentRequest : Payment request, insecure " << recipients[i].address;
+ qDebug() << "PaymentServer::processPaymentRequest : Payment request, insecure " << recipients[i].address;
}
else {
// Insecure payments to custom bitcoin addresses are not supported
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index d574eb73f9..51304bc05c 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -1,13 +1,13 @@
#include "sendcoinsdialog.h"
#include "ui_sendcoinsdialog.h"
-#include "walletmodel.h"
#include "bitcoinunits.h"
#include "optionsmodel.h"
#include "sendcoinsentry.h"
#include "guiutil.h"
#include "askpassphrasedialog.h"
#include "base58.h"
+#include "ui_interface.h"
#include <QMessageBox>
#include <QTextDocument>
@@ -136,41 +136,9 @@ void SendCoinsDialog::on_sendButton_clicked()
// prepare transaction for getting txFee earlier
WalletModelTransaction currentTransaction(recipients);
WalletModel::SendCoinsReturn prepareStatus = model->prepareTransaction(currentTransaction);
-
- QString strSendCoins = tr("Send Coins");
- switch(prepareStatus.status)
- {
- case WalletModel::InvalidAddress:
- QMessageBox::warning(this, strSendCoins,
- tr("The recipient address is not valid, please recheck."));
- break;
- case WalletModel::InvalidAmount:
- QMessageBox::warning(this, strSendCoins,
- tr("The amount to pay must be larger than 0."));
- break;
- case WalletModel::AmountExceedsBalance:
- QMessageBox::warning(this, strSendCoins,
- tr("The amount exceeds your balance."));
- break;
- case WalletModel::AmountWithFeeExceedsBalance:
- QMessageBox::warning(this, strSendCoins,
- tr("The total exceeds your balance when the %1 transaction fee is included.").
- arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee())));
- break;
- case WalletModel::DuplicateAddress:
- QMessageBox::warning(this, strSendCoins,
- tr("Duplicate address found, can only send to each address once per send operation."));
- break;
- case WalletModel::TransactionCreationFailed:
- QMessageBox::warning(this, strSendCoins,
- tr("Error: Transaction creation failed!"));
- break;
- case WalletModel::TransactionCommitFailed:
- case WalletModel::OK:
- case WalletModel::Aborted: // User aborted, nothing to do
- default:
- break;
- }
+ // process prepareStatus and on error generate message shown to user
+ processSendCoinsReturn(prepareStatus,
+ BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
if(prepareStatus.status != WalletModel::OK) {
fNewRecipientAllowed = true;
@@ -208,19 +176,13 @@ void SendCoinsDialog::on_sendButton_clicked()
}
// now send the prepared transaction
- WalletModel::SendCoinsReturn sendstatus = model->sendCoins(currentTransaction);
- switch(sendstatus.status)
+ WalletModel::SendCoinsReturn sendStatus = model->sendCoins(currentTransaction);
+ // process sendStatus and on error generate message shown to user
+ processSendCoinsReturn(sendStatus);
+
+ if (sendStatus.status == WalletModel::OK)
{
- case WalletModel::TransactionCommitFailed:
- QMessageBox::warning(this, strSendCoins,
- tr("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."));
- break;
- case WalletModel::OK:
accept();
- break;
- case WalletModel::Aborted: // User aborted, nothing to do
- default:
- break;
}
fNewRecipientAllowed = true;
}
@@ -356,16 +318,16 @@ bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv)
const payments::PaymentDetails& details = rv.paymentRequest.getDetails();
if (details.has_expires() && (int64)details.expires() < GetTime())
{
- QMessageBox::warning(this, strSendCoins,
- tr("Payment request expired"));
+ emit message(strSendCoins, tr("Payment request expired"),
+ CClientUIInterface::MSG_WARNING);
return false;
}
}
else {
CBitcoinAddress address(rv.address.toStdString());
if (!address.IsValid()) {
- QMessageBox::warning(this, strSendCoins,
- tr("Invalid payment address %1").arg(rv.address));
+ emit message(strSendCoins, tr("Invalid payment address %1").arg(rv.address),
+ CClientUIInterface::MSG_WARNING);
return false;
}
}
@@ -389,3 +351,47 @@ void SendCoinsDialog::updateDisplayUnit()
{
setBalance(model->getBalance(), 0, 0);
}
+
+void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg)
+{
+ QPair<QString, CClientUIInterface::MessageBoxFlags> msgParams;
+ // Default to a warning message, override if error message is needed
+ msgParams.second = CClientUIInterface::MSG_WARNING;
+
+ // This comment is specific to SendCoinsDialog usage of WalletModel::SendCoinsReturn.
+ // WalletModel::TransactionCommitFailed is used only in WalletModel::sendCoins()
+ // all others are used only in WalletModel::prepareTransaction()
+ switch(sendCoinsReturn.status)
+ {
+ case WalletModel::InvalidAddress:
+ msgParams.first = tr("The recipient address is not valid, please recheck.");
+ break;
+ case WalletModel::InvalidAmount:
+ msgParams.first = tr("The amount to pay must be larger than 0.");
+ break;
+ case WalletModel::AmountExceedsBalance:
+ msgParams.first = tr("The amount exceeds your balance.");
+ break;
+ case WalletModel::AmountWithFeeExceedsBalance:
+ msgParams.first = tr("The total exceeds your balance when the %1 transaction fee is included.").arg(msgArg);
+ break;
+ case WalletModel::DuplicateAddress:
+ msgParams.first = tr("Duplicate address found, can only send to each address once per send operation.");
+ break;
+ case WalletModel::TransactionCreationFailed:
+ msgParams.first = tr("Transaction creation failed!");
+ msgParams.second = CClientUIInterface::MSG_ERROR;
+ break;
+ case WalletModel::TransactionCommitFailed:
+ msgParams.first = tr("The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
+ msgParams.second = CClientUIInterface::MSG_ERROR;
+ break;
+ // OK and Aborted are included to prevent a compiler warning.
+ case WalletModel::OK:
+ case WalletModel::Aborted:
+ default:
+ return;
+ }
+
+ emit message(tr("Send Coins"), msgParams.first, msgParams.second);
+}
diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h
index b295b7d837..4e68e26731 100644
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -1,16 +1,17 @@
#ifndef SENDCOINSDIALOG_H
#define SENDCOINSDIALOG_H
+#include "walletmodel.h"
+
#include <QDialog>
#include <QVariant>
+#include <QPair>
namespace Ui {
class SendCoinsDialog;
}
-class WalletModel;
class SendCoinsEntry;
class SendCoinsRecipient;
-class OptionsModel;
QT_BEGIN_NAMESPACE
class QUrl;
@@ -48,6 +49,11 @@ private:
WalletModel *model;
bool fNewRecipientAllowed;
+ // Process WalletModel::SendCoinsReturn and generate a pair consisting
+ // of a message and message flags for use in emit message().
+ // Additional parameter msgArg can be used via .arg(msgArg).
+ void processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg = QString());
+
private slots:
void on_sendButton_clicked();
void removeEntry(SendCoinsEntry* entry);
diff --git a/src/util.cpp b/src/util.cpp
index 71994587cf..9ee1ad5f52 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -73,7 +73,6 @@ using namespace std;
map<string, string> mapArgs;
map<string, vector<string> > mapMultiArgs;
bool fDebug = false;
-bool fDebugNet = false;
bool fPrintToConsole = false;
bool fPrintToDebugger = false;
bool fDaemon = false;
@@ -226,10 +225,20 @@ int LogPrint(const char* category, const char* pszFormat, ...)
{
if (category != NULL)
{
- if (!fDebug) return 0;
- const vector<string>& categories = mapMultiArgs["-debug"];
- if (find(categories.begin(), categories.end(), string(category)) == categories.end())
+ if (!fDebug)
return 0;
+
+ const vector<string>& categories = mapMultiArgs["-debug"];
+ bool allCategories = count(categories.begin(), categories.end(), string(""));
+
+ // Only look for categories, if not -debug/-debug=1 was passed,
+ // as that implies every category should be logged.
+ if (!allCategories)
+ {
+ // Category was not found (not supplied via -debug=<category>)
+ if (find(categories.begin(), categories.end(), string(category)) == categories.end())
+ return 0;
+ }
}
int ret = 0; // Returns total number of characters written
diff --git a/src/util.h b/src/util.h
index 258910e2fb..2573694046 100644
--- a/src/util.h
+++ b/src/util.h
@@ -140,7 +140,6 @@ inline void MilliSleep(int64 n)
extern std::map<std::string, std::string> mapArgs;
extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
extern bool fDebug;
-extern bool fDebugNet;
extern bool fPrintToConsole;
extern bool fPrintToDebugger;
extern bool fDaemon;