Fix bug with password protection at fee calculation

This commit is contained in:
Manfred Karrer 2016-04-29 10:49:58 +02:00
parent 60289553d5
commit 0a0f5a5659
3 changed files with 10 additions and 2 deletions

View file

@ -95,6 +95,7 @@ public class WalletService {
public final BooleanProperty shutDownDone = new SimpleBooleanProperty(); public final BooleanProperty shutDownDone = new SimpleBooleanProperty();
private final Storage<Long> storage; private final Storage<Long> storage;
private final Long bloomFilterTweak; private final Long bloomFilterTweak;
private KeyParameter aesKey;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -337,6 +338,10 @@ public class WalletService {
} }
} }
public void setAesKey(KeyParameter aesKey) {
this.aesKey = aesKey;
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Listener // Listener
@ -618,7 +623,7 @@ public class WalletService {
AddressEntry.Context context, AddressEntry.Context context,
Coin fee) throws AddressEntryException, AddressFormatException { Coin fee) throws AddressEntryException, AddressFormatException {
try { try {
wallet.completeTx(getSendRequest(fromAddress, toAddress, amount, null, context)); wallet.completeTx(getSendRequest(fromAddress, toAddress, amount, aesKey, context));
} catch (InsufficientMoneyException e) { } catch (InsufficientMoneyException e) {
if (e.missing != null) { if (e.missing != null) {
log.trace("missing fee " + e.missing.toFriendlyString()); log.trace("missing fee " + e.missing.toFriendlyString());
@ -640,7 +645,7 @@ public class WalletService {
Coin amount, Coin amount,
Coin fee) throws AddressEntryException, AddressFormatException { Coin fee) throws AddressEntryException, AddressFormatException {
try { try {
wallet.completeTx(getSendRequestForMultipleAddresses(fromAddresses, toAddress, amount, null, null)); wallet.completeTx(getSendRequestForMultipleAddresses(fromAddresses, toAddress, amount, null, aesKey));
} catch (InsufficientMoneyException e) { } catch (InsufficientMoneyException e) {
if (e.missing != null) { if (e.missing != null) {
log.trace("missing fee " + e.missing.toFriendlyString()); log.trace("missing fee " + e.missing.toFriendlyString());

View file

@ -444,6 +444,7 @@ public class MainViewModel implements ViewModel {
walletPasswordWindow walletPasswordWindow
.onAesKey(aesKey -> { .onAesKey(aesKey -> {
tradeWalletService.setAesKey(aesKey); tradeWalletService.setAesKey(aesKey);
walletService.setAesKey(aesKey);
walletInitialized.set(true); walletInitialized.set(true);
}) })
.hideCloseButton() .hideCloseButton()

View file

@ -117,6 +117,7 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
if (wallet.checkAESKey(aesKey)) { if (wallet.checkAESKey(aesKey)) {
wallet.decrypt(aesKey); wallet.decrypt(aesKey);
tradeWalletService.setAesKey(null); tradeWalletService.setAesKey(null);
walletService.setAesKey(null);
new Popup() new Popup()
.feedback("Wallet successfully decrypted and password protection removed.") .feedback("Wallet successfully decrypted and password protection removed.")
.show(); .show();
@ -133,6 +134,7 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
wallet.encrypt(keyCrypterScrypt, aesKey); wallet.encrypt(keyCrypterScrypt, aesKey);
// we save the key for the trade wallet as we don't require passwords here // we save the key for the trade wallet as we don't require passwords here
tradeWalletService.setAesKey(aesKey); tradeWalletService.setAesKey(aesKey);
walletService.setAesKey(aesKey);
new Popup() new Popup()
.feedback("Wallet successfully encrypted and password protection enabled.") .feedback("Wallet successfully encrypted and password protection enabled.")
.show(); .show();