From 776fcb3044b464df82d845f8732de5fbba522eef Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 12 Oct 2021 12:46:42 +0200 Subject: [PATCH] permit mixing from badbank --- .../sparrow/wallet/UtxosController.java | 2 +- .../sparrowwallet/sparrow/wallet/WalletForm.java | 4 ++++ .../sparrowwallet/sparrow/whirlpool/Whirlpool.java | 13 +++++-------- .../sparrow/whirlpool/WhirlpoolServices.java | 1 + 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java index 66eb7cf7..c722801b 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java @@ -224,7 +224,7 @@ public class UtxosController extends WalletFormController implements Initializab public void mixSelected(ActionEvent event) { List selectedEntries = getSelectedUtxos(); - WhirlpoolDialog whirlpoolDialog = new WhirlpoolDialog(getWalletForm().getWalletId(), getWalletForm().getWallet(), selectedEntries); + WhirlpoolDialog whirlpoolDialog = new WhirlpoolDialog(getWalletForm().getMasterWalletId(), getWalletForm().getWallet(), selectedEntries); Optional optTx0Preview = whirlpoolDialog.showAndWait(); optTx0Preview.ifPresent(tx0Preview -> previewPremix(tx0Preview, selectedEntries)); } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java index ff22d8b3..23bce179 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java @@ -66,6 +66,10 @@ public class WalletForm { return wallet.isMasterWallet() ? wallet : wallet.getMasterWallet(); } + public String getMasterWalletId() { + return storage.getWalletId(getMasterWallet()); + } + public Storage getStorage() { return storage; } diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java index 0e979c21..7394110a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java @@ -52,10 +52,7 @@ import javafx.concurrent.Task; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; public class Whirlpool { @@ -71,9 +68,9 @@ public class Whirlpool { private final TorClientService torClientService; private final WhirlpoolWalletService whirlpoolWalletService; private final WhirlpoolWalletConfig config; - private Tx0ParamService tx0ParamService; - private ExpirablePoolSupplier poolSupplier; - private Tx0Service tx0Service; + private final Tx0ParamService tx0ParamService; + private final ExpirablePoolSupplier poolSupplier; + private final Tx0Service tx0Service; private HD_Wallet hdWallet; private String walletId; private String mixToWalletId; @@ -162,7 +159,7 @@ public class Whirlpool { HD_WalletFactoryGeneric hdWalletFactory = HD_WalletFactoryGeneric.getInstance(); byte[] seed = hdWalletFactory.computeSeedFromWords(words); this.walletId = walletId; - hdWallet = new HD_Wallet(purpose, words, config.getNetworkParameters(), seed, passphrase, 1); + hdWallet = new HD_Wallet(purpose, words, config.getNetworkParameters(), seed, passphrase, 10); } catch(Exception e) { throw new IllegalStateException("Could not create Whirlpool HD wallet ", e); } diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolServices.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolServices.java index 35286d55..42453524 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolServices.java @@ -136,6 +136,7 @@ public class WhirlpoolServices { && wallet.getKeystores().size() == 1 && wallet.getKeystores().get(0).hasSeed() && wallet.getKeystores().get(0).getSeed().getType() == DeterministicSeed.Type.BIP39 + && wallet.getStandardAccountType() != null && !wallet.isWhirlpoolMixWallet(); }