mirror of
https://github.com/oxen-io/oxen-electron-gui-wallet.git
synced 2023-12-14 06:13:02 +01:00
added export_key_images function
This commit is contained in:
parent
e22cdc978c
commit
cb32e3ca78
|
@ -8,6 +8,7 @@ const crypto = require("crypto");
|
|||
export class WalletRPC {
|
||||
constructor(backend) {
|
||||
this.backend = backend
|
||||
this.data_dir = null
|
||||
this.wallet_dir = null
|
||||
this.auth = []
|
||||
this.id = 0
|
||||
|
@ -76,6 +77,8 @@ export class WalletRPC {
|
|||
|
||||
let log_file
|
||||
|
||||
this.data_dir = options.app.data_dir
|
||||
|
||||
if(options.app.testnet) {
|
||||
this.testnet = true
|
||||
this.wallet_dir = path.join(options.app.data_dir, "testnet", "wallets")
|
||||
|
@ -223,6 +226,10 @@ export class WalletRPC {
|
|||
this.getPrivateKeys(params.password)
|
||||
break
|
||||
|
||||
case "export_key_images":
|
||||
this.exportKeyImages()
|
||||
break
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
@ -906,6 +913,26 @@ export class WalletRPC {
|
|||
}
|
||||
|
||||
|
||||
exportKeyImages(filepath=null) {
|
||||
this.sendRPC("export_key_images").then((data) => {
|
||||
if(data.hasOwnProperty("error") || !data.hasOwnProperty("result")) {
|
||||
this.sendGateway("show_notification", {type: "negative", message: "Error exporting key images", timeout: 2000})
|
||||
return
|
||||
}
|
||||
|
||||
if(filepath == null)
|
||||
filepath = path.join(this.data_dir, "gui", "key_image_export.json")
|
||||
|
||||
fs.writeFile(filepath, JSON.stringify(data.result), "utf8", (err) => {
|
||||
if(err) {
|
||||
this.sendGateway("show_notification", {type: "negative", message: "Error writing key images to file", timeout: 2000})
|
||||
return
|
||||
}
|
||||
this.sendGateway("show_notification", {message: "Key images exported to "+filepath, timeout: 2000})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
listWallets(legacy=false) {
|
||||
|
||||
let wallets = {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ipcRenderer } from "electron"
|
||||
import { Dialog, Loading } from "quasar"
|
||||
import { Notify, Dialog, Loading } from "quasar"
|
||||
import { SCEE } from "./SCEE-Node";
|
||||
import * as WebSocket from "ws"
|
||||
|
||||
|
@ -118,6 +118,15 @@ export class Gateway {
|
|||
this.confirmClose("Changes require restart. Would you like to exit now?")
|
||||
break
|
||||
|
||||
case "show_notification":
|
||||
let notification = {
|
||||
type: "positive",
|
||||
timeout: 1000,
|
||||
message: ""
|
||||
}
|
||||
Notify.create(Object.assign(notification, decrypted_data.data))
|
||||
break
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,13 +22,31 @@
|
|||
|
||||
<div class="infoBox q-pt-md">
|
||||
<q-btn
|
||||
:disable="!is_ready"
|
||||
flat @click="getPrivateKeys()">Show seed words</q-btn>
|
||||
:disable="!is_ready"
|
||||
flat @click="getPrivateKeys()">Show seed words</q-btn>
|
||||
<q-btn
|
||||
:disable="!is_ready"
|
||||
flat @click="rescan_modal_show = true">Rescan Wallet</q-btn>
|
||||
</div>
|
||||
:disable="!is_ready"
|
||||
flat @click="rescan_modal_show = true">Rescan Wallet</q-btn>
|
||||
|
||||
<q-btn icon="more_vert" label="" size="md" flat>
|
||||
<q-popover>
|
||||
<q-list separator link>
|
||||
<q-item v-close-overlay @click.native="export_modal_show = true">
|
||||
<q-item-main>
|
||||
<q-item-tile label>Export Key Images</q-item-tile>
|
||||
</q-item-main>
|
||||
</q-item>
|
||||
<q-item v-close-overlay @click.native="importKeyImages">
|
||||
<q-item-main>
|
||||
<q-item-tile label>Import Key Images</q-item-tile>
|
||||
</q-item-main>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-popover>
|
||||
|
||||
</q-btn>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -58,10 +76,10 @@
|
|||
<p>{{ secret.spend_key }}</p>
|
||||
|
||||
<q-btn
|
||||
color="primary"
|
||||
@click="private_keys_modal_show = false"
|
||||
label="Close"
|
||||
/>
|
||||
color="primary"
|
||||
@click="private_keys_modal_show = false"
|
||||
label="Close"
|
||||
/>
|
||||
</div>
|
||||
</q-modal>
|
||||
|
||||
|
@ -79,16 +97,49 @@
|
|||
<q-radio v-model="rescan_type" val="spent" label="Rescan spent outputs" />
|
||||
</div>
|
||||
|
||||
<div class="q-mt-xl text-right">
|
||||
<q-btn
|
||||
flat class="q-mr-sm"
|
||||
@click="rescan_modal_show = false"
|
||||
label="Close"
|
||||
/>
|
||||
<q-btn
|
||||
color="primary"
|
||||
@click="rescanWallet()"
|
||||
label="Rescan"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</q-modal>
|
||||
|
||||
<q-modal minimized v-model="export_modal_show">
|
||||
<div class="q-ma-md">
|
||||
|
||||
<h4 class="q-mt-lg q-mb-md">Export key images</h4>
|
||||
<p>Select file location for export.</p>
|
||||
|
||||
<q-field>
|
||||
<div class="row gutter-sm">
|
||||
<div class="col-8">
|
||||
<q-input v-model="key_image_path" stack-label="Key image output directory" disable />
|
||||
<input type="file" webkitdirectory directory id="keyImagePath" v-on:change="setKeyImagePath" ref="fileInput" hidden />
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<q-btn v-on:click="selectFile">Browse</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</q-field>
|
||||
|
||||
<div class="q-mt-xl text-right">
|
||||
<q-btn
|
||||
flat class="q-mr-sm"
|
||||
@click="rescan_modal_show = false"
|
||||
@click="export_modal_show = false"
|
||||
label="Close"
|
||||
/>
|
||||
<q-btn
|
||||
color="primary"
|
||||
@click="rescanWallet()"
|
||||
label="Rescan"
|
||||
@click="exportKeyImages()"
|
||||
label="Export"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -115,7 +166,9 @@ export default {
|
|||
spinner: false,
|
||||
private_keys_modal_show: false,
|
||||
rescan_modal_show: false,
|
||||
rescan_type: "full"
|
||||
rescan_type: "full",
|
||||
key_image_path: null,
|
||||
export_modal_show: false,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -123,7 +176,6 @@ export default {
|
|||
handler(val, old) {
|
||||
if(val.view_key == old.view_key) return
|
||||
this.spinner = false
|
||||
console.log(this.secret.view_key)
|
||||
switch(this.secret.view_key) {
|
||||
case "":
|
||||
break
|
||||
|
@ -189,6 +241,16 @@ export default {
|
|||
} else {
|
||||
this.$gateway.send("wallet", "rescan_spent")
|
||||
}
|
||||
},
|
||||
selectFile () {
|
||||
this.$refs.fileInput.click()
|
||||
},
|
||||
setKeyImagePath (file) {
|
||||
this.key_image_path = file.target.files[0].path
|
||||
},
|
||||
exportKeyImages () {
|
||||
this.export_modal_show = false
|
||||
this.$gateway.send("wallet", "export_key_images", {path: this.key_image_path})
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
Loading…
Reference in a new issue