-
Notifications
You must be signed in to change notification settings - Fork 37.7k
interfaces: Stop exposing wallet destdata to gui #21353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Make sure wallet receive requests are saved and deleted correctly by GUI code Co-authored-by: Jarol Rodriguez <jarolrod@tutanota.com>
Stop giving GUI access to destdata rows in database. Replace with narrow API just for saving and reading receive request information. This simplifies code and should prevent the GUI from interfering with other destdata like address-used status. Note: No user-visible behavior is changing in this commit. New CWallet::SetAddressReceiveRequest() implementation avoids a bug in CWallet::AddDestData() where a modification would leave the previous value in memory while writing the new value to disk. But it doesn't matter because the GUI doesn't currently expose the ability to modify receive requests, only to add and erase them.
This simplifies code and adds a less cumbersome interface for accessing address used information than CWallet AddDestData / EraseDestData / GetDestData methods. There is no change in behavior. Lower-level walletdb DestData methods are also still available and not affected by this change. If there is interest in consolidating destdata logic more and making it internal to walletdb, bitcoin#18608 could be considered as a followup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 53291c7, tested on macOS 11.2 Qt 5.15.2
Tested that the functionality remained the same between master and this PR. Specifically with populating the recentrequeststablemodel
and actions like creating and removing a request.
This is a nice refactor and yay, more GUI test coverage!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated 53291c7 -> 758cbfa (pr/nodestg.2
-> pr/nodestg.3
, compare) with review suggestions
src/qt/test/wallettests.cpp
Outdated
@@ -225,6 +225,7 @@ void TestGUI(interfaces::Node& node) | |||
int initialRowCount = requestTableModel->rowCount({}); | |||
QPushButton* requestPaymentButton = receiveCoinsDialog.findChild<QPushButton*>("receiveButton"); | |||
requestPaymentButton->click(); | |||
std::string address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to use std::string
here? If we just use QString
we could avoid conversions on lines 238 and 274
diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp
index 3acf9d6b2..708c3cc92 100644
--- a/src/qt/test/wallettests.cpp
+++ b/src/qt/test/wallettests.cpp
@@ -225,7 +225,7 @@ void TestGUI(interfaces::Node& node)
int initialRowCount = requestTableModel->rowCount({});
QPushButton* requestPaymentButton = receiveCoinsDialog.findChild<QPushButton*>("receiveButton");
requestPaymentButton->click();
- std::string address;
+ QString address;
for (QWidget* widget : QApplication::topLevelWidgets()) {
if (widget->inherits("ReceiveRequestDialog")) {
ReceiveRequestDialog* receiveRequestDialog = qobject_cast<ReceiveRequestDialog*>(widget);
@@ -234,9 +234,9 @@ void TestGUI(interfaces::Node& node)
QString uri = receiveRequestDialog->QObject::findChild<QLabel*>("uri_content")->text();
QCOMPARE(uri.count("bitcoin:"), 2);
QCOMPARE(receiveRequestDialog->QObject::findChild<QLabel*>("address_tag")->text(), QString("Address:"));
- QVERIFY(address.empty());
- address = receiveRequestDialog->QObject::findChild<QLabel*>("address_content")->text().toStdString();
- QVERIFY(!address.empty());
+ QVERIFY(address.isEmpty());
+ address = receiveRequestDialog->QObject::findChild<QLabel*>("address_content")->text();
+ QVERIFY(!address.isEmpty());
QCOMPARE(uri.count("amount=0.00000001"), 2);
QCOMPARE(receiveRequestDialog->QObject::findChild<QLabel*>("amount_tag")->text(), QString("Amount:"));
@@ -271,7 +271,7 @@ void TestGUI(interfaces::Node& node)
QCOMPARE(entry.nVersion, int{1});
QCOMPARE(entry.id, int64_t{1});
QVERIFY(entry.date.isValid());
- QCOMPARE(entry.recipient.address, QString::fromStdString(address));
+ QCOMPARE(entry.recipient.address, address);
QCOMPARE(entry.recipient.label, QString{"TEST_LABEL_1"});
QCOMPARE(entry.recipient.amount, CAmount{1});
QCOMPARE(entry.recipient.message, QString{"TEST_MESSAGE_1"});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Applied simplification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated 758cbfa -> f5ba424 (pr/nodestg.3
-> pr/nodestg.4
, compare) with suggestion
src/qt/test/wallettests.cpp
Outdated
@@ -225,6 +225,7 @@ void TestGUI(interfaces::Node& node) | |||
int initialRowCount = requestTableModel->rowCount({}); | |||
QPushButton* requestPaymentButton = receiveCoinsDialog.findChild<QPushButton*>("receiveButton"); | |||
requestPaymentButton->click(); | |||
std::string address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Applied simplification
tACK f5ba424 |
Code review ACK f5ba424 |
f5ba424 wallet: Add IsAddressUsed / SetAddressUsed methods (Russell Yanofsky) 62252c9 interfaces: Stop exposing wallet destdata to gui (Russell Yanofsky) 985430d test: Add gui test for wallet receive requests (Russell Yanofsky) Pull request description: Stop giving GUI access to destdata rows in database. Replace with narrow API just for saving and reading receive request information. This simplifies code and should prevent the GUI from interfering with other destdata like address-used status. It also adds some more GUI test coverage. There are no changes in behavior. ACKs for top commit: jarolrod: tACK f5ba424 laanwj: Code review ACK f5ba424 Tree-SHA512: 5423df4786e537a59013cb5bfb9e1bc29a7ca4b8835360c00cc2165a59f925fdc355907a4ceb8bca0285bb4946ba235bffa7645537a951ad03fd3b4cee17b6b0
return batch.EraseDestData(EncodeDestination(dest), key); | ||
} | ||
|
||
const std::string value{"1"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "wallet: Add IsAddressUsed / SetAddressUsed methods" (f5ba424)
Note: behavior accidentally changed here. Used addresses previously were written with "p" values, now they are written with "1" values. The change should not be significant because the values are currently ignored, but future code should continue to treat "1" and "p" the same
Stop giving GUI access to destdata rows in database. Replace with narrow API just for saving and reading receive request information.
This simplifies code and should prevent the GUI from interfering with other destdata like address-used status. It also adds some more GUI test coverage.
There are no changes in behavior.