diff --git a/core/src/main/java/io/bitsquare/btc/WalletService.java b/core/src/main/java/io/bitsquare/btc/WalletService.java index bdbbc1c406..a424f1a5e5 100644 --- a/core/src/main/java/io/bitsquare/btc/WalletService.java +++ b/core/src/main/java/io/bitsquare/btc/WalletService.java @@ -95,6 +95,7 @@ public class WalletService { public final BooleanProperty shutDownDone = new SimpleBooleanProperty(); private final Storage storage; private final Long bloomFilterTweak; + private KeyParameter aesKey; /////////////////////////////////////////////////////////////////////////////////////////// @@ -337,6 +338,10 @@ public class WalletService { } } + public void setAesKey(KeyParameter aesKey) { + this.aesKey = aesKey; + } + /////////////////////////////////////////////////////////////////////////////////////////// // Listener @@ -618,7 +623,7 @@ public class WalletService { AddressEntry.Context context, Coin fee) throws AddressEntryException, AddressFormatException { try { - wallet.completeTx(getSendRequest(fromAddress, toAddress, amount, null, context)); + wallet.completeTx(getSendRequest(fromAddress, toAddress, amount, aesKey, context)); } catch (InsufficientMoneyException e) { if (e.missing != null) { log.trace("missing fee " + e.missing.toFriendlyString()); @@ -640,7 +645,7 @@ public class WalletService { Coin amount, Coin fee) throws AddressEntryException, AddressFormatException { try { - wallet.completeTx(getSendRequestForMultipleAddresses(fromAddresses, toAddress, amount, null, null)); + wallet.completeTx(getSendRequestForMultipleAddresses(fromAddresses, toAddress, amount, null, aesKey)); } catch (InsufficientMoneyException e) { if (e.missing != null) { log.trace("missing fee " + e.missing.toFriendlyString()); diff --git a/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java b/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java index f5c4821d07..d076d09e5e 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java +++ b/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java @@ -444,6 +444,7 @@ public class MainViewModel implements ViewModel { walletPasswordWindow .onAesKey(aesKey -> { tradeWalletService.setAesKey(aesKey); + walletService.setAesKey(aesKey); walletInitialized.set(true); }) .hideCloseButton() diff --git a/gui/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordView.java b/gui/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordView.java index 1052a7c30c..83ceac968c 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordView.java @@ -117,6 +117,7 @@ public class PasswordView extends ActivatableView { if (wallet.checkAESKey(aesKey)) { wallet.decrypt(aesKey); tradeWalletService.setAesKey(null); + walletService.setAesKey(null); new Popup() .feedback("Wallet successfully decrypted and password protection removed.") .show(); @@ -133,6 +134,7 @@ public class PasswordView extends ActivatableView { wallet.encrypt(keyCrypterScrypt, aesKey); // we save the key for the trade wallet as we don't require passwords here tradeWalletService.setAesKey(aesKey); + walletService.setAesKey(aesKey); new Popup() .feedback("Wallet successfully encrypted and password protection enabled.") .show();