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();
private final Storage<Long> 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());

View file

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

View file

@ -117,6 +117,7 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
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<GridPane, Void> {
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();