Permalink
Browse files

removed delete wallet entirely

  • Loading branch information...
1 parent 537d749 commit fd4cc7f2e771874554993243bec641d891d8c8ac @jim618 jim618 committed Dec 14, 2013
View
@@ -25,27 +25,6 @@ All these options are set in the main control file `multibit.properties`. MultiB
Wherever this file is found, that directory is used as the application data directory for Multibit.
-#### Show Delete Wallet
-
-To enable the display in the File menu of the 'Delete Wallet' option, do the following:
-1. Shutdown MultiBit.
-2. Locate the file "multibit.properties" in your installation directory
-3. Edit this file to include a setting of: showDeleteWallet=true
-4. Save the file and restart MultiBit.
-5. The File | Delete menu option should now be available - use it at your own risk.
-
-When deleting a wallet, to avoid accidental deletion, MultiBit asks you:
-```
-"To confirm this action enter the name of the creator of Bitcoin"
-```
-The answer is:
-```
-satoshi nakamoto
-```
-
-Note that when a wallet is deleted the wallet data directory and all the wallet backups are NOT deleted.
-You have to [securely delete (shred)](http://superuser.com/questions/86824/how-to-secure-delete-file-or-folder-in-windows) this directory manually (as long as you are sure you do not
-need them).
#### Connect to specific peers
@@ -32,7 +32,6 @@
import org.multibit.exchange.TickerTimerTask;
import org.multibit.message.Message;
import org.multibit.message.MessageManager;
-import org.multibit.model.bitcoin.BitcoinModel;
import org.multibit.model.bitcoin.WalletBusyListener;
import org.multibit.model.bitcoin.WalletData;
import org.multibit.model.core.StatusEnum;
@@ -247,9 +246,6 @@ public MultiBitFrame(CoreController coreController, BitcoinController bitcoinCon
ToolTipManager.sharedInstance().setDismissDelay(TOOLTIP_DISMISSAL_DELAY);
- // TODO Examine how this fits in with the controller onQuit() event
- // Cam: I've moved this to the quit event.
-
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent arg0) {
@@ -801,19 +797,6 @@ private void addMenuBar(GridBagConstraints constraints, Container contentPane) {
fileMenu.addSeparator();
- // See if user has enabled the delete wallet action
- String showDeleteWalletString = this.bitcoinController.getModel().getUserPreference(BitcoinModel.SHOW_DELETE_WALLET);
- if (Boolean.TRUE.toString().equalsIgnoreCase(showDeleteWalletString)) {
- DeleteWalletAction deleteWalletAction = new DeleteWalletAction(this.bitcoinController,
- ImageLoader.createImageIcon(ImageLoader.DELETE_WALLET_ICON_FILE), this);
- menuItem = new JMenuItem(deleteWalletAction);
- menuItem.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont());
- menuItem.setComponentOrientation(componentOrientation);
- fileMenu.add(menuItem);
-
- fileMenu.addSeparator();
- }
-
// Add password action.
addPasswordAction = new MultiBitWalletBusyAction(this.bitcoinController, ImageLoader.ADD_PASSWORD_ICON_FILE, "addPasswordAction.text",
"addPasswordAction.tooltip", "addPasswordAction.mnemonic", View.ADD_PASSWORD_VIEW);
@@ -1,66 +0,0 @@
-/**
- * Copyright 2012 multibit.org
- *
- * Licensed under the MIT license (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://opensource.org/licenses/mit-license.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.multibit.viewsystem.swing.action;
-
-import java.awt.Cursor;
-import java.awt.event.ActionEvent;
-
-import javax.swing.Action;
-import javax.swing.ImageIcon;
-
-import org.multibit.controller.Controller;
-import org.multibit.controller.bitcoin.BitcoinController;
-import org.multibit.viewsystem.swing.MultiBitFrame;
-import org.multibit.viewsystem.swing.view.dialogs.DeleteWalletConfirmDialog;
-import org.multibit.viewsystem.swing.view.panels.HelpContentsPanel;
-
-/**
- * This {@link Action} show the delete wallet confirmation dialog.
- */
-public class DeleteWalletAction extends MultiBitSubmitAction {
- private static final long serialVersionUID = 1923933460523457765L;
-
- private MultiBitFrame mainFrame;
-
- /**
- * Creates a new {@link DeleteWalletAction}.
- */
- public DeleteWalletAction(BitcoinController bitcoinController, ImageIcon icon, MultiBitFrame mainFrame) {
- super(bitcoinController, "deleteWalletAction.text", "deleteWalletAction.tooltip", "deleteWalletAction.mnemonicKey", icon);
- this.mainFrame = mainFrame;
- putValue(SHORT_DESCRIPTION, HelpContentsPanel.createTooltipTextForMenuItem(controller.getLocaliser().getString("deleteWalletAction.tooltip")));
- }
-
- /**
- * prompt for deletion of a wallet
- */
- @Override
- public void actionPerformed(ActionEvent e) {
- if (abort()) {
- return;
- }
- mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- setEnabled(false);
-
- try {
- DeleteWalletConfirmDialog deleteWalletConfirmDialog = new DeleteWalletConfirmDialog(super.bitcoinController, mainFrame);
- deleteWalletConfirmDialog.setVisible(true);
- } finally {
- setEnabled(true);
- mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-}
@@ -1,209 +0,0 @@
-/**
- * Copyright 2012 multibit.org
- *
- * Licensed under the MIT license (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://opensource.org/licenses/mit-license.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.multibit.viewsystem.swing.action;
-
-import java.awt.event.ActionEvent;
-import java.io.IOException;
-import java.util.List;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ImageIcon;
-
-import org.multibit.controller.Controller;
-import org.multibit.controller.bitcoin.BitcoinController;
-import org.multibit.file.DeleteWalletException;
-import org.multibit.file.FileHandler;
-import org.multibit.file.WalletLoadException;
-import org.multibit.model.bitcoin.WalletData;
-import org.multibit.store.WalletVersionException;
-import org.multibit.viewsystem.swing.view.dialogs.DeleteWalletConfirmDialog;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This {@link Action} deletes a wallet.
- */
-public class DeleteWalletSubmitAction extends AbstractAction {
-
- private static final Logger log = LoggerFactory.getLogger(DeleteWalletSubmitAction.class);
-
- private static final long serialVersionUID = 1923933460523457765L;
-
- private final Controller controller;
- private final BitcoinController bitcoinController;
-
- private DeleteWalletConfirmDialog deleteWalletConfirmDialog;
-
- /**
- * Creates a new {@link DeleteWalletSubmitAction}.
- */
- public DeleteWalletSubmitAction(BitcoinController bitcoinController, ImageIcon icon, DeleteWalletConfirmDialog deleteWalletConfirmDialog) {
- super(bitcoinController.getLocaliser().getString("deleteWalletAction.text"), icon);
-
- this.bitcoinController = bitcoinController;
- this.controller = this.bitcoinController;
-
- this.deleteWalletConfirmDialog = deleteWalletConfirmDialog;
-
- MnemonicUtil mnemonicUtil = new MnemonicUtil(controller.getLocaliser());
- putValue(SHORT_DESCRIPTION, controller.getLocaliser().getString("deleteWalletAction.tooltip"));
- putValue(MNEMONIC_KEY, mnemonicUtil.getMnemonic("deleteWalletAction.mnemonicKey"));
- }
-
- /**
- * Deletes the wallet and updates the dialog.
- */
- @Override
- public void actionPerformed(ActionEvent e) {
- try {
- String answer = null;
-
- if (deleteWalletConfirmDialog != null) {
- answer = deleteWalletConfirmDialog.getAnswer();
- }
-
- if (answer == null || !"satoshi nakamoto".equalsIgnoreCase(answer.trim())) {
- if (deleteWalletConfirmDialog != null) {
- deleteWalletConfirmDialog.getExplainLabel().setText(" ");
- deleteWalletConfirmDialog.setDeleteConfirmText(
- controller.getLocaliser().getString("deleteWalletConfirmDialog.wrongAnswer"), " ");
- }
- return;
- }
- String walletDescription = bitcoinController.getModel().getActivePerWalletModelData().getWalletDescription();
-
- // Work out which wallet to select after the wallet is removed.
- String activeWalletFilename = bitcoinController.getModel().getActivePerWalletModelData().getWalletFilename();
-
- List<WalletData> perWalletModelDataList = bitcoinController.getModel().getPerWalletModelDataList();
- int numberOfOpenWalletsBefore = perWalletModelDataList.size();
- int positionInList = -1;
- for (int i = 0; i < numberOfOpenWalletsBefore; i++) {
- if (activeWalletFilename.equals(perWalletModelDataList.get(i).getWalletFilename())) {
- positionInList = i;
- break;
- }
- }
-
- // By default select the first wallet.
- int newWalletToSelect = 0;
-
- if (numberOfOpenWalletsBefore > 1) {
- // If deleting the last, then select the new last one.
- if (positionInList == numberOfOpenWalletsBefore - 1) {
- newWalletToSelect = numberOfOpenWalletsBefore - 2;
- } else {
- // Select the same position in the list
- newWalletToSelect = positionInList;
- }
- } else {
- // One wallet open before. One auto created after.
- }
-
- // Delete the wallet.
- deleteWallet(bitcoinController.getModel().getActivePerWalletModelData());
-
- // Set the new Wallet to be the active wallet.
- if (!this.bitcoinController.getModel().getPerWalletModelDataList().isEmpty()) {
- WalletData firstPerWalletModelData = this.bitcoinController.getModel().getPerWalletModelDataList().get(newWalletToSelect);
- this.bitcoinController.getModel().setActiveWalletByFilename(firstPerWalletModelData.getWalletFilename());
- } else {
- // No wallets are selected.
- // Clear all the views
- // Should not happen as one is auto created.
- }
-
- if (deleteWalletConfirmDialog != null) {
- deleteWalletConfirmDialog.getExplainLabel().setText(" ");
- deleteWalletConfirmDialog.setDeleteConfirmText(
- bitcoinController.getLocaliser().getString("deleteWalletConfirmDialog.walletDeletedOk",
- new Object[] { walletDescription }), " " );
- }
- } catch (WalletLoadException wle) {
- log.error(wle.getClass().getName() + " " + wle.getMessage());
- if (wle.getCause() != null) {
- log.error(wle.getClass().getName() + ", cause = " + wle.getCause().getMessage());
- }
- deleteWalletConfirmDialog.getExplainLabel().setText(" ");
- deleteWalletConfirmDialog.setDeleteConfirmText(controller.getLocaliser().getString("deleteWalletConfirmDialog.walletDeleteError1"), controller
- .getLocaliser().getString("deleteWalletConfirmDialog.walletDeleteError2", new Object[] { wle.getMessage() }));
- } catch (WalletVersionException wve) {
- log.error(wve.getClass().getName() + " " + wve.getMessage());
- if (wve.getCause() != null) {
- log.error(wve.getClass().getName() + ", cause = " + wve.getCause().getMessage());
- }
- deleteWalletConfirmDialog.getExplainLabel().setText(" ");
- deleteWalletConfirmDialog.setDeleteConfirmText(controller.getLocaliser().getString("deleteWalletConfirmDialog.walletDeleteError1"), controller
- .getLocaliser().getString("deleteWalletConfirmDialog.walletDeleteError2", new Object[] { wve.getMessage() }));
- } catch (DeleteWalletException dwe) {
- log.error(dwe.getClass().getName() + " " + dwe.getMessage());
- if (dwe.getCause() != null) {
- log.error(dwe.getClass().getName() + ", cause = " + dwe.getCause().getMessage());
- }
- deleteWalletConfirmDialog.getExplainLabel().setText(" ");
- deleteWalletConfirmDialog.setDeleteConfirmText(controller.getLocaliser().getString("deleteWalletConfirmDialog.walletDeleteError1"), controller
- .getLocaliser().getString("deleteWalletConfirmDialog.walletDeleteError2", new Object[] { dwe.getMessage() }));
- } catch (IOException ioe) {
- log.error(ioe.getClass().getName() + " " + ioe.getMessage());
- if (ioe.getCause() != null) {
- log.error(ioe.getClass().getName() + ", cause = " + ioe.getCause().getMessage());
- }
- deleteWalletConfirmDialog.getExplainLabel().setText(" ");
- deleteWalletConfirmDialog.setDeleteConfirmText(controller.getLocaliser().getString("deleteWalletConfirmDialog.walletDeleteError1"), controller
- .getLocaliser().getString("deleteWalletConfirmDialog.walletDeleteError2", new Object[] { ioe.getMessage() }));
- } finally {
- controller.fireRecreateAllViews(true);
- controller.fireDataChangedUpdateNow();
- }
- }
-
- /**
- * Delete wallet by filename.
- *
- * @param filename of wallet to delete
- * @return newWalletCreated
- * @throws DeleteWalletException
- * @throws IOException */
- public void deleteWallet(String filename) throws DeleteWalletException, IOException {
- deleteWallet(bitcoinController.getModel().getPerWalletModelDataByWalletFilename(filename));
- }
-
- /**
- * Actually delete the wallet (no UI elements used).
- * @param perWalletModelData of wallet to delete
- * @throws DeleteWalletException
- * @throws IOException
- */
- private void deleteWallet(WalletData perWalletModelData) throws DeleteWalletException, WalletVersionException, IOException {
- FileHandler fileHandler = new FileHandler(bitcoinController);
- fileHandler.deleteWalletAndWalletInfo(perWalletModelData);
-
- // Set the first wallet to be the active wallet.
- if (!bitcoinController.getModel().getPerWalletModelDataList().isEmpty()) {
- WalletData firstPerWalletModelData = bitcoinController.getModel().getPerWalletModelDataList().get(0);
- bitcoinController.getModel().setActiveWalletByFilename(firstPerWalletModelData.getWalletFilename());
-
- fileHandler.savePerWalletModelData(firstPerWalletModelData, true);
- }
-
- // Save the user properties to disk.
- FileHandler.writeUserPreferences(bitcoinController);
- log.debug("User preferences with old wallet deleted were written successfully");
-
- controller.fireRecreateAllViews(true);
- }
-}
Oops, something went wrong.

0 comments on commit fd4cc7f

Please sign in to comment.