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

gui: Add dynamic wallets support #13100

Closed
wants to merge 6 commits into from

Conversation

promag
Copy link
Member

@promag promag commented Apr 26, 2018

This PR adds a menu entry Open Wallet to support loading existing wallets in the UI.

Fixes #7675.

@fanquake fanquake added the GUI label Apr 27, 2018
@ken2812221
Copy link
Contributor

ken2812221 commented Apr 27, 2018

If the wallet folder name contains Chinese, it will create a new folder that has same wallet file with a weird name on Windows, maybe the encoding issue (Not related)

Also, the seperator is incorrect on Windows
image

@promag
Copy link
Member Author

promag commented Apr 27, 2018

@ken2812221 does the problem exists if you use the RPC command?

@ken2812221
Copy link
Contributor

ken2812221 commented Apr 27, 2018

It shows wallet not found on RPC. (Not related)

@promag
Copy link
Member Author

promag commented Apr 27, 2018

@ken2812221 but it does exists right? What if you launch the application with -wallet=d:\...?

@ken2812221
Copy link
Contributor

ken2812221 commented Apr 27, 2018

-wallet=d:\錢包 does works, but the name displayed in Qt is incorrect
image

And it crash when I quit Qt

Checked that this isn't an issue on Linux.

@ryanofsky
Copy link
Contributor

ryanofsky commented Apr 27, 2018

Maybe windows or boost is using big5 encoding. which ends in a right square bracket ]

>>> '錢包'.encode('big5')
b'\xbf\xfa\xa5]'
>>> '錢包'.encode('big5').decode('utf8', 'replace')
'���]'

@promag
Copy link
Member Author

promag commented Apr 27, 2018

@ken2812221 thanks for the review and bug report. Let's move the bug discussion to #13103.

@@ -701,6 +707,20 @@ void BitcoinGUI::openClicked()
}
}

void BitcoinGUI::openWalletClicked()
{
QString fileName = QFileDialog::getExistingDirectory(this, tr("Open Wallet"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Use QDir::toNativeSeparators to convert / to \ on Windows

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link

Choose a reason for hiding this comment

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

^^

{
#ifdef ENABLE_WALLET
try {
std::string dummy_warning;
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems almost exactly duplicated from loadwallet() in rpcwallet.cpp. Does it make sense to factor it out to avoid repetition?

Copy link
Member Author

@promag promag Apr 30, 2018

Choose a reason for hiding this comment

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

Yeah, I would like to move to WalletManager

Copy link
Member Author

Choose a reason for hiding this comment

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

@jnewbery done in #9888dc2.

wallet->postInitProcess();
return { MakeWallet(*wallet), std::string() };
} catch (...) {
return { std::unique_ptr<Wallet>(), "ops" };
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why you're passing back an error string if it's always the string ops

Copy link
Member Author

Choose a reason for hiding this comment

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

Ops, it's unfinished. Not sure if it should return the pair.

Copy link
Member Author

@promag promag May 2, 2018

Choose a reason for hiding this comment

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

Removed, changed the return type.

QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if (fileName.isEmpty()) return;
const auto& result = m_node.loadWallet(fileName.toStdString());
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of auto here makes it difficult to understand the result.second below.

Copy link
Member Author

Choose a reason for hiding this comment

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

No an issue now, return value is not necessary.

@meshcollider
Copy link
Contributor

Concept ACK

if (fileName.isEmpty()) return;

std::vector<std::string> errors;
m_node.loadWallet(QDir::toNativeSeparators(fileName).toStdString(), errors);
Copy link
Member Author

Choose a reason for hiding this comment

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

@jnewbery @laanwj ATM the wallet is loaded in the UI thread, should I refactor to load it in the background?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's a good future enhancement. Not necessary in the initial version IMO.

@jnewbery
Copy link
Contributor

jnewbery commented May 3, 2018

Please update description to say that this fixes #7675

@jnewbery jnewbery added this to In progress in Multiwallet support May 3, 2018
@promag
Copy link
Member Author

promag commented May 4, 2018

Please update description to say that this fixes #7675

Done. Also rebased.

@promag promag force-pushed the 2018-04-ui-open-wallet branch 2 times, most recently from 8c9cf75 to 9170254 Compare May 23, 2018 11:56
@promag
Copy link
Member Author

promag commented May 23, 2018

Rebased on master.

@jnewbery
Copy link
Contributor

wallet_multiwallet.py fails

@maflcko maflcko changed the title Add menu entry to open wallet gui: Add menu entry to open wallet May 23, 2018
@promag
Copy link
Member Author

promag commented May 24, 2018

Rebased.

void BitcoinGUI::openWalletClicked()
{
QString fileName = QFileDialog::getExistingDirectory(this, tr("Open Wallet"),
QString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: start in the data directory for the current network (mainnet/testnet/regtest) instead of the home directory, since that's where the wallet files and folders will usually be (and because it may be difficult to traverse down into .bitcoin).

{
QString fileName = QFileDialog::getExistingDirectory(this, tr("Open Wallet"),
QString(),
QFileDialog::ShowDirsOnly
Copy link
Contributor

Choose a reason for hiding this comment

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

Why only show directories and not symlinks? Wallets can be .dat files.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right.

@DrahtBot
Copy link
Contributor

Needs rebase

@meshcollider
Copy link
Contributor

meshcollider commented Nov 3, 2018

It'd be nice to get this in to 0.18, is that feasible? Needs a rebase

Overall this is looking good, concept ACK with some code review, I'll review more once rebased/the comments above have been addressed and the WIP fixup commit is done

@fanquake fanquake added this to the 0.18.0 milestone Nov 10, 2018
@Sjors
Copy link
Member

Sjors commented Dec 10, 2018

For a followup, once #11082 is merged, we should add a wallet= entry to it once a wallet is created.

Noteable changes that may cause a headache during rebase:

@@ -330,6 +332,15 @@ void BitcoinGUI::createActions()
openAction = new QAction(platformStyle->TextColorIcon(":/icons/open"), tr("Open &URI..."), this);
openAction->setStatusTip(tr("Open a bitcoin: URI or payment request"));

m_new_wallet_action = new QAction(platformStyle->TextColorIcon(":/icons/open"), tr("New &Wallet"), this);
Copy link
Member

Choose a reason for hiding this comment

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

If we're going to use icons, I think they ought to be different...

@luke-jr
Copy link
Member

luke-jr commented Jan 2, 2019

Why is there a separate File and Wallet menu in the screenshot above? They should be the same menu...

@jonasschnelli
Copy link
Contributor

@promag: care to rebase/pick this up again?

@Sjors
Copy link
Member

Sjors commented Jan 17, 2019

A lot of this has been moved to smaller pull requests. E.g. there's now a separate PR for just the open wallet feature #15153. I suppose "unloading" a wallet would be fairly trivial on top of that.

For my own work on #14912 I'd love to have a (proof of concept) "create wallet" PR to build on top of. Ideally it would a dialog, with a check box for the read-only feature (and later for the empty wallet feature in #14938).

@jnewbery
Copy link
Contributor

Feature freeze is on Feb 15th. I'd really love to have this in v0.18.

@promag - any chance of a rebase so we can start testing & reviewing?

@promag
Copy link
Member Author

promag commented Jan 17, 2019

@jnewbery please see #15101 and then #15153.

jonasschnelli added a commit that referenced this pull request Jan 18, 2019
0dd9bde gui: Refactor to use WalletController (João Barbosa)
8fa271f gui: Add WalletController (João Barbosa)
cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa)

Pull request description:

  This PR is a subset of the work done in the context of #13100. This change consists in extracting from the application class the code that manages the wallet models.

  The role of the `WalletController` instance is to coordinate wallet operations and the window.

Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
@jnewbery
Copy link
Contributor

Can this PR be closed? I think all changes are covered by other PRs, and issue #13059 tracks the total progress.

@promag promag closed this Jan 18, 2019
@promag promag deleted the 2018-04-ui-open-wallet branch January 18, 2019 20:40
@promag
Copy link
Member Author

promag commented Jan 18, 2019

Thanks for updating that @jnewbery.

@jonasschnelli jonasschnelli removed this from In progress in Multiwallet support Jan 18, 2019
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 8, 2021
0dd9bde gui: Refactor to use WalletController (João Barbosa)
8fa271f gui: Add WalletController (João Barbosa)
cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa)

Pull request description:

  This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models.

  The role of the `WalletController` instance is to coordinate wallet operations and the window.

Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 10, 2021
0dd9bde gui: Refactor to use WalletController (João Barbosa)
8fa271f gui: Add WalletController (João Barbosa)
cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa)

Pull request description:

  This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models.

  The role of the `WalletController` instance is to coordinate wallet operations and the window.

Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 10, 2021
0dd9bde gui: Refactor to use WalletController (João Barbosa)
8fa271f gui: Add WalletController (João Barbosa)
cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa)

Pull request description:

  This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models.

  The role of the `WalletController` instance is to coordinate wallet operations and the window.

Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 18, 2021
0dd9bde gui: Refactor to use WalletController (João Barbosa)
8fa271f gui: Add WalletController (João Barbosa)
cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa)

Pull request description:

  This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models.

  The role of the `WalletController` instance is to coordinate wallet operations and the window.

Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 18, 2021
0dd9bde gui: Refactor to use WalletController (João Barbosa)
8fa271f gui: Add WalletController (João Barbosa)
cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa)

Pull request description:

  This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models.

  The role of the `WalletController` instance is to coordinate wallet operations and the window.

Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 18, 2021
0dd9bde gui: Refactor to use WalletController (João Barbosa)
8fa271f gui: Add WalletController (João Barbosa)
cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa)

Pull request description:

  This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models.

  The role of the `WalletController` instance is to coordinate wallet operations and the window.

Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
thelazier pushed a commit to thelazier/dash that referenced this pull request Sep 25, 2021
0dd9bde gui: Refactor to use WalletController (João Barbosa)
8fa271f gui: Add WalletController (João Barbosa)
cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa)

Pull request description:

  This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models.

  The role of the `WalletController` instance is to coordinate wallet operations and the window.

Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qt GUI Feature Request: Load wallet file