aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/misc/example-linearize.cfg12
-rwxr-xr-xcontrib/misc/linearize.py129
-rw-r--r--src/init.cpp3
-rw-r--r--src/qt/addresstablemodel.cpp2
-rw-r--r--src/qt/bitcoin.cpp20
-rw-r--r--src/qt/bitcoingui.cpp5
-rw-r--r--src/qt/paymentserver.cpp22
-rw-r--r--src/qt/paymentserver.h18
-rw-r--r--src/qt/sendcoinsdialog.cpp36
-rw-r--r--src/qt/test/paymentservertests.cpp3
-rw-r--r--src/qt/transactiondesc.cpp26
-rw-r--r--src/qt/transactiondesc.h2
-rw-r--r--src/qt/transactiontablemodel.cpp14
13 files changed, 221 insertions, 71 deletions
diff --git a/contrib/misc/example-linearize.cfg b/contrib/misc/example-linearize.cfg
new file mode 100644
index 0000000000..9e5aa404c2
--- /dev/null
+++ b/contrib/misc/example-linearize.cfg
@@ -0,0 +1,12 @@
+
+# bitcoind RPC settings
+rpcuser=someuser
+rpcpass=somepassword
+host=127.0.0.1
+port=8332
+
+# bootstrap.dat settings
+netmagic=f9beb4d9
+max_height=250000
+output=bootstrap.dat
+
diff --git a/contrib/misc/linearize.py b/contrib/misc/linearize.py
new file mode 100755
index 0000000000..2d8509f83c
--- /dev/null
+++ b/contrib/misc/linearize.py
@@ -0,0 +1,129 @@
+#!/usr/bin/python
+#
+# linearize.py: Construct a linear, no-fork, best version of the blockchain.
+#
+#
+# Copyright (c) 2013 The Bitcoin developers
+# Distributed under the MIT/X11 software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#
+
+import json
+import struct
+import re
+import base64
+import httplib
+import sys
+
+ERR_SLEEP = 15
+MAX_NONCE = 1000000L
+
+settings = {}
+
+class BitcoinRPC:
+ OBJID = 1
+
+ def __init__(self, host, port, username, password):
+ authpair = "%s:%s" % (username, password)
+ self.authhdr = "Basic %s" % (base64.b64encode(authpair))
+ self.conn = httplib.HTTPConnection(host, port, False, 30)
+ def rpc(self, method, params=None):
+ self.OBJID += 1
+ obj = { 'version' : '1.1',
+ 'method' : method,
+ 'id' : self.OBJID }
+ if params is None:
+ obj['params'] = []
+ else:
+ obj['params'] = params
+ self.conn.request('POST', '/', json.dumps(obj),
+ { 'Authorization' : self.authhdr,
+ 'Content-type' : 'application/json' })
+
+ resp = self.conn.getresponse()
+ if resp is None:
+ print "JSON-RPC: no response"
+ return None
+
+ body = resp.read()
+ resp_obj = json.loads(body)
+ if resp_obj is None:
+ print "JSON-RPC: cannot JSON-decode body"
+ return None
+ if 'error' in resp_obj and resp_obj['error'] != None:
+ return resp_obj['error']
+ if 'result' not in resp_obj:
+ print "JSON-RPC: no result in object"
+ return None
+
+ return resp_obj['result']
+ def getblock(self, hash, verbose=True):
+ return self.rpc('getblock', [hash, verbose])
+ def getblockhash(self, index):
+ return self.rpc('getblockhash', [index])
+
+def getblock(rpc, settings, n):
+ hash = rpc.getblockhash(n)
+ hexdata = rpc.getblock(hash, False)
+ data = hexdata.decode('hex')
+
+ return data
+
+def get_blocks(settings):
+ rpc = BitcoinRPC(settings['host'], settings['port'],
+ settings['rpcuser'], settings['rpcpass'])
+
+ outf = open(settings['output'], 'wb')
+
+ for height in xrange(settings['max_height']+1):
+ data = getblock(rpc, settings, height)
+
+ outhdr = settings['netmagic']
+ outhdr += struct.pack("<i", len(data))
+
+ outf.write(outhdr)
+ outf.write(data)
+
+ if (height % 1000) == 0:
+ sys.stdout.write("Wrote block " + str(height) + "\n")
+
+if __name__ == '__main__':
+ if len(sys.argv) != 2:
+ print "Usage: linearize.py CONFIG-FILE"
+ sys.exit(1)
+
+ f = open(sys.argv[1])
+ for line in f:
+ # skip comment lines
+ m = re.search('^\s*#', line)
+ if m:
+ continue
+
+ # parse key=value lines
+ m = re.search('^(\w+)\s*=\s*(\S.*)$', line)
+ if m is None:
+ continue
+ settings[m.group(1)] = m.group(2)
+ f.close()
+
+ if 'netmagic' not in settings:
+ settings['netmagic'] = 'f9beb4d9'
+ if 'output' not in settings:
+ settings['output'] = 'bootstrap.dat'
+ if 'host' not in settings:
+ settings['host'] = '127.0.0.1'
+ if 'port' not in settings:
+ settings['port'] = 8332
+ if 'max_height' not in settings:
+ settings['max_height'] = 250000
+ if 'rpcuser' not in settings or 'rpcpass' not in settings:
+ print "Missing username and/or password in cfg file"
+ sys.exit(1)
+
+ settings['netmagic'] = settings['netmagic'].decode('hex')
+ settings['port'] = int(settings['port'])
+ settings['max_height'] = int(settings['max_height'])
+
+ get_blocks(settings)
+
+
diff --git a/src/init.cpp b/src/init.cpp
index acf6deab8d..57e20523b1 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -377,8 +377,6 @@ bool AppInit2(boost::thread_group& threadGroup)
// ********************************************************* Step 2: parameter interactions
- Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
-
if (mapArgs.count("-bind")) {
// when specifying an explicit binding address, you want to listen on it
// even when -connect or -proxy is specified
@@ -427,6 +425,7 @@ bool AppInit2(boost::thread_group& threadGroup)
fDebug = GetBoolArg("-debug", false);
fBenchmark = GetBoolArg("-benchmark", false);
mempool.fChecks = GetBoolArg("-checkmempool", RegTest());
+ Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
nScriptCheckThreads = GetArg("-par", 0);
diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp
index 69355febe2..be31b03749 100644
--- a/src/qt/addresstablemodel.cpp
+++ b/src/qt/addresstablemodel.cpp
@@ -87,6 +87,8 @@ public:
}
}
// qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
+ // Even though the map is already sorted this re-sorting step is needed because the originating map
+ // is sorted by binary address, not by base58() address.
qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan());
}
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 9c290fa717..a4d589e167 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -155,12 +155,12 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
#if QT_VERSION < 0x050000
void DebugMessageHandler(QtMsgType type, const char * msg)
{
- OutputDebugStringF("%s\n", msg);
+ OutputDebugStringF("Bitcoin-Qt: %s\n", msg);
}
#else
void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)
{
- OutputDebugStringF("%s\n", qPrintable(msg));
+ OutputDebugStringF("Bitcoin-Qt: %s\n", qPrintable(msg));
}
#endif
@@ -236,6 +236,12 @@ int main(int argc, char *argv[])
// Install global event filter that makes sure that long tooltips can be word-wrapped
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
+ // Install qDebug() message handler to route to debug.log
+#if QT_VERSION < 0x050000
+ qInstallMsgHandler(DebugMessageHandler);
+#else
+ qInstallMessageHandler(DebugMessageHandler);
+#endif
// ... now GUI settings:
OptionsModel optionsModel;
@@ -255,13 +261,6 @@ int main(int argc, char *argv[])
return 1;
}
- // Install qDebug() message handler to route to debug.log:
-#if QT_VERSION < 0x050000
- qInstallMsgHandler(DebugMessageHandler);
-#else
- qInstallMessageHandler(DebugMessageHandler);
-#endif
-
SplashScreen splash(QPixmap(), 0);
if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false))
{
@@ -300,7 +299,8 @@ int main(int argc, char *argv[])
optionsModel.Upgrade(); // Must be done after AppInit2
PaymentServer::LoadRootCAs();
- paymentServer->initNetManager(optionsModel);
+ paymentServer->setOptionsModel(&optionsModel);
+ paymentServer->initNetManager();
if (splashref)
splash.finish(&window);
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index ad32c9ea68..bb9eb60e5b 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -670,9 +670,12 @@ void BitcoinGUI::closeEvent(QCloseEvent *event)
void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
{
+ if (!clientModel || !clientModel->getOptionsModel())
+ return;
+
QString strMessage = tr("This transaction is over the size limit. You can still send it for a fee of %1, "
"which goes to the nodes that process your transaction and helps to support the network. "
- "Do you want to pay the fee?").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nFeeRequired));
+ "Do you want to pay the fee?").arg(BitcoinUnits::formatWithUnit(clientModel->getOptionsModel()->getDisplayUnit(), nFeeRequired));
QMessageBox::StandardButton retval = QMessageBox::question(
this, tr("Confirm transaction fee"), strMessage,
QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index ff3c2a0981..c7c6f6706a 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -92,7 +92,7 @@ static void ReportInvalidCertificate(const QSslCertificate& cert)
}
//
-// Load openSSL's list of root certificate authorities
+// Load OpenSSL's list of root certificate authorities
//
void PaymentServer::LoadRootCAs(X509_STORE* _store)
{
@@ -147,7 +147,7 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store)
const unsigned char *data = (const unsigned char *)certData.data();
X509* x509 = d2i_X509(0, &data, certData.size());
- if (x509 && X509_STORE_add_cert( PaymentServer::certStore, x509))
+ if (x509 && X509_STORE_add_cert(PaymentServer::certStore, x509))
{
// Note: X509_STORE_free will free the X509* objects when
// the PaymentServer is destroyed
@@ -303,18 +303,20 @@ bool PaymentServer::eventFilter(QObject *, QEvent *event)
return false;
}
-void PaymentServer::initNetManager(const OptionsModel& options)
+void PaymentServer::initNetManager()
{
+ if (!optionsModel)
+ return;
if (netManager != NULL)
delete netManager;
// netManager is used to fetch paymentrequests given in bitcoin: URI's
netManager = new QNetworkAccessManager(this);
- // Use proxy settings from options:
+ // Use proxy settings from optionsModel:
QString proxyIP;
quint16 proxyPort;
- if (options.getProxySettings(proxyIP, proxyPort))
+ if (optionsModel->getProxySettings(proxyIP, proxyPort))
{
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::Socks5Proxy);
@@ -435,13 +437,16 @@ bool
PaymentServer::processPaymentRequest(PaymentRequestPlus& request,
QList<SendCoinsRecipient>& recipients)
{
+ if (!optionsModel)
+ return false;
+
QList<std::pair<CScript,qint64> > sendingTos = request.getPayTo();
qint64 totalAmount = 0;
foreach(const PAIRTYPE(CScript, qint64)& sendingTo, sendingTos) {
CTxOut txOut(sendingTo.second, sendingTo.first);
if (txOut.IsDust(CTransaction::nMinRelayTxFee)) {
QString message = QObject::tr("Requested payment amount (%1) too small")
- .arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, sendingTo.second));
+ .arg(BitcoinUnits::formatWithUnit(optionsModel->getDisplayUnit(), sendingTo.second));
qDebug() << message;
emit reportError(tr("Payment request error"), message, CClientUIInterface::MODAL);
return false;
@@ -614,3 +619,8 @@ PaymentServer::reportSslErrors(QNetworkReply* reply, const QList<QSslError> &err
}
emit reportError(tr("Network request error"), errString, CClientUIInterface::MODAL);
}
+
+void PaymentServer::setOptionsModel(OptionsModel *optionsModel)
+{
+ this->optionsModel = optionsModel;
+}
diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h
index 7c6b2eabf0..131ede518e 100644
--- a/src/qt/paymentserver.h
+++ b/src/qt/paymentserver.h
@@ -17,7 +17,7 @@
// received at or during startup in a list.
//
// When startup is finished and the main window is
-// show, a signal is sent to slot uiReady(), which
+// shown, a signal is sent to slot uiReady(), which
// emits a receivedURL() signal for any payment
// requests that happened during startup.
//
@@ -70,13 +70,16 @@ public:
// Return certificate store
static X509_STORE* getCertStore() { return certStore; }
- // Setup networking (options is used to get proxy settings)
- void initNetManager(const OptionsModel& options);
+ // Setup networking
+ void initNetManager();
// Constructor registers this on the parent QApplication to
// receive QEvent::FileOpen events
bool eventFilter(QObject *object, QEvent *event);
+ // OptionsModel is used for getting proxy settings and display unit
+ void setOptionsModel(OptionsModel *optionsModel);
+
signals:
// Fired when a valid payment request is received
void receivedPaymentRequest(SendCoinsRecipient);
@@ -106,12 +109,15 @@ private:
void handleURIOrFile(const QString& s);
void fetchRequest(const QUrl& url);
- bool saveURIs; // true during startup
+ bool saveURIs; // true during startup
QLocalServer* uriServer;
- static X509_STORE* certStore; // Trusted root certificates
+
+ static X509_STORE* certStore; // Trusted root certificates
static void freeCertStore();
- QNetworkAccessManager* netManager; // Used to fetch payment requests
+ QNetworkAccessManager* netManager; // Used to fetch payment requests
+
+ OptionsModel *optionsModel;
};
#endif // PAYMENTSERVER_H
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 9086f6614e..df3ff5c9a9 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -63,12 +63,12 @@ SendCoinsDialog::~SendCoinsDialog()
void SendCoinsDialog::on_sendButton_clicked()
{
+ if(!model || !model->getOptionsModel())
+ return;
+
QList<SendCoinsRecipient> recipients;
bool valid = true;
- if(!model)
- return;
-
for(int i = 0; i < ui->entries->count(); ++i)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
@@ -94,24 +94,16 @@ void SendCoinsDialog::on_sendButton_clicked()
QStringList formatted;
foreach(const SendCoinsRecipient &rcp, recipients)
{
- QString amount = BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount);
+ QString amount = BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
if (rcp.authenticatedMerchant.isEmpty())
{
QString address = rcp.address;
-#if QT_VERSION < 0x050000
- QString to = Qt::escape(rcp.label);
-#else
- QString to = rcp.label.toHtmlEscaped();
-#endif
+ QString to = GUIUtil::HtmlEscape(rcp.label);
formatted.append(tr("<b>%1</b> to %2 (%3)").arg(amount, to, address));
}
else
{
-#if QT_VERSION < 0x050000
- QString merchant = Qt::escape(rcp.authenticatedMerchant);
-#else
- QString merchant = rcp.authenticatedMerchant.toHtmlEscaped();
-#endif
+ QString merchant = GUIUtil::HtmlEscape(rcp.authenticatedMerchant);
formatted.append(tr("<b>%1</b> to %2").arg(amount, merchant));
}
}
@@ -158,7 +150,7 @@ void SendCoinsDialog::on_sendButton_clicked()
case WalletModel::AmountWithFeeExceedsBalance:
QMessageBox::warning(this, tr("Send Coins"),
tr("The total exceeds your balance when the %1 transaction fee is included.").
- arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, sendstatus.fee)),
+ arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), sendstatus.fee)),
QMessageBox::Ok, QMessageBox::Ok);
break;
case WalletModel::DuplicateAddress:
@@ -338,18 +330,14 @@ void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint
{
Q_UNUSED(unconfirmedBalance);
Q_UNUSED(immatureBalance);
- if(!model || !model->getOptionsModel())
- return;
- int unit = model->getOptionsModel()->getDisplayUnit();
- ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance));
+ if(model && model->getOptionsModel())
+ {
+ ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance));
+ }
}
void SendCoinsDialog::updateDisplayUnit()
{
- if(model && model->getOptionsModel())
- {
- // Update labelBalance with the current balance and the current unit
- ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->getBalance()));
- }
+ setBalance(model->getBalance(), 0, 0);
}
diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp
index 2e26ab0c9b..6c8ad62b2b 100644
--- a/src/qt/test/paymentservertests.cpp
+++ b/src/qt/test/paymentservertests.cpp
@@ -58,7 +58,8 @@ void PaymentServerTests::paymentServerTests()
X509_STORE* caStore = X509_STORE_new();
X509_STORE_add_cert(caStore, parse_b64der_cert(caCert_BASE64));
PaymentServer::LoadRootCAs(caStore);
- server->initNetManager(optionsModel);
+ server->setOptionsModel(&optionsModel);
+ server->initNetManager();
server->uiReady();
// Now feed PaymentRequests to server, and observe signals it produces:
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 25ff3623c0..55875c2e46 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -32,7 +32,7 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
}
}
-QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
+QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int unit)
{
QString strHTML;
@@ -129,7 +129,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
nUnmatured += wallet->GetCredit(txout);
strHTML += "<b>" + tr("Credit") + ":</b> ";
if (wtx.IsInMainChain())
- strHTML += BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", wtx.GetBlocksToMaturity()) + ")";
+ strHTML += BitcoinUnits::formatWithUnit(unit, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", wtx.GetBlocksToMaturity()) + ")";
else
strHTML += "(" + tr("not accepted") + ")";
strHTML += "<br>";
@@ -139,7 +139,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
//
// Credit
//
- strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nNet) + "<br>";
+ strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, nNet) + "<br>";
}
else
{
@@ -175,7 +175,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
}
}
- strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -txout.nValue) + "<br>";
+ strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -txout.nValue) + "<br>";
}
if (fAllToMe)
@@ -183,13 +183,13 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
// Payment to self
int64 nChange = wtx.GetChange();
int64 nValue = nCredit - nChange;
- strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nValue) + "<br>";
- strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nValue) + "<br>";
+ strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -nValue) + "<br>";
+ strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, nValue) + "<br>";
}
int64 nTxFee = nDebit - GetValueOut(wtx);
if (nTxFee > 0)
- strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nTxFee) + "<br>";
+ strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -nTxFee) + "<br>";
}
else
{
@@ -198,14 +198,14 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
//
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
if (wallet->IsMine(txin))
- strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -wallet->GetDebit(txin)) + "<br>";
+ strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -wallet->GetDebit(txin)) + "<br>";
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
if (wallet->IsMine(txout))
- strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, wallet->GetCredit(txout)) + "<br>";
+ strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, wallet->GetCredit(txout)) + "<br>";
}
}
- strHTML += "<b>" + tr("Net amount") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nNet, true) + "<br>";
+ strHTML += "<b>" + tr("Net amount") + ":</b> " + BitcoinUnits::formatWithUnit(unit, nNet, true) + "<br>";
//
// Message
@@ -243,10 +243,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
if(wallet->IsMine(txin))
- strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -wallet->GetDebit(txin)) + "<br>";
+ strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -wallet->GetDebit(txin)) + "<br>";
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
if(wallet->IsMine(txout))
- strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, wallet->GetCredit(txout)) + "<br>";
+ strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, wallet->GetCredit(txout)) + "<br>";
strHTML += "<br><b>" + tr("Transaction") + ":</b><br>";
strHTML += GUIUtil::HtmlEscape(wtx.ToString(), true);
@@ -274,7 +274,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + " ";
strHTML += QString::fromStdString(CBitcoinAddress(address).ToString());
}
- strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, vout.nValue);
+ strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatWithUnit(unit, vout.nValue);
strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) ? tr("true") : tr("false")) + "</li>";
}
}
diff --git a/src/qt/transactiondesc.h b/src/qt/transactiondesc.h
index cb0dda5b58..a659281dd2 100644
--- a/src/qt/transactiondesc.h
+++ b/src/qt/transactiondesc.h
@@ -14,7 +14,7 @@ class TransactionDesc: public QObject
Q_OBJECT
public:
- static QString toHTML(CWallet *wallet, CWalletTx &wtx);
+ static QString toHTML(CWallet *wallet, CWalletTx &wtx, int unit);
private:
TransactionDesc() {}
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 977e56a2b0..9c040d5b63 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -48,11 +48,12 @@ struct TxLessThan
class TransactionTablePriv
{
public:
- TransactionTablePriv(CWallet *wallet, TransactionTableModel *parent):
- wallet(wallet),
- parent(parent)
+ TransactionTablePriv(CWallet *wallet, TransactionTableModel *parent) :
+ wallet(wallet),
+ parent(parent)
{
}
+
CWallet *wallet;
TransactionTableModel *parent;
@@ -200,19 +201,18 @@ public:
}
}
- QString describe(TransactionRecord *rec)
+ QString describe(TransactionRecord *rec, int unit)
{
{
LOCK(wallet->cs_wallet);
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
if(mi != wallet->mapWallet.end())
{
- return TransactionDesc::toHTML(wallet, mi->second);
+ return TransactionDesc::toHTML(wallet, mi->second, unit);
}
}
return QString("");
}
-
};
TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *parent):
@@ -561,7 +561,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case DateRole:
return QDateTime::fromTime_t(static_cast<uint>(rec->time));
case LongDescriptionRole:
- return priv->describe(rec);
+ return priv->describe(rec, walletModel->getOptionsModel()->getDisplayUnit());
case AddressRole:
return QString::fromStdString(rec->address);
case LabelRole: