From 3bc7c7473a0fc689bcc5fa4f3cac0befdf399702 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 21 Mar 2023 08:34:06 +0200 Subject: [PATCH] fix error initializing whirlpool on new wallet without a passphrase --- .../sparrow/control/MnemonicKeystorePane.java | 2 +- .../com/sparrowwallet/sparrow/soroban/Soroban.java | 2 +- .../sparrowwallet/sparrow/whirlpool/Whirlpool.java | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystorePane.java b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystorePane.java index 9660b54c..9a6bba43 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystorePane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystorePane.java @@ -44,7 +44,7 @@ public class MnemonicKeystorePane extends TitledDescriptionPane { protected Label invalidLabel; protected SimpleListProperty wordEntriesProperty; - protected final SimpleStringProperty passphraseProperty = new SimpleStringProperty(); + protected final SimpleStringProperty passphraseProperty = new SimpleStringProperty(""); protected IntegerProperty defaultWordSizeProperty; public MnemonicKeystorePane(String title, String description, String content, String imageUrl) { diff --git a/src/main/java/com/sparrowwallet/sparrow/soroban/Soroban.java b/src/main/java/com/sparrowwallet/sparrow/soroban/Soroban.java index 43c1d7a2..e5ca0d57 100644 --- a/src/main/java/com/sparrowwallet/sparrow/soroban/Soroban.java +++ b/src/main/java/com/sparrowwallet/sparrow/soroban/Soroban.java @@ -59,7 +59,7 @@ public class Soroban { ScriptType scriptType = wallet.getScriptType(); int purpose = scriptType.getDefaultDerivation().get(0).num(); List words = keystore.getSeed().getMnemonicCode(); - String passphrase = keystore.getSeed().getPassphrase().asString(); + String passphrase = keystore.getSeed().getPassphrase() == null ? "" : keystore.getSeed().getPassphrase().asString(); byte[] seed = hdWalletFactory.computeSeedFromWords(words); hdWallet = new HD_Wallet(purpose, new ArrayList<>(words), sorobanServer.getParams(), seed, passphrase); bip47Account = wallet.isMasterWallet() ? wallet.getAccountIndex() : wallet.getMasterWallet().getAccountIndex(); diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java index 2460da24..57510685 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java @@ -68,6 +68,7 @@ public class Whirlpool { private final ExpirablePoolSupplier poolSupplier; private final Tx0Service tx0Service; private Tx0FeeTarget tx0FeeTarget = Tx0FeeTarget.BLOCKS_4; + private Tx0FeeTarget mixFeeTarget = Tx0FeeTarget.BLOCKS_4; private HD_Wallet hdWallet; private String walletId; private String mixToWalletId; @@ -149,7 +150,6 @@ public class Whirlpool { } private Tx0Config computeTx0Config() { - Tx0FeeTarget mixFeeTarget = Tx0FeeTarget.BLOCKS_4; return new Tx0Config(tx0ParamService, poolSupplier, tx0FeeTarget, mixFeeTarget, WhirlpoolAccount.BADBANK); } @@ -163,7 +163,7 @@ public class Whirlpool { ScriptType scriptType = wallet.getScriptType(); int purpose = scriptType.getDefaultDerivation().get(0).num(); List words = keystore.getSeed().getMnemonicCode(); - String passphrase = keystore.getSeed().getPassphrase().asString(); + String passphrase = keystore.getSeed().getPassphrase() == null ? "" : keystore.getSeed().getPassphrase().asString(); HD_WalletFactoryGeneric hdWalletFactory = HD_WalletFactoryGeneric.getInstance(); byte[] seed = hdWalletFactory.computeSeedFromWords(words); this.walletId = walletId; @@ -488,6 +488,14 @@ public class Whirlpool { this.tx0FeeTarget = tx0FeeTarget; } + public Tx0FeeTarget getMixFeeTarget() { + return mixFeeTarget; + } + + public void setMixFeeTarget(Tx0FeeTarget mixFeeTarget) { + this.mixFeeTarget = mixFeeTarget; + } + public String getWalletId() { return walletId; }