Fixed wallet to use the default wallet location

if available, rather than asking for a location
This commit is contained in:
Cheng 2023-10-29 05:37:33 +00:00
parent 1d7ce60cf7
commit 3d805aa7c5
No known key found for this signature in database
GPG Key ID: 571C3A9C3B9E6FCA

View File

@ -374,6 +374,10 @@ COMMIT;
void Frame::OnSaveNew(wxCommandEvent& WXUNUSED(event))
{
wxFileName wxFileWallet;
if (m_DefaultWalletLocation.FileExists()) {
// OK, the default wallet exists, so we need a new
// name and wallet location
wxString wxstrWalletPath;
wxString wxstrWalletName(wxEmptyString);
if (!m_LastUsedWallet.IsOk() || !m_LastUsedWallet.DirExists()) {
@ -404,15 +408,25 @@ void Frame::OnSaveNew(wxCommandEvent& WXUNUSED(event))
dialog.GetPath(),
dialog.GetFilterIndex()
);
wxFileName wxFileWallet(dialog.GetPath());
ristretto255::hash<256> WalletSecret( wxFileWallet.GetFullPath().ToUTF8());
wxFileWallet.Assign(dialog.GetPath());
m_FileDialogFilterIndex = dialog.GetFilterIndex();
}
}
else {
// Default does not exist, so we go right
// ahead without asking the user to invent
// a name and select a directory
RecursiveCreateDirectory(m_DefaultWalletLocation);
wxFileWallet = m_DefaultWalletLocation;
}
if (wxFileWallet.IsOk()) {
ristretto255::hash<256> WalletSecret(wxFileWallet.GetFullPath().ToUTF8());
NewWallet(wxFileWallet, WalletSecret);
wxLogMessage("new wallet created: %s", wxFileWallet.GetFullPath());
if (m_panel)m_panel->Close(true);
m_panel = nullptr;
auto panel = new display_wallet(this, wxFileWallet);
m_panel = panel;
m_FileDialogFilterIndex = dialog.GetFilterIndex();
m_LastUsedWallet = wxFileWallet; //We do this last, so that if an exception occurs the filename is forgotten.
}
}