Skip to content
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

Fix "Load PSBT" functionality when no wallet loaded #399

Merged
merged 1 commit into from
Aug 11, 2021

Conversation

psancheti110
Copy link
Contributor

@psancheti110 psancheti110 commented Aug 7, 2021

This PR provides a fix to the issue mentioned in #232.

Currently, the Load PSBT functionality works well in case a wallet is loaded but does nothing when a wallet isn't loaded.

If a function cannot work without a wallet being loaded, it is disabled by default (It is unclickable as shown in the image).

For e.g. One cannot Close Wallet or Backup Wallet or Sign Messages without a wallet being loaded. And hence they are disabled. But if you notice, Load PSBT options are not disabled by default even when a wallet isn't loaded.

Screenshot 2021-08-07 at 11 46 30 PM

As mentioned by hebasto in the issue description :

<hebasto> achow101: does "File" -> "Load PSBT from {file|clipboard}" make any sense when no wallet is loaded?
<achow101> hebasto: yes, for finalize and sending

This means Load PSBT should be working just as similar whether wallets are being loaded or not.

After making the required changes to the code, The Load PSBT works as expected even with no wallet loaded and the PSBT is finalized.

Master PR
Hnet com-image (1) Hnet com-image (2)

Close #232

@hebasto
Copy link
Member

hebasto commented Aug 7, 2021

Concept ACK.

@hebasto hebasto added Bug Something isn't working UX All about "how to get things done" Wallet labels Aug 7, 2021
@psancheti110 psancheti110 changed the title [WIP] qt: Fix "Load PSBT" functionality when no wallet loaded qt: Fix "Load PSBT" functionality when no wallet loaded Aug 7, 2021
@psancheti110 psancheti110 marked this pull request as ready for review August 7, 2021 19:36
@hebasto hebasto changed the title qt: Fix "Load PSBT" functionality when no wallet loaded Fix "Load PSBT" functionality when no wallet loaded Aug 7, 2021
Copy link
Member

@achow101 achow101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

src/qt/psbtoperationsdialog.cpp Outdated Show resolved Hide resolved
src/qt/psbtoperationsdialog.cpp Outdated Show resolved Hide resolved
src/qt/psbtoperationsdialog.cpp Show resolved Hide resolved
src/qt/psbtoperationsdialog.cpp Outdated Show resolved Hide resolved
src/qt/walletframe.cpp Outdated Show resolved Hide resolved
src/qt/walletframe.cpp Outdated Show resolved Hide resolved
@psancheti110
Copy link
Contributor Author

PR Updated from a77d04f -> cb7b222. Click here to check diff.

Addressed changes suggested by @achow101 in #399 (review).

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach ACK cb7b222.

After moving PSBT dialog code from walletview.cpp into waletframe.cpp, some includes could be removed:

--- a/src/qt/walletview.cpp
+++ b/src/qt/walletview.cpp
@@ -8,7 +8,6 @@
 #include <qt/askpassphrasedialog.h>
 #include <qt/clientmodel.h>
 #include <qt/guiutil.h>
-#include <qt/psbtoperationsdialog.h>
 #include <qt/optionsmodel.h>
 #include <qt/overviewpage.h>
 #include <qt/platformstyle.h>
@@ -21,13 +20,10 @@
 
 #include <interfaces/node.h>
 #include <node/ui_interface.h>
-#include <psbt.h>
 #include <util/strencodings.h>
 
 #include <QAction>
 #include <QActionGroup>
-#include <QApplication>
-#include <QClipboard>
 #include <QFileDialog>
 #include <QHBoxLayout>
 #include <QProgressDialog>

src/qt/psbtoperationsdialog.cpp Outdated Show resolved Hide resolved
}
PSBTOperationsDialog* dlg = new PSBTOperationsDialog(this, currentWalletModel(), clientModel);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add an empty line above as it was in walletview.cpp for readability and easier verifying with diff --color-moved=dimmed-zebra?

if (walletView) {
walletView->gotoLoadPSBT(from_clipboard);
std::string data;
if (from_clipboard) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add an empty line above as it was in walletview.cpp for readability and easier verifying with diff --color-moved=dimmed-zebra?

Comment on lines 203 to 205
QString filename = GUIUtil::getOpenFileName(this,
tr("Load Transaction Data"), QString(),
tr("Partially Signed Transaction (*.psbt)"), nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand these indentations were suggested by clang-format-diff.py, but to keep verifying easy with diff --color-moved=dimmed-zebra, I'd suggest to keep the same indentations as they were in walletview.cpp.

@psancheti110
Copy link
Contributor Author

PR Updated from cb7b222 -> e5e0091. Click here to check diff.

Addressed changes suggested by @hebasto in #399 (review)

@achow101
Copy link
Member

ACK e5e0091

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested e5e0091.

I think the PSBTOperationsDialog::showTransactionStatus should be modified to correctly handle unsigned PSBTs:

--- a/src/qt/psbtoperationsdialog.cpp
+++ b/src/qt/psbtoperationsdialog.cpp
@@ -254,7 +254,10 @@ void PSBTOperationsDialog::showTransactionStatus(const PartiallySignedTransactio
         case PSBTRole::SIGNER: {
             QString need_sig_text = tr("Transaction still needs signature(s).");
             StatusLevel level = StatusLevel::INFO;
-            if (m_wallet_model->wallet().privateKeysDisabled()) {
+            if (!m_wallet_model) {
+                need_sig_text += " " + tr("(But no wallet is loaded.)");
+                level = StatusLevel::WARN;
+            } else if (m_wallet_model->wallet().privateKeysDisabled()) {
                 need_sig_text += " " + tr("(But this wallet cannot sign transactions.)");
                 level = StatusLevel::WARN;
             } else if (n_could_sign < 1) {

@psancheti110
Copy link
Contributor Author

PR Updated from e5e0091 -> 0237d95. Click here to check diff.

Addressed changes suggested by @hebasto in #399 (review)

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 0237d95, tested on Linux Mint 20.2 (Qt 5.12.8).

No wallet is loaded when testing: bitcoin-qt -nowallet.

A. The loading of an unsigned PSBT being prepared with the walletcreatefundedpsbt RPC command:

Screenshot from 2021-08-11 14-06-59

B. The loading of a signed PSBT which is the PSBT mentioned above being processed with the walletprocesspsbt RPC command:

Screenshot from 2021-08-11 14-07-33

@achow101
Copy link
Member

re-ACK 0237d95

@hebasto hebasto merged commit e614cc8 into bitcoin-core:master Aug 11, 2021
@psancheti110
Copy link
Contributor Author

A big thanks to all the contributors who took out time to test and review my PR.
Appreciate each and every comment made here by fellow mates
🙌🏻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working UX All about "how to get things done" Wallet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Load PSBT from file..." does not work when no wallet is loaded
3 participants