use of com.sparrowwallet.drongo.wallet.MixConfig in project sparrow by sparrowwallet.
the class MixConfigMapper method map.
@Override
public MixConfig map(ResultSet rs, StatementContext ctx) throws SQLException {
String scode = rs.getString("scode");
Boolean mixOnStartup = rs.getBoolean("mixOnStartup");
if (rs.wasNull()) {
mixOnStartup = null;
}
String indexRange = rs.getString("indexRange");
String mixToWalletFile = rs.getString("mixToWalletFile");
String mixToWalletName = rs.getString("mixToWalletName");
Integer minMixes = rs.getInt("minMixes");
if (rs.wasNull()) {
minMixes = null;
}
MixConfig mixConfig = new MixConfig(scode, mixOnStartup, indexRange, mixToWalletFile == null ? null : new File(mixToWalletFile), mixToWalletName, minMixes, rs.getInt("receiveIndex"), rs.getInt("changeIndex"));
mixConfig.setId(rs.getLong("id"));
return mixConfig;
}
use of com.sparrowwallet.drongo.wallet.MixConfig in project sparrow by sparrowwallet.
the class MixToController method initializeView.
public void initializeView(Wallet wallet) {
mixConfig = wallet.getMasterMixConfig().copy();
List<Wallet> allWallets = new ArrayList<>();
allWallets.add(NONE_WALLET);
List<Wallet> destinationWallets = AppServices.get().getOpenWallets().keySet().stream().filter(openWallet -> openWallet.isValid() && (openWallet.getScriptType() == ScriptType.P2WPKH || openWallet.getScriptType() == ScriptType.P2WSH) && openWallet != wallet && openWallet != wallet.getMasterWallet() && (openWallet.getStandardAccountType() == null || !StandardAccount.WHIRLPOOL_ACCOUNTS.contains(openWallet.getStandardAccountType()))).collect(Collectors.toList());
allWallets.addAll(destinationWallets);
mixToWallets.setItems(FXCollections.observableList(allWallets));
mixToWallets.setConverter(new StringConverter<>() {
@Override
public String toString(Wallet wallet) {
return wallet == null ? "" : wallet.getFullDisplayName();
}
@Override
public Wallet fromString(String string) {
return null;
}
});
String mixToWalletId = null;
try {
mixToWalletId = AppServices.getWhirlpoolServices().getWhirlpoolMixToWalletId(mixConfig);
} catch (NoSuchElementException e) {
// ignore, mix to wallet is not open
}
if (mixToWalletId != null) {
mixToWallets.setValue(AppServices.get().getWallet(mixToWalletId));
} else {
mixToWallets.setValue(NONE_WALLET);
}
mixToWallets.valueProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == NONE_WALLET) {
mixConfig.setMixToWalletName(null);
mixConfig.setMixToWalletFile(null);
} else {
mixConfig.setMixToWalletName(newValue.getName());
mixConfig.setMixToWalletFile(AppServices.get().getOpenWallets().get(newValue).getWalletFile());
}
EventManager.get().post(new MixToConfigChangedEvent(wallet));
});
int initialMinMixes = mixConfig.getMinMixes() == null ? Whirlpool.DEFAULT_MIXTO_MIN_MIXES : mixConfig.getMinMixes();
minMixes.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 10000, initialMinMixes));
minMixes.valueProperty().addListener((observable, oldValue, newValue) -> {
mixConfig.setMinMixes(newValue);
EventManager.get().post(new MixToConfigChangedEvent(wallet));
});
indexRange.setConverter(new StringConverter<>() {
@Override
public String toString(IndexRange indexRange) {
if (indexRange == null) {
return "";
}
return indexRange.toString().charAt(0) + indexRange.toString().substring(1).toLowerCase();
}
@Override
public IndexRange fromString(String string) {
return null;
}
});
indexRange.setValue(IndexRange.FULL);
if (mixConfig.getIndexRange() != null) {
try {
indexRange.setValue(IndexRange.valueOf(mixConfig.getIndexRange()));
} catch (Exception e) {
// ignore
}
}
indexRange.valueProperty().addListener((observable, oldValue, newValue) -> {
mixConfig.setIndexRange(newValue.toString());
EventManager.get().post(new MixToConfigChangedEvent(wallet));
});
}
Aggregations