mirror of
https://github.com/lil-org/wallet.git
synced 2025-01-04 02:24:39 +03:00
Export private keys
This commit is contained in:
parent
8447c74ec8
commit
81e9bcbd96
@ -50,6 +50,7 @@
|
||||
2CC0CDBE2692027E0072922A /* PriceService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CC0CDBD2692027E0072922A /* PriceService.swift */; };
|
||||
2CC8946F269A2E8C00879245 /* SessionStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CC8946E269A2E8C00879245 /* SessionStorage.swift */; };
|
||||
2CC89471269A334A00879245 /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CC89470269A334A00879245 /* UserDefaults.swift */; };
|
||||
2CD0B3F526A0DAA900488D92 /* NSPasteboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD0B3F426A0DAA900488D92 /* NSPasteboard.swift */; };
|
||||
2CDAB3722675B3F0009F8B97 /* PasswordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CDAB3712675B3F0009F8B97 /* PasswordViewController.swift */; };
|
||||
2CE3D012267F73C00032A62E /* Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CE3D011267F73C00032A62E /* Transaction.swift */; };
|
||||
2CE3D015267F73E80032A62E /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CE3D014267F73E80032A62E /* Account.swift */; };
|
||||
@ -101,6 +102,7 @@
|
||||
2CC0CDBD2692027E0072922A /* PriceService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PriceService.swift; sourceTree = "<group>"; };
|
||||
2CC8946E269A2E8C00879245 /* SessionStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionStorage.swift; sourceTree = "<group>"; };
|
||||
2CC89470269A334A00879245 /* UserDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaults.swift; sourceTree = "<group>"; };
|
||||
2CD0B3F426A0DAA900488D92 /* NSPasteboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSPasteboard.swift; sourceTree = "<group>"; };
|
||||
2CDAB3712675B3F0009F8B97 /* PasswordViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordViewController.swift; sourceTree = "<group>"; };
|
||||
2CE3D011267F73C00032A62E /* Transaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Transaction.swift; sourceTree = "<group>"; };
|
||||
2CE3D014267F73E80032A62E /* Account.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Account.swift; sourceTree = "<group>"; };
|
||||
@ -204,6 +206,7 @@
|
||||
children = (
|
||||
2C6706A4267A6BFE006AAEF2 /* Bundle.swift */,
|
||||
2C03D1D4269B428C00EF10EA /* Notification.swift */,
|
||||
2CD0B3F426A0DAA900488D92 /* NSPasteboard.swift */,
|
||||
2CC89470269A334A00879245 /* UserDefaults.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
@ -436,6 +439,7 @@
|
||||
0DB729142674E2DB0011F7A1 /* EIP712Parameter.swift in Sources */,
|
||||
2C901C4D268A033100D0926A /* GasService.swift in Sources */,
|
||||
2C528A16267FA8EB00CA3ADD /* Defaults.swift in Sources */,
|
||||
2CD0B3F526A0DAA900488D92 /* NSPasteboard.swift in Sources */,
|
||||
2CE3D015267F73E80032A62E /* Account.swift in Sources */,
|
||||
2CE3D012267F73C00032A62E /* Transaction.swift in Sources */,
|
||||
0DB7291B2674E2DB0011F7A1 /* EIP712Hash.swift in Sources */,
|
||||
|
@ -36,6 +36,8 @@ class AccountsListViewController: NSViewController {
|
||||
|
||||
let menu = NSMenu()
|
||||
menu.addItem(NSMenuItem(title: "Copy address", action: #selector(didClickCopyAddress(_:)), keyEquivalent: ""))
|
||||
menu.addItem(.separator())
|
||||
menu.addItem(NSMenuItem(title: "Show private key", action: #selector(didClickExportAccount(_:)), keyEquivalent: "")) // TODO: show different texts for secret words export
|
||||
menu.addItem(NSMenuItem(title: "Remove account", action: #selector(didClickRemoveAccount(_:)), keyEquivalent: ""))
|
||||
tableView.menu = menu
|
||||
|
||||
@ -100,9 +102,7 @@ class AccountsListViewController: NSViewController {
|
||||
@objc private func didClickCopyAddress(_ sender: AnyObject) {
|
||||
let row = tableView.clickedRow
|
||||
guard row >= 0 else { return }
|
||||
let pasteboard = NSPasteboard.general
|
||||
pasteboard.clearContents()
|
||||
pasteboard.setString(accounts[row].address, forType: .string)
|
||||
NSPasteboard.general.clearAndSetString(accounts[row].address)
|
||||
}
|
||||
|
||||
@objc private func didClickRemoveAccount(_ sender: AnyObject) {
|
||||
@ -114,7 +114,6 @@ class AccountsListViewController: NSViewController {
|
||||
alert.addButton(withTitle: "Remove anyway")
|
||||
alert.addButton(withTitle: "Cancel")
|
||||
if alert.runModal() == .alertFirstButtonReturn {
|
||||
guard row >= 0 else { return }
|
||||
agent.askAuthentication(on: view.window, getBackTo: self, onStart: false, reason: "Remove account") { [weak self] allowed in
|
||||
Window.activateWindow(self?.view.window)
|
||||
if allowed {
|
||||
@ -124,6 +123,38 @@ class AccountsListViewController: NSViewController {
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func didClickExportAccount(_ sender: AnyObject) {
|
||||
// TODO: show different texts for secret words export
|
||||
let row = tableView.clickedRow
|
||||
guard row >= 0 else { return }
|
||||
let alert = Alert()
|
||||
alert.messageText = "Private key gives full access to your funds."
|
||||
alert.alertStyle = .critical
|
||||
alert.addButton(withTitle: "I understand the risks")
|
||||
alert.addButton(withTitle: "Cancel")
|
||||
if alert.runModal() == .alertFirstButtonReturn {
|
||||
agent.askAuthentication(on: view.window, getBackTo: self, onStart: false, reason: "Show private key") { [weak self] allowed in
|
||||
Window.activateWindow(self?.view.window)
|
||||
if allowed {
|
||||
self?.showPrivateKey(index: row)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func showPrivateKey(index: Int) {
|
||||
let privateKey = accounts[index].privateKey
|
||||
let alert = Alert()
|
||||
alert.messageText = "Private key"
|
||||
alert.informativeText = privateKey
|
||||
alert.alertStyle = .informational
|
||||
alert.addButton(withTitle: "OK")
|
||||
alert.addButton(withTitle: "Copy")
|
||||
if alert.runModal() != .alertFirstButtonReturn {
|
||||
NSPasteboard.general.clearAndSetString(privateKey)
|
||||
}
|
||||
}
|
||||
|
||||
private func showInstructionsAlert() {
|
||||
let alert = Alert()
|
||||
alert.messageText = "How to start?"
|
||||
|
Loading…
Reference in New Issue
Block a user