-
Notifications
You must be signed in to change notification settings - Fork 302
Fix "Load PSBT" functionality when no wallet loaded #399
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,18 @@ | |
|
||
#include <qt/walletframe.h> | ||
|
||
#include <node/ui_interface.h> | ||
#include <psbt.h> | ||
#include <qt/guiutil.h> | ||
#include <qt/overviewpage.h> | ||
#include <qt/psbtoperationsdialog.h> | ||
#include <qt/walletmodel.h> | ||
#include <qt/walletview.h> | ||
|
||
#include <cassert> | ||
|
||
#include <QApplication> | ||
#include <QClipboard> | ||
#include <QGroupBox> | ||
#include <QHBoxLayout> | ||
#include <QLabel> | ||
|
@@ -184,10 +190,40 @@ void WalletFrame::gotoVerifyMessageTab(QString addr) | |
|
||
void WalletFrame::gotoLoadPSBT(bool from_clipboard) | ||
{ | ||
WalletView *walletView = currentWalletView(); | ||
if (walletView) { | ||
walletView->gotoLoadPSBT(from_clipboard); | ||
std::string data; | ||
|
||
if (from_clipboard) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Add an empty line above as it was in |
||
std::string raw = QApplication::clipboard()->text().toStdString(); | ||
bool invalid; | ||
data = DecodeBase64(raw, &invalid); | ||
if (invalid) { | ||
Q_EMIT message(tr("Error"), tr("Unable to decode PSBT from clipboard (invalid base64)"), CClientUIInterface::MSG_ERROR); | ||
return; | ||
} | ||
} else { | ||
QString filename = GUIUtil::getOpenFileName(this, | ||
tr("Load Transaction Data"), QString(), | ||
tr("Partially Signed Transaction (*.psbt)"), nullptr); | ||
if (filename.isEmpty()) return; | ||
if (GetFileSize(filename.toLocal8Bit().data(), MAX_FILE_SIZE_PSBT) == MAX_FILE_SIZE_PSBT) { | ||
Q_EMIT message(tr("Error"), tr("PSBT file must be smaller than 100 MiB"), CClientUIInterface::MSG_ERROR); | ||
return; | ||
} | ||
std::ifstream in(filename.toLocal8Bit().data(), std::ios::binary); | ||
data = std::string(std::istreambuf_iterator<char>{in}, {}); | ||
} | ||
|
||
std::string error; | ||
PartiallySignedTransaction psbtx; | ||
if (!DecodeRawPSBT(psbtx, data, error)) { | ||
Q_EMIT message(tr("Error"), tr("Unable to decode PSBT") + "\n" + QString::fromStdString(error), CClientUIInterface::MSG_ERROR); | ||
return; | ||
} | ||
|
||
PSBTOperationsDialog* dlg = new PSBTOperationsDialog(this, currentWalletModel(), clientModel); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Add an empty line above as it was in |
||
dlg->openWithPSBT(psbtx); | ||
dlg->setAttribute(Qt::WA_DeleteOnClose); | ||
dlg->exec(); | ||
} | ||
|
||
void WalletFrame::encryptWallet() | ||
|
Uh oh!
There was an error while loading. Please reload this page.