aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/addresstablemodel.cpp3
-rw-r--r--src/qt/bitcoingui.cpp6
-rw-r--r--src/qt/bitcoinunits.cpp21
-rw-r--r--src/qt/bitcoinunits.h4
-rw-r--r--src/qt/paymentserver.cpp35
-rw-r--r--src/qt/recentrequeststablemodel.cpp2
-rw-r--r--src/qt/sendcoinsdialog.cpp2
-rw-r--r--src/qt/test/wallettests.cpp5
-rw-r--r--src/qt/transactionview.cpp2
9 files changed, 46 insertions, 34 deletions
diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp
index c672486984..a2521a1e9e 100644
--- a/src/qt/addresstablemodel.cpp
+++ b/src/qt/addresstablemodel.cpp
@@ -384,7 +384,8 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
return QString();
}
}
- strAddress = EncodeDestination(newKey.GetID());
+ wallet->LearnRelatedScripts(newKey, g_address_type);
+ strAddress = EncodeDestination(GetDestinationForKey(newKey, g_address_type));
}
else
{
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 8efa009460..afd90a3bc6 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -1206,7 +1206,7 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *pl
const QFontMetrics fm(font());
for (const BitcoinUnits::Unit unit : units)
{
- max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit)));
+ max_width = qMax(max_width, fm.width(BitcoinUnits::longName(unit)));
}
setMinimumSize(max_width, 0);
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
@@ -1225,7 +1225,7 @@ void UnitDisplayStatusBarControl::createContextMenu()
menu = new QMenu(this);
for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
{
- QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
+ QAction *menuAction = new QAction(QString(BitcoinUnits::longName(u)), this);
menuAction->setData(QVariant(u));
menu->addAction(menuAction);
}
@@ -1250,7 +1250,7 @@ void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel *_optionsModel)
/** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */
void UnitDisplayStatusBarControl::updateDisplayUnit(int newUnits)
{
- setText(BitcoinUnits::name(newUnits));
+ setText(BitcoinUnits::longName(newUnits));
}
/** Shows context menu with Display Unit options by the mouse coordinates */
diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp
index 55811458a9..9df05d2a13 100644
--- a/src/qt/bitcoinunits.cpp
+++ b/src/qt/bitcoinunits.cpp
@@ -36,24 +36,33 @@ bool BitcoinUnits::valid(int unit)
}
}
-QString BitcoinUnits::name(int unit)
+QString BitcoinUnits::longName(int unit)
{
switch(unit)
{
case BTC: return QString("BTC");
case mBTC: return QString("mBTC");
- case uBTC: return QString::fromUtf8("μBTC");
+ case uBTC: return QString::fromUtf8("µBTC (bits)");
default: return QString("???");
}
}
+QString BitcoinUnits::shortName(int unit)
+{
+ switch(unit)
+ {
+ case uBTC: return QString::fromUtf8("bits");
+ default: return longName(unit);
+ }
+}
+
QString BitcoinUnits::description(int unit)
{
switch(unit)
{
case BTC: return QString("Bitcoins");
case mBTC: return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)");
- case uBTC: return QString("Micro-Bitcoins (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
+ case uBTC: return QString("Micro-Bitcoins (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
default: return QString("???");
}
}
@@ -121,7 +130,7 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
QString BitcoinUnits::formatWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
{
- return format(unit, amount, plussign, separators) + QString(" ") + name(unit);
+ return format(unit, amount, plussign, separators) + QString(" ") + shortName(unit);
}
QString BitcoinUnits::formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
@@ -176,7 +185,7 @@ QString BitcoinUnits::getAmountColumnTitle(int unit)
QString amountTitle = QObject::tr("Amount");
if (BitcoinUnits::valid(unit))
{
- amountTitle += " ("+BitcoinUnits::name(unit) + ")";
+ amountTitle += " ("+BitcoinUnits::shortName(unit) + ")";
}
return amountTitle;
}
@@ -197,7 +206,7 @@ QVariant BitcoinUnits::data(const QModelIndex &index, int role) const
{
case Qt::EditRole:
case Qt::DisplayRole:
- return QVariant(name(unit));
+ return QVariant(longName(unit));
case Qt::ToolTipRole:
return QVariant(description(unit));
case UnitRole:
diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h
index d94b33acde..310f651815 100644
--- a/src/qt/bitcoinunits.h
+++ b/src/qt/bitcoinunits.h
@@ -76,8 +76,10 @@ public:
static QList<Unit> availableUnits();
//! Is unit ID valid?
static bool valid(int unit);
+ //! Long name
+ static QString longName(int unit);
//! Short name
- static QString name(int unit);
+ static QString shortName(int unit);
//! Longer description
static QString description(int unit);
//! Number of Satoshis (1e-8) per unit
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index 8a83b513e1..dc729649b8 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -636,27 +636,24 @@ void PaymentServer::fetchPaymentACK(CWallet* wallet, const SendCoinsRecipient& r
// Create a new refund address, or re-use:
QString account = tr("Refund from %1").arg(recipient.authenticatedMerchant);
std::string strAccount = account.toStdString();
- std::set<CTxDestination> refundAddresses = wallet->GetAccountAddresses(strAccount);
- if (!refundAddresses.empty()) {
- CScript s = GetScriptForDestination(*refundAddresses.begin());
+ CPubKey newKey;
+ if (wallet->GetKeyFromPool(newKey)) {
+ // BIP70 requests encode the scriptPubKey directly, so we are not restricted to address
+ // types supported by the receiver. As a result, we choose the address format we also
+ // use for change. Despite an actual payment and not change, this is a close match:
+ // it's the output type we use subject to privacy issues, but not restricted by what
+ // other software supports.
+ wallet->LearnRelatedScripts(newKey, g_change_type);
+ CTxDestination dest = GetDestinationForKey(newKey, g_change_type);
+ wallet->SetAddressBook(dest, strAccount, "refund");
+
+ CScript s = GetScriptForDestination(dest);
payments::Output* refund_to = payment.add_refund_to();
refund_to->set_script(&s[0], s.size());
- }
- else {
- CPubKey newKey;
- if (wallet->GetKeyFromPool(newKey)) {
- CKeyID keyID = newKey.GetID();
- wallet->SetAddressBook(keyID, strAccount, "refund");
-
- CScript s = GetScriptForDestination(keyID);
- payments::Output* refund_to = payment.add_refund_to();
- refund_to->set_script(&s[0], s.size());
- }
- else {
- // This should never happen, because sending coins should have
- // just unlocked the wallet and refilled the keypool.
- qWarning() << "PaymentServer::fetchPaymentACK: Error getting refund key, refund_to not set";
- }
+ } else {
+ // This should never happen, because sending coins should have
+ // just unlocked the wallet and refilled the keypool.
+ qWarning() << "PaymentServer::fetchPaymentACK: Error getting refund key, refund_to not set";
}
int length = payment.ByteSize();
diff --git a/src/qt/recentrequeststablemodel.cpp b/src/qt/recentrequeststablemodel.cpp
index c8c2cb76a3..0dd7d46960 100644
--- a/src/qt/recentrequeststablemodel.cpp
+++ b/src/qt/recentrequeststablemodel.cpp
@@ -123,7 +123,7 @@ void RecentRequestsTableModel::updateAmountColumnTitle()
/** Gets title for amount column including current display unit if optionsModel reference available. */
QString RecentRequestsTableModel::getAmountTitle()
{
- return (this->walletModel->getOptionsModel() != nullptr) ? tr("Requested") + " ("+BitcoinUnits::name(this->walletModel->getOptionsModel()->getDisplayUnit()) + ")" : "";
+ return (this->walletModel->getOptionsModel() != nullptr) ? tr("Requested") + " ("+BitcoinUnits::shortName(this->walletModel->getOptionsModel()->getDisplayUnit()) + ")" : "";
}
QModelIndex RecentRequestsTableModel::index(int row, int column, const QModelIndex &parent) const
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 56b62f97fb..9fd61db70e 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -336,7 +336,7 @@ void SendCoinsDialog::on_sendButton_clicked()
}
questionString.append(tr("Total Amount %1")
.arg(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount)));
- questionString.append(QString("<span style='font-size:10pt;font-weight:normal;'><br />(=%2)</span>")
+ questionString.append(QString("<span style='font-size:10pt;font-weight:normal;'><br />(=%1)</span>")
.arg(alternativeUnits.join(" " + tr("or") + "<br />")));
questionString.append("<hr /><span>");
diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp
index 4b7c3bd726..a270e5de59 100644
--- a/src/qt/test/wallettests.cpp
+++ b/src/qt/test/wallettests.cpp
@@ -149,6 +149,9 @@ void BumpFee(TransactionView& view, const uint256& txid, bool expectDisabled, st
// src/qt/test/test_bitcoin-qt -platform cocoa # macOS
void TestGUI()
{
+ g_address_type = OUTPUT_TYPE_P2SH_SEGWIT;
+ g_change_type = OUTPUT_TYPE_P2SH_SEGWIT;
+
// Set up wallet and chain with 105 blocks (5 mature blocks for spending).
TestChain100Setup test;
for (int i = 0; i < 5; ++i) {
@@ -161,7 +164,7 @@ void TestGUI()
wallet.LoadWallet(firstRun);
{
LOCK(wallet.cs_wallet);
- wallet.SetAddressBook(test.coinbaseKey.GetPubKey().GetID(), "", "receive");
+ wallet.SetAddressBook(GetDestinationForKey(test.coinbaseKey.GetPubKey(), g_address_type), "", "receive");
wallet.AddKeyPubKey(test.coinbaseKey, test.coinbaseKey.GetPubKey());
}
{
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
index 868934288b..fa43ab750a 100644
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -365,7 +365,7 @@ void TransactionView::exportClicked()
// name, column, role
writer.setModel(transactionProxyModel);
writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole);
- if (model && model->haveWatchOnly())
+ if (model->haveWatchOnly())
writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly);
writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole);
writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole);