Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
feat(wallet): require confirm before deleting wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Dec 12, 2018
1 parent e7e9d2b commit c0a7c72
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion app/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,34 @@ async function deleteLocalWallet(chain, network, wallet) {
}

const walletDir = join(remote.app.getPath('userData'), 'lnd', chain, network, wallet)
return await fsRimraf(walletDir)

return new Promise((resolve, reject) => {
remote.dialog.showMessageBox(
{
/* eslint-disable max-len */
type: 'warning',
message: 'Are you sure you want to delete this wallet?',
detail: `Deleting this wallet will remove all data from the wallet directory:\n\n${walletDir}\n\nThis action cannot be undone!\n\nPlease ensure that you have access to your wallet backup seed before proceeding.`,
checkboxLabel: `Yes, delete this wallet`,
cancelId: 1,
buttons: ['Delete', 'Cancel'],
defaultId: 0
},
async (choice, checkboxChecked) => {
if (choice === 0) {
if (checkboxChecked) {
await fsRimraf(walletDir)
return resolve()
} else {
remote.dialog.showErrorBox(
'Wallet not deleted',
'The wallet was not deleted as you did not select the confirmation checkbox.'
)
}
} else {
return reject()
}
}
)
})
}

0 comments on commit c0a7c72

Please sign in to comment.