SendBitcoinConfirmAction extends MultiBitSubmitAction { @Override public void actionPerformed(ActionEvent e) { if (abort()) { return; } SendBitcoinConfirmDialog sendBitcoinConfirmDialog = null; ValidationErrorDialog validationErrorDialog = null; try { String sendAddress = dataProvider.getAddress(); String sendAmount = dataProvider.getAmount(); Validator validator = new Validator(super.bitcoinController); if (validator.validate(sendAddress, sendAmount)) { Address sendAddressObject; sendAddressObject = new Address(bitcoinController.getModel().getNetworkParameters(), sendAddress); SendRequest sendRequest = SendRequest.to(sendAddressObject, Utils.toNanoCoins(sendAmount)); sendRequest.ensureMinRequiredFee = true; sendRequest.fee = BigInteger.ZERO; sendRequest.feePerKb = BitcoinModel.SEND_FEE_PER_KB_DEFAULT; log.debug("Just about to complete the tx (and calculate the fee)..."); boolean completedOk; try { bitcoinController.getModel().getActiveWallet().completeTx(sendRequest, false); completedOk = true; log.debug("The fee after completing the transaction was " + sendRequest.fee); } catch (InsufficientMoneyException ime) { completedOk = false; } if (completedOk) { sendBitcoinConfirmDialog = new SendBitcoinConfirmDialog(super.bitcoinController, mainFrame, sendRequest); sendBitcoinConfirmDialog.setVisible(true); } else { validationErrorDialog = new ValidationErrorDialog(super.bitcoinController, mainFrame, sendRequest, true); validationErrorDialog.setVisible(true); } } else { validationErrorDialog = new ValidationErrorDialog(super.bitcoinController, mainFrame, null, false); validationErrorDialog.setVisible(true); } } catch (WrongNetworkException e1) { logMessage(e1); } catch (AddressFormatException e1) { logMessage(e1); } catch (KeyCrypterException e1) { logMessage(e1); } catch (Exception e1) { logMessage(e1); } } SendBitcoinConfirmAction(BitcoinController bitcoinController, MultiBitFrame mainFrame, BitcoinFormDataProvider dataProvider); @Override void actionPerformed(ActionEvent e);  }
@Test public void testNoWalletSelected() throws Exception { final CreateControllers.Controllers controllers = CreateControllers.createControllers(); BitcoinController controller = controllers.bitcoinController; assertTrue("There was an active wallet when there should not be", controller.getModel().thereIsNoActiveWallet()); ColorAndFontConstants.init(); FontSizer.INSTANCE.initialise(controller); SendBitcoinPanel sendBitcoinPanel = new SendBitcoinPanel(controller, null); SendBitcoinConfirmAction sendBitcoinConfirmAction = sendBitcoinPanel.getSendBitcoinConfirmAction(); assertNotNull("sendBitcoinConfirmAction was not created successfully", sendBitcoinConfirmAction); sendBitcoinConfirmAction.actionPerformed(null); Object[] messages = MessageManager.INSTANCE.getMessages().toArray(); assertTrue("There were no messages but there should have been", messages != null && messages.length > 0); assertEquals("Wrong message after send bitcoin confirm with no active wallet", ResetTransactionsSubmitActionTest.EXPECTED_NO_WALLET_IS_SELECTED, ((Message)messages[messages.length - 1]).getText()); }