diff options
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/bitcoingui.cpp | 3 | ||||
-rw-r--r-- | src/qt/coincontroldialog.cpp | 34 | ||||
-rw-r--r-- | src/qt/coincontroldialog.h | 1 | ||||
-rw-r--r-- | src/qt/forms/coincontroldialog.ui | 41 | ||||
-rw-r--r-- | src/qt/forms/sendcoinsdialog.ui | 35 | ||||
-rw-r--r-- | src/qt/psbtoperationsdialog.cpp | 2 | ||||
-rw-r--r-- | src/qt/rpcconsole.cpp | 6 | ||||
-rw-r--r-- | src/qt/rpcconsole.h | 4 | ||||
-rw-r--r-- | src/qt/sendcoinsdialog.cpp | 9 | ||||
-rw-r--r-- | src/qt/sendcoinsdialog.h | 1 | ||||
-rw-r--r-- | src/qt/test/apptests.cpp | 1 | ||||
-rw-r--r-- | src/qt/test/uritests.cpp | 26 |
12 files changed, 55 insertions, 108 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index f201d8fa01..fd329faf18 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -412,6 +412,7 @@ void BitcoinGUI::createActions() connect(action, &QAction::triggered, [this, path] { auto activity = new OpenWalletActivity(m_wallet_controller, this); connect(activity, &OpenWalletActivity::opened, this, &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection); + connect(activity, &OpenWalletActivity::opened, rpcConsole, &RPCConsole::setCurrentWallet, Qt::QueuedConnection); activity->open(path); }); } @@ -441,6 +442,7 @@ void BitcoinGUI::createActions() auto activity = new RestoreWalletActivity(m_wallet_controller, this); connect(activity, &RestoreWalletActivity::restored, this, &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection); + connect(activity, &RestoreWalletActivity::restored, rpcConsole, &RPCConsole::setCurrentWallet, Qt::QueuedConnection); auto backup_file_path = fs::PathFromString(backup_file.toStdString()); activity->restore(backup_file_path, wallet_name.toStdString()); @@ -451,6 +453,7 @@ void BitcoinGUI::createActions() connect(m_create_wallet_action, &QAction::triggered, [this] { auto activity = new CreateWalletActivity(m_wallet_controller, this); connect(activity, &CreateWalletActivity::created, this, &BitcoinGUI::setCurrentWallet); + connect(activity, &CreateWalletActivity::created, rpcConsole, &RPCConsole::setCurrentWallet); activity->create(); }); connect(m_close_all_wallets_action, &QAction::triggered, [this] { diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 50d3c2e559..38c7656e00 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -70,7 +70,6 @@ CoinControlDialog::CoinControlDialog(CCoinControl& coin_control, WalletModel* _m QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); - QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this); QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); connect(clipboardQuantityAction, &QAction::triggered, this, &CoinControlDialog::clipboardQuantity); @@ -78,7 +77,6 @@ CoinControlDialog::CoinControlDialog(CCoinControl& coin_control, WalletModel* _m connect(clipboardFeeAction, &QAction::triggered, this, &CoinControlDialog::clipboardFee); connect(clipboardAfterFeeAction, &QAction::triggered, this, &CoinControlDialog::clipboardAfterFee); connect(clipboardBytesAction, &QAction::triggered, this, &CoinControlDialog::clipboardBytes); - connect(clipboardLowOutputAction, &QAction::triggered, this, &CoinControlDialog::clipboardLowOutput); connect(clipboardChangeAction, &QAction::triggered, this, &CoinControlDialog::clipboardChange); ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); @@ -86,7 +84,6 @@ CoinControlDialog::CoinControlDialog(CCoinControl& coin_control, WalletModel* _m ui->labelCoinControlFee->addAction(clipboardFeeAction); ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); ui->labelCoinControlBytes->addAction(clipboardBytesAction); - ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); ui->labelCoinControlChange->addAction(clipboardChangeAction); // toggle tree/list mode @@ -294,12 +291,6 @@ void CoinControlDialog::clipboardBytes() GUIUtil::setClipboard(ui->labelCoinControlBytes->text().replace(ASYMP_UTF8, "")); } -// copy label "Dust" to clipboard -void CoinControlDialog::clipboardLowOutput() -{ - GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text()); -} - // copy label "Change" to clipboard void CoinControlDialog::clipboardChange() { @@ -390,17 +381,8 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel * // nPayAmount CAmount nPayAmount = 0; - bool fDust = false; - for (const CAmount &amount : CoinControlDialog::payAmounts) - { + for (const CAmount &amount : CoinControlDialog::payAmounts) { nPayAmount += amount; - - if (amount > 0) - { - // Assumes a p2pkh script size - CTxOut txout(amount, CScript() << std::vector<unsigned char>(24, 0)); - fDust |= IsDust(txout, model->node().getDustRelayFee()); - } } CAmount nAmount = 0; @@ -515,12 +497,9 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel * QLabel *l3 = dialog->findChild<QLabel *>("labelCoinControlFee"); QLabel *l4 = dialog->findChild<QLabel *>("labelCoinControlAfterFee"); QLabel *l5 = dialog->findChild<QLabel *>("labelCoinControlBytes"); - QLabel *l7 = dialog->findChild<QLabel *>("labelCoinControlLowOutput"); QLabel *l8 = dialog->findChild<QLabel *>("labelCoinControlChange"); - // enable/disable "dust" and "change" - dialog->findChild<QLabel *>("labelCoinControlLowOutputText")->setEnabled(nPayAmount > 0); - dialog->findChild<QLabel *>("labelCoinControlLowOutput") ->setEnabled(nPayAmount > 0); + // enable/disable "change" dialog->findChild<QLabel *>("labelCoinControlChangeText") ->setEnabled(nPayAmount > 0); dialog->findChild<QLabel *>("labelCoinControlChange") ->setEnabled(nPayAmount > 0); @@ -530,7 +509,6 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel * l3->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nPayFee)); // Fee l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); // After Fee l5->setText(((nBytes > 0) ? ASYMP_UTF8 : "") + QString::number(nBytes)); // Bytes - l7->setText(fDust ? tr("yes") : tr("no")); // Dust l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); // Change if (nPayFee > 0) { @@ -540,12 +518,6 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel * l8->setText(ASYMP_UTF8 + l8->text()); } - // turn label red when dust - l7->setStyleSheet((fDust) ? "color:red;" : ""); - - // tool tips - QString toolTipDust = tr("This label turns red if any recipient receives an amount smaller than the current dust threshold."); - // how many satoshis the estimated fee can vary per byte we guess wrong double dFeeVary = (nBytes != 0) ? (double)nPayFee / nBytes : 0; @@ -553,12 +525,10 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel * l3->setToolTip(toolTip4); l4->setToolTip(toolTip4); - l7->setToolTip(toolTipDust); l8->setToolTip(toolTip4); dialog->findChild<QLabel *>("labelCoinControlFeeText") ->setToolTip(l3->toolTip()); dialog->findChild<QLabel *>("labelCoinControlAfterFeeText") ->setToolTip(l4->toolTip()); dialog->findChild<QLabel *>("labelCoinControlBytesText") ->setToolTip(l5->toolTip()); - dialog->findChild<QLabel *>("labelCoinControlLowOutputText")->setToolTip(l7->toolTip()); dialog->findChild<QLabel *>("labelCoinControlChangeText") ->setToolTip(l8->toolTip()); // Insufficient funds diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h index ccceff10e8..5fc2cdca9b 100644 --- a/src/qt/coincontroldialog.h +++ b/src/qt/coincontroldialog.h @@ -105,7 +105,6 @@ private Q_SLOTS: void clipboardFee(); void clipboardAfterFee(); void clipboardBytes(); - void clipboardLowOutput(); void clipboardChange(); void radioTreeMode(bool); void radioListMode(bool); diff --git a/src/qt/forms/coincontroldialog.ui b/src/qt/forms/coincontroldialog.ui index 5ce469ee96..f053adba0f 100644 --- a/src/qt/forms/coincontroldialog.ui +++ b/src/qt/forms/coincontroldialog.ui @@ -24,6 +24,9 @@ </property> <item> <layout class="QFormLayout" name="formLayoutCoinControl1"> + <property name="labelAlignment"> + <set>Qt::AlignLeft|Qt::AlignVCenter</set> + </property> <property name="horizontalSpacing"> <number>10</number> </property> @@ -139,41 +142,6 @@ </property> </widget> </item> - <item row="1" column="0"> - <widget class="QLabel" name="labelCoinControlLowOutputText"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Dust:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="labelCoinControlLowOutput"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="cursor"> - <cursorShape>IBeamCursor</cursorShape> - </property> - <property name="contextMenuPolicy"> - <enum>Qt::ActionsContextMenu</enum> - </property> - <property name="text"> - <string notr="true">no</string> - </property> - <property name="textInteractionFlags"> - <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> - </property> - </widget> - </item> </layout> </item> <item> @@ -223,6 +191,9 @@ </item> <item> <layout class="QFormLayout" name="formLayoutCoinControl4"> + <property name="labelAlignment"> + <set>Qt::AlignLeft|Qt::AlignVCenter</set> + </property> <property name="horizontalSpacing"> <number>10</number> </property> diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index 37da6fedda..1ca92440c8 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -201,6 +201,9 @@ </property> <item> <layout class="QFormLayout" name="formLayoutCoinControl1"> + <property name="labelAlignment"> + <set>Qt::AlignLeft|Qt::AlignVCenter</set> + </property> <property name="horizontalSpacing"> <number>10</number> </property> @@ -331,35 +334,6 @@ </property> </widget> </item> - <item row="1" column="0"> - <widget class="QLabel" name="labelCoinControlLowOutputText"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Dust:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="labelCoinControlLowOutput"> - <property name="cursor"> - <cursorShape>IBeamCursor</cursorShape> - </property> - <property name="contextMenuPolicy"> - <enum>Qt::ActionsContextMenu</enum> - </property> - <property name="text"> - <string notr="true">no</string> - </property> - <property name="textInteractionFlags"> - <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> - </property> - </widget> - </item> </layout> </item> <item> @@ -415,6 +389,9 @@ </item> <item> <layout class="QFormLayout" name="formLayoutCoinControl4"> + <property name="labelAlignment"> + <set>Qt::AlignLeft|Qt::AlignVCenter</set> + </property> <property name="horizontalSpacing"> <number>10</number> </property> diff --git a/src/qt/psbtoperationsdialog.cpp b/src/qt/psbtoperationsdialog.cpp index fe52e11157..26f1696de1 100644 --- a/src/qt/psbtoperationsdialog.cpp +++ b/src/qt/psbtoperationsdialog.cpp @@ -182,6 +182,8 @@ std::string PSBTOperationsDialog::renderTransaction(const PartiallySignedTransac tx_description.append(tr(" * Sends %1 to %2") .arg(BitcoinUnits::formatWithUnit(BitcoinUnit::BTC, out.nValue)) .arg(QString::fromStdString(EncodeDestination(address)))); + // Check if the address is one of ours + if (m_wallet_model != nullptr && m_wallet_model->wallet().txoutIsMine(out)) tx_description.append(" (" + tr("own address") + ")"); tx_description.append("<br>"); } diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 90aae0219e..cb4ecfb6fb 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -797,6 +797,12 @@ void RPCConsole::removeWallet(WalletModel * const walletModel) ui->WalletSelectorLabel->setVisible(false); } } + +void RPCConsole::setCurrentWallet(WalletModel* const wallet_model) +{ + QVariant data = QVariant::fromValue(wallet_model); + ui->WalletSelector->setCurrentIndex(ui->WalletSelector->findData(data)); +} #endif static QString categoryClass(int category) diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 32a7520491..65eef7fbba 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -136,6 +136,10 @@ public Q_SLOTS: void unbanSelectedNode(); /** set which tab has the focus (is visible) */ void setTabFocus(enum TabTypes tabType); +#ifdef ENABLE_WALLET + /** Set the current (ie - active) wallet */ + void setCurrentWallet(WalletModel* const wallet_model); +#endif // ENABLE_WALLET private: struct TranslatedStrings { diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 48f7fb6ad1..dea9b92395 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -97,21 +97,18 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *p QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); - QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this); QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); connect(clipboardQuantityAction, &QAction::triggered, this, &SendCoinsDialog::coinControlClipboardQuantity); connect(clipboardAmountAction, &QAction::triggered, this, &SendCoinsDialog::coinControlClipboardAmount); connect(clipboardFeeAction, &QAction::triggered, this, &SendCoinsDialog::coinControlClipboardFee); connect(clipboardAfterFeeAction, &QAction::triggered, this, &SendCoinsDialog::coinControlClipboardAfterFee); connect(clipboardBytesAction, &QAction::triggered, this, &SendCoinsDialog::coinControlClipboardBytes); - connect(clipboardLowOutputAction, &QAction::triggered, this, &SendCoinsDialog::coinControlClipboardLowOutput); connect(clipboardChangeAction, &QAction::triggered, this, &SendCoinsDialog::coinControlClipboardChange); ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); ui->labelCoinControlAmount->addAction(clipboardAmountAction); ui->labelCoinControlFee->addAction(clipboardFeeAction); ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); ui->labelCoinControlBytes->addAction(clipboardBytesAction); - ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); ui->labelCoinControlChange->addAction(clipboardChangeAction); // init transaction fee section @@ -919,12 +916,6 @@ void SendCoinsDialog::coinControlClipboardBytes() GUIUtil::setClipboard(ui->labelCoinControlBytes->text().replace(ASYMP_UTF8, "")); } -// Coin Control: copy label "Dust" to clipboard -void SendCoinsDialog::coinControlClipboardLowOutput() -{ - GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text()); -} - // Coin Control: copy label "Change" to clipboard void SendCoinsDialog::coinControlClipboardChange() { diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index ac05cd98e5..4e861e55bb 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -111,7 +111,6 @@ private Q_SLOTS: void coinControlClipboardFee(); void coinControlClipboardAfterFee(); void coinControlClipboardBytes(); - void coinControlClipboardLowOutput(); void coinControlClipboardChange(); void updateFeeSectionControls(); void updateNumberOfBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state); diff --git a/src/qt/test/apptests.cpp b/src/qt/test/apptests.cpp index e918e84184..fb8029cb65 100644 --- a/src/qt/test/apptests.cpp +++ b/src/qt/test/apptests.cpp @@ -86,7 +86,6 @@ void AppTests::appTests() // Reset global state to avoid interfering with later tests. LogInstance().DisconnectTestLogger(); - AbortShutdown(); } //! Entry point for BitcoinGUI tests. diff --git a/src/qt/test/uritests.cpp b/src/qt/test/uritests.cpp index b87d3b21ca..935f078e3d 100644 --- a/src/qt/test/uritests.cpp +++ b/src/qt/test/uritests.cpp @@ -58,9 +58,35 @@ void URITests::uriTests() uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); + // Commas in amounts are not allowed. uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); + + // There are two amount specifications. The last value wins. + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&amount=200&label=Wikipedia Example")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); + QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); + QVERIFY(rv.amount == 20000000000LL); + QVERIFY(rv.label == QString("Wikipedia Example")); + + // The first amount value is correct. However, the second amount value is not valid. Hence, the URI is not valid. + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&amount=1,000&label=Wikipedia Example")); + QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); + + // Test label containing a question mark ('?'). + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=?")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); + QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); + QVERIFY(rv.amount == 10000000000LL); + QVERIFY(rv.label == QString("?")); + + // Escape sequences are not supported. + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=%3F")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); + QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); + QVERIFY(rv.amount == 10000000000LL); + QVERIFY(rv.label == QString("%3F")); } |