From e36b166edde49f5943e745137c1796beccdb08bb Mon Sep 17 00:00:00 2001 From: tobtoht Date: Sat, 24 Apr 2021 05:51:19 +0200 Subject: [PATCH 1/2] Wallet: import / export output function --- src/libwalletqt/Wallet.cpp | 8 ++++++++ src/libwalletqt/Wallet.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index f7cc1965..82b101b1 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -499,6 +499,14 @@ bool Wallet::importKeyImages(const QString& path) return m_walletImpl->importKeyImages(path.toStdString()); } +bool Wallet::exportOutputs(const QString& path, bool all) { + return m_walletImpl->exportOutputs(path.toStdString(), all); +} + +bool Wallet::importOutputs(const QString& path) { + return m_walletImpl->importOutputs(path.toStdString()); +} + bool Wallet::refresh(bool historyAndSubaddresses /* = true */) { refreshingSet(true); diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index e0157ee3..e1d19914 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -208,6 +208,10 @@ public: Q_INVOKABLE bool exportKeyImages(const QString& path); Q_INVOKABLE bool importKeyImages(const QString& path); + //! export/import outputs + Q_INVOKABLE bool exportOutputs(const QString& path, bool all = false); + Q_INVOKABLE bool importOutputs(const QString& path); + //! refreshes the wallet Q_INVOKABLE bool refresh(bool historyAndSubaddresses = true); From 36940f07c9de9a2acbe64771f64646002c739a1c Mon Sep 17 00:00:00 2001 From: selsta Date: Sat, 24 Apr 2021 06:10:52 +0200 Subject: [PATCH 2/2] Transfer: add support for outputs import / export --- pages/Transfer.qml | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/pages/Transfer.qml b/pages/Transfer.qml index 1b1a8260..fe232dee 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -898,6 +898,32 @@ Rectangle { } } + AdvancedOptionsItem { + visible: persistentSettings.transferShowAdvanced && appWindow.walletMode >= 2 + title: qsTr("Outputs") + translationManager.emptyString + button1.text: qsTr("Export") + translationManager.emptyString + button1.enabled: appWindow.viewOnly + button1.onClicked: { + console.log("Transfer: export outputs clicked") + exportOutputsDialog.open(); + } + button2.text: qsTr("Import") + translationManager.emptyString + button2.enabled: !appWindow.viewOnly + button2.onClicked: { + console.log("Transfer: import outputs clicked") + importOutputsDialog.open(); + } + tooltip: { + var header = qsTr("Required for cold wallets to sign their corresponding key images") + translationManager.emptyString; + return "" + + "
" + header + "
" + + "

" + qsTr("1. Using view-only wallet, export the outputs into a file") + "

" + + "

" + qsTr("2. Using cold wallet, import the outputs file") + "

" + + translationManager.emptyString + } + } + AdvancedOptionsItem { visible: persistentSettings.transferShowAdvanced && appWindow.walletMode >= 2 title: qsTr("Key images") + translationManager.emptyString @@ -1072,6 +1098,41 @@ Rectangle { } + FileDialog { + id: exportOutputsDialog + selectMultiple: false + selectExisting: false + onAccepted: { + console.log(walletManager.urlToLocalPath(exportOutputsDialog.fileUrl)) + if (currentWallet.exportOutputs(walletManager.urlToLocalPath(exportOutputsDialog.fileUrl), true)) { + appWindow.showStatusMessage(qsTr("Outputs successfully exported to file") + translationManager.emptyString, 3); + } else { + appWindow.showStatusMessage(currentWallet.errorString, 5); + } + } + onRejected: { + console.log("Canceled"); + } + } + + FileDialog { + id: importOutputsDialog + selectMultiple: false + selectExisting: true + title: qsTr("Please choose a file") + translationManager.emptyString + onAccepted: { + console.log(walletManager.urlToLocalPath(importOutputsDialog.fileUrl)) + if (currentWallet.importOutputs(walletManager.urlToLocalPath(importOutputsDialog.fileUrl))) { + appWindow.showStatusMessage(qsTr("Outputs successfully imported to wallet") + translationManager.emptyString, 3); + } else { + appWindow.showStatusMessage(currentWallet.errorString, 5); + } + } + onRejected: { + console.log("Canceled"); + } + } + //ExportKeyImagesDialog FileDialog { id: exportKeyImagesDialog