Merge pull request #2930 from Diapolo/displayUnit
Bitcoin-Qt: fixes for using display unit from options
This commit is contained in:
commit
1a12b3e090
9 changed files with 67 additions and 50 deletions
|
@ -300,7 +300,8 @@ int main(int argc, char *argv[])
|
||||||
optionsModel.Upgrade(); // Must be done after AppInit2
|
optionsModel.Upgrade(); // Must be done after AppInit2
|
||||||
|
|
||||||
PaymentServer::LoadRootCAs();
|
PaymentServer::LoadRootCAs();
|
||||||
paymentServer->initNetManager(optionsModel);
|
paymentServer->setOptionsModel(&optionsModel);
|
||||||
|
paymentServer->initNetManager();
|
||||||
|
|
||||||
if (splashref)
|
if (splashref)
|
||||||
splash.finish(&window);
|
splash.finish(&window);
|
||||||
|
|
|
@ -670,9 +670,12 @@ void BitcoinGUI::closeEvent(QCloseEvent *event)
|
||||||
|
|
||||||
void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
|
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, "
|
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. "
|
"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(
|
QMessageBox::StandardButton retval = QMessageBox::question(
|
||||||
this, tr("Confirm transaction fee"), strMessage,
|
this, tr("Confirm transaction fee"), strMessage,
|
||||||
QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
|
QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
|
||||||
|
|
|
@ -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)
|
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();
|
const unsigned char *data = (const unsigned char *)certData.data();
|
||||||
|
|
||||||
X509* x509 = d2i_X509(0, &data, certData.size());
|
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
|
// Note: X509_STORE_free will free the X509* objects when
|
||||||
// the PaymentServer is destroyed
|
// the PaymentServer is destroyed
|
||||||
|
@ -303,18 +303,20 @@ bool PaymentServer::eventFilter(QObject *, QEvent *event)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaymentServer::initNetManager(const OptionsModel& options)
|
void PaymentServer::initNetManager()
|
||||||
{
|
{
|
||||||
|
if (!optionsModel)
|
||||||
|
return;
|
||||||
if (netManager != NULL)
|
if (netManager != NULL)
|
||||||
delete netManager;
|
delete netManager;
|
||||||
|
|
||||||
// netManager is used to fetch paymentrequests given in bitcoin: URI's
|
// netManager is used to fetch paymentrequests given in bitcoin: URI's
|
||||||
netManager = new QNetworkAccessManager(this);
|
netManager = new QNetworkAccessManager(this);
|
||||||
|
|
||||||
// Use proxy settings from options:
|
// Use proxy settings from optionsModel:
|
||||||
QString proxyIP;
|
QString proxyIP;
|
||||||
quint16 proxyPort;
|
quint16 proxyPort;
|
||||||
if (options.getProxySettings(proxyIP, proxyPort))
|
if (optionsModel->getProxySettings(proxyIP, proxyPort))
|
||||||
{
|
{
|
||||||
QNetworkProxy proxy;
|
QNetworkProxy proxy;
|
||||||
proxy.setType(QNetworkProxy::Socks5Proxy);
|
proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||||
|
@ -435,13 +437,16 @@ bool
|
||||||
PaymentServer::processPaymentRequest(PaymentRequestPlus& request,
|
PaymentServer::processPaymentRequest(PaymentRequestPlus& request,
|
||||||
QList<SendCoinsRecipient>& recipients)
|
QList<SendCoinsRecipient>& recipients)
|
||||||
{
|
{
|
||||||
|
if (!optionsModel)
|
||||||
|
return false;
|
||||||
|
|
||||||
QList<std::pair<CScript,qint64> > sendingTos = request.getPayTo();
|
QList<std::pair<CScript,qint64> > sendingTos = request.getPayTo();
|
||||||
qint64 totalAmount = 0;
|
qint64 totalAmount = 0;
|
||||||
foreach(const PAIRTYPE(CScript, qint64)& sendingTo, sendingTos) {
|
foreach(const PAIRTYPE(CScript, qint64)& sendingTo, sendingTos) {
|
||||||
CTxOut txOut(sendingTo.second, sendingTo.first);
|
CTxOut txOut(sendingTo.second, sendingTo.first);
|
||||||
if (txOut.IsDust(CTransaction::nMinRelayTxFee)) {
|
if (txOut.IsDust(CTransaction::nMinRelayTxFee)) {
|
||||||
QString message = QObject::tr("Requested payment amount (%1) too small")
|
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;
|
qDebug() << message;
|
||||||
emit reportError(tr("Payment request error"), message, CClientUIInterface::MODAL);
|
emit reportError(tr("Payment request error"), message, CClientUIInterface::MODAL);
|
||||||
return false;
|
return false;
|
||||||
|
@ -614,3 +619,8 @@ PaymentServer::reportSslErrors(QNetworkReply* reply, const QList<QSslError> &err
|
||||||
}
|
}
|
||||||
emit reportError(tr("Network request error"), errString, CClientUIInterface::MODAL);
|
emit reportError(tr("Network request error"), errString, CClientUIInterface::MODAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PaymentServer::setOptionsModel(OptionsModel *optionsModel)
|
||||||
|
{
|
||||||
|
this->optionsModel = optionsModel;
|
||||||
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
// received at or during startup in a list.
|
// received at or during startup in a list.
|
||||||
//
|
//
|
||||||
// When startup is finished and the main window is
|
// 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
|
// emits a receivedURL() signal for any payment
|
||||||
// requests that happened during startup.
|
// requests that happened during startup.
|
||||||
//
|
//
|
||||||
|
@ -70,13 +70,16 @@ public:
|
||||||
// Return certificate store
|
// Return certificate store
|
||||||
static X509_STORE* getCertStore() { return certStore; }
|
static X509_STORE* getCertStore() { return certStore; }
|
||||||
|
|
||||||
// Setup networking (options is used to get proxy settings)
|
// Setup networking
|
||||||
void initNetManager(const OptionsModel& options);
|
void initNetManager();
|
||||||
|
|
||||||
// Constructor registers this on the parent QApplication to
|
// Constructor registers this on the parent QApplication to
|
||||||
// receive QEvent::FileOpen events
|
// receive QEvent::FileOpen events
|
||||||
bool eventFilter(QObject *object, QEvent *event);
|
bool eventFilter(QObject *object, QEvent *event);
|
||||||
|
|
||||||
|
// OptionsModel is used for getting proxy settings and display unit
|
||||||
|
void setOptionsModel(OptionsModel *optionsModel);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// Fired when a valid payment request is received
|
// Fired when a valid payment request is received
|
||||||
void receivedPaymentRequest(SendCoinsRecipient);
|
void receivedPaymentRequest(SendCoinsRecipient);
|
||||||
|
@ -108,10 +111,13 @@ private:
|
||||||
|
|
||||||
bool saveURIs; // true during startup
|
bool saveURIs; // true during startup
|
||||||
QLocalServer* uriServer;
|
QLocalServer* uriServer;
|
||||||
|
|
||||||
static X509_STORE* certStore; // Trusted root certificates
|
static X509_STORE* certStore; // Trusted root certificates
|
||||||
static void freeCertStore();
|
static void freeCertStore();
|
||||||
|
|
||||||
QNetworkAccessManager* netManager; // Used to fetch payment requests
|
QNetworkAccessManager* netManager; // Used to fetch payment requests
|
||||||
|
|
||||||
|
OptionsModel *optionsModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PAYMENTSERVER_H
|
#endif // PAYMENTSERVER_H
|
||||||
|
|
|
@ -63,12 +63,12 @@ SendCoinsDialog::~SendCoinsDialog()
|
||||||
|
|
||||||
void SendCoinsDialog::on_sendButton_clicked()
|
void SendCoinsDialog::on_sendButton_clicked()
|
||||||
{
|
{
|
||||||
|
if(!model || !model->getOptionsModel())
|
||||||
|
return;
|
||||||
|
|
||||||
QList<SendCoinsRecipient> recipients;
|
QList<SendCoinsRecipient> recipients;
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
|
|
||||||
if(!model)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for(int i = 0; i < ui->entries->count(); ++i)
|
for(int i = 0; i < ui->entries->count(); ++i)
|
||||||
{
|
{
|
||||||
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
|
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
|
||||||
|
@ -94,7 +94,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||||
QStringList formatted;
|
QStringList formatted;
|
||||||
foreach(const SendCoinsRecipient &rcp, recipients)
|
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())
|
if (rcp.authenticatedMerchant.isEmpty())
|
||||||
{
|
{
|
||||||
QString address = rcp.address;
|
QString address = rcp.address;
|
||||||
|
@ -158,7 +158,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||||
case WalletModel::AmountWithFeeExceedsBalance:
|
case WalletModel::AmountWithFeeExceedsBalance:
|
||||||
QMessageBox::warning(this, tr("Send Coins"),
|
QMessageBox::warning(this, tr("Send Coins"),
|
||||||
tr("The total exceeds your balance when the %1 transaction fee is included.").
|
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);
|
QMessageBox::Ok, QMessageBox::Ok);
|
||||||
break;
|
break;
|
||||||
case WalletModel::DuplicateAddress:
|
case WalletModel::DuplicateAddress:
|
||||||
|
@ -338,18 +338,14 @@ void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint
|
||||||
{
|
{
|
||||||
Q_UNUSED(unconfirmedBalance);
|
Q_UNUSED(unconfirmedBalance);
|
||||||
Q_UNUSED(immatureBalance);
|
Q_UNUSED(immatureBalance);
|
||||||
if(!model || !model->getOptionsModel())
|
|
||||||
return;
|
|
||||||
|
|
||||||
int unit = model->getOptionsModel()->getDisplayUnit();
|
if(model && model->getOptionsModel())
|
||||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance));
|
{
|
||||||
|
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendCoinsDialog::updateDisplayUnit()
|
void SendCoinsDialog::updateDisplayUnit()
|
||||||
{
|
{
|
||||||
if(model && model->getOptionsModel())
|
setBalance(model->getBalance(), 0, 0);
|
||||||
{
|
|
||||||
// Update labelBalance with the current balance and the current unit
|
|
||||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->getBalance()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,8 @@ void PaymentServerTests::paymentServerTests()
|
||||||
X509_STORE* caStore = X509_STORE_new();
|
X509_STORE* caStore = X509_STORE_new();
|
||||||
X509_STORE_add_cert(caStore, parse_b64der_cert(caCert_BASE64));
|
X509_STORE_add_cert(caStore, parse_b64der_cert(caCert_BASE64));
|
||||||
PaymentServer::LoadRootCAs(caStore);
|
PaymentServer::LoadRootCAs(caStore);
|
||||||
server->initNetManager(optionsModel);
|
server->setOptionsModel(&optionsModel);
|
||||||
|
server->initNetManager();
|
||||||
server->uiReady();
|
server->uiReady();
|
||||||
|
|
||||||
// Now feed PaymentRequests to server, and observe signals it produces:
|
// Now feed PaymentRequests to server, and observe signals it produces:
|
||||||
|
|
|
@ -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;
|
QString strHTML;
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
nUnmatured += wallet->GetCredit(txout);
|
nUnmatured += wallet->GetCredit(txout);
|
||||||
strHTML += "<b>" + tr("Credit") + ":</b> ";
|
strHTML += "<b>" + tr("Credit") + ":</b> ";
|
||||||
if (wtx.IsInMainChain())
|
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
|
else
|
||||||
strHTML += "(" + tr("not accepted") + ")";
|
strHTML += "(" + tr("not accepted") + ")";
|
||||||
strHTML += "<br>";
|
strHTML += "<br>";
|
||||||
|
@ -139,7 +139,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
//
|
//
|
||||||
// Credit
|
// Credit
|
||||||
//
|
//
|
||||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nNet) + "<br>";
|
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, nNet) + "<br>";
|
||||||
}
|
}
|
||||||
else
|
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)
|
if (fAllToMe)
|
||||||
|
@ -183,13 +183,13 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
// Payment to self
|
// Payment to self
|
||||||
int64 nChange = wtx.GetChange();
|
int64 nChange = wtx.GetChange();
|
||||||
int64 nValue = nCredit - nChange;
|
int64 nValue = nCredit - nChange;
|
||||||
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nValue) + "<br>";
|
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -nValue) + "<br>";
|
||||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nValue) + "<br>";
|
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, nValue) + "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 nTxFee = nDebit - GetValueOut(wtx);
|
int64 nTxFee = nDebit - GetValueOut(wtx);
|
||||||
if (nTxFee > 0)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -198,14 +198,14 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
//
|
//
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
||||||
if (wallet->IsMine(txin))
|
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)
|
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||||
if (wallet->IsMine(txout))
|
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
|
// Message
|
||||||
|
@ -243,10 +243,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
||||||
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
|
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
||||||
if(wallet->IsMine(txin))
|
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)
|
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||||
if(wallet->IsMine(txout))
|
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 += "<br><b>" + tr("Transaction") + ":</b><br>";
|
||||||
strHTML += GUIUtil::HtmlEscape(wtx.ToString(), true);
|
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 += GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + " ";
|
||||||
strHTML += QString::fromStdString(CBitcoinAddress(address).ToString());
|
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>";
|
strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) ? tr("true") : tr("false")) + "</li>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TransactionDesc: public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QString toHTML(CWallet *wallet, CWalletTx &wtx);
|
static QString toHTML(CWallet *wallet, CWalletTx &wtx, int unit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TransactionDesc() {}
|
TransactionDesc() {}
|
||||||
|
|
|
@ -48,11 +48,12 @@ struct TxLessThan
|
||||||
class TransactionTablePriv
|
class TransactionTablePriv
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TransactionTablePriv(CWallet *wallet, TransactionTableModel *parent):
|
TransactionTablePriv(CWallet *wallet, TransactionTableModel *parent) :
|
||||||
wallet(wallet),
|
wallet(wallet),
|
||||||
parent(parent)
|
parent(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CWallet *wallet;
|
CWallet *wallet;
|
||||||
TransactionTableModel *parent;
|
TransactionTableModel *parent;
|
||||||
|
|
||||||
|
@ -200,19 +201,18 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString describe(TransactionRecord *rec)
|
QString describe(TransactionRecord *rec, int unit)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
|
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
|
||||||
if(mi != wallet->mapWallet.end())
|
if(mi != wallet->mapWallet.end())
|
||||||
{
|
{
|
||||||
return TransactionDesc::toHTML(wallet, mi->second);
|
return TransactionDesc::toHTML(wallet, mi->second, unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QString("");
|
return QString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *parent):
|
TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *parent):
|
||||||
|
@ -561,7 +561,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||||
case DateRole:
|
case DateRole:
|
||||||
return QDateTime::fromTime_t(static_cast<uint>(rec->time));
|
return QDateTime::fromTime_t(static_cast<uint>(rec->time));
|
||||||
case LongDescriptionRole:
|
case LongDescriptionRole:
|
||||||
return priv->describe(rec);
|
return priv->describe(rec, walletModel->getOptionsModel()->getDisplayUnit());
|
||||||
case AddressRole:
|
case AddressRole:
|
||||||
return QString::fromStdString(rec->address);
|
return QString::fromStdString(rec->address);
|
||||||
case LabelRole:
|
case LabelRole:
|
||||||
|
|
Loading…
Reference in a new issue