use of com.sparrowwallet.sparrow.whirlpool.Whirlpool in project sparrow by sparrowwallet.
the class UtxosController method initializeView.
@Override
public void initializeView() {
balance.valueProperty().addListener((observable, oldValue, newValue) -> {
setFiatBalance(fiatBalance, AppServices.getFiatCurrencyExchangeRate(), newValue.longValue());
});
mempoolBalance.valueProperty().addListener((observable, oldValue, newValue) -> {
setFiatBalance(fiatMempoolBalance, AppServices.getFiatCurrencyExchangeRate(), newValue.longValue());
});
WalletUtxosEntry walletUtxosEntry = getWalletForm().getWalletUtxosEntry();
updateFields(walletUtxosEntry);
utxosTable.initialize(walletUtxosEntry);
utxosChart.initialize(walletUtxosEntry);
mixButtonsBox.managedProperty().bind(mixButtonsBox.visibleProperty());
mixButtonsBox.setVisible(getWalletForm().getWallet().isWhirlpoolMixWallet());
startMix.managedProperty().bind(startMix.visibleProperty());
startMix.setDisable(!AppServices.isConnected());
stopMix.managedProperty().bind(stopMix.visibleProperty());
startMix.visibleProperty().bind(stopMix.visibleProperty().not());
stopMix.visibleProperty().addListener((observable, oldValue, newValue) -> {
stopMix.setDisable(!newValue);
});
mixTo.managedProperty().bind(mixTo.visibleProperty());
mixTo.setVisible(getWalletForm().getWallet().getStandardAccountType() == StandardAccount.WHIRLPOOL_POSTMIX);
if (mixButtonsBox.isVisible()) {
Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(getWalletForm().getWallet());
if (whirlpool != null) {
stopMix.visibleProperty().bind(whirlpool.mixingProperty());
if (whirlpool.startingProperty().getValue()) {
mixingStartingListener.changed(whirlpool.startingProperty(), null, whirlpool.startingProperty().getValue());
}
whirlpool.startingProperty().addListener(new WeakChangeListener<>(mixingStartingListener));
if (whirlpool.stoppingProperty().getValue()) {
mixingStoppingListener.changed(whirlpool.stoppingProperty(), null, whirlpool.stoppingProperty().getValue());
}
whirlpool.stoppingProperty().addListener(new WeakChangeListener<>(mixingStoppingListener));
whirlpool.mixingProperty().addListener(new WeakChangeListener<>(mixingListener));
updateMixToButton();
}
}
sendSelected.setDisable(true);
sendSelected.setTooltip(new Tooltip("Send selected UTXOs. Use " + (org.controlsfx.tools.Platform.getCurrent() == org.controlsfx.tools.Platform.OSX ? "Cmd" : "Ctrl") + "+click to select multiple."));
mixSelected.managedProperty().bind(mixSelected.visibleProperty());
mixSelected.setVisible(canWalletMix());
mixSelected.setDisable(true);
AppServices.onlineProperty().addListener(new WeakChangeListener<>(mixingOnlineListener));
utxosTable.getSelectionModel().getSelectedIndices().addListener((ListChangeListener<Integer>) c -> {
List<Entry> selectedEntries = utxosTable.getSelectionModel().getSelectedCells().stream().filter(tp -> tp.getTreeItem() != null).map(tp -> tp.getTreeItem().getValue()).collect(Collectors.toList());
utxosChart.select(selectedEntries);
updateButtons(Config.get().getBitcoinUnit());
});
}
use of com.sparrowwallet.sparrow.whirlpool.Whirlpool in project sparrow by sparrowwallet.
the class UtxosController method stopMixing.
public void stopMixing(ActionEvent event) {
stopMix.setDisable(true);
startMix.setDisable(!AppServices.onlineProperty().get());
getWalletForm().getWallet().getMasterMixConfig().setMixOnStartup(Boolean.FALSE);
EventManager.get().post(new WalletMasterMixConfigChangedEvent(getWalletForm().getWallet()));
Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(getWalletForm().getWallet());
if (whirlpool.isStarted()) {
AppServices.getWhirlpoolServices().stopWhirlpool(whirlpool, true);
} else {
// Ensure http clients are shutdown
whirlpool.shutdown();
}
}
use of com.sparrowwallet.sparrow.whirlpool.Whirlpool in project sparrow by sparrowwallet.
the class SendController method broadcastPremix.
public void broadcastPremix(ActionEvent event) {
// Ensure all child wallets have been saved
Wallet masterWallet = getWalletForm().getWallet().isMasterWallet() ? getWalletForm().getWallet() : getWalletForm().getWallet().getMasterWallet();
for (Wallet childWallet : masterWallet.getChildWallets()) {
if (!childWallet.isNested()) {
Storage storage = AppServices.get().getOpenWallets().get(childWallet);
if (!storage.isPersisted(childWallet)) {
try {
storage.saveWallet(childWallet);
} catch (Exception e) {
AppServices.showErrorDialog("Error saving wallet " + childWallet.getName(), e.getMessage());
}
}
}
}
// The WhirlpoolWallet has already been configured for the tx0 preview
Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(getWalletForm().getStorage().getWalletId(masterWallet));
Map<BlockTransactionHashIndex, WalletNode> utxos = walletTransactionProperty.get().getSelectedUtxos();
Whirlpool.Tx0BroadcastService tx0BroadcastService = new Whirlpool.Tx0BroadcastService(whirlpool, whirlpoolProperty.get(), utxos.keySet());
tx0BroadcastService.setOnRunning(workerStateEvent -> {
premixButton.setDisable(true);
addWalletTransactionNodes();
});
tx0BroadcastService.setOnSucceeded(workerStateEvent -> {
premixButton.setDisable(false);
Sha256Hash txid = tx0BroadcastService.getValue();
clear(null);
});
tx0BroadcastService.setOnFailed(workerStateEvent -> {
premixButton.setDisable(false);
Throwable exception = workerStateEvent.getSource().getException();
while (exception.getCause() != null) {
exception = exception.getCause();
}
AppServices.showErrorDialog("Error broadcasting premix transaction", exception.getMessage());
});
ServiceProgressDialog progressDialog = new ServiceProgressDialog("Whirlpool", "Broadcast Premix Transaction", "/image/whirlpool.png", tx0BroadcastService);
AppServices.moveToActiveWindowScreen(progressDialog);
tx0BroadcastService.start();
}
use of com.sparrowwallet.sparrow.whirlpool.Whirlpool in project sparrow by sparrowwallet.
the class WalletUtxosEntry method updateMixProgress.
public void updateMixProgress() {
Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(getWallet());
if (whirlpool != null) {
for (Entry entry : getChildren()) {
UtxoEntry utxoEntry = (UtxoEntry) entry;
MixProgress mixProgress = whirlpool.getMixProgress(utxoEntry.getHashIndex());
if (mixProgress != null || utxoEntry.getMixStatus() == null || (utxoEntry.getMixStatus().getMixFailReason() == null && utxoEntry.getMixStatus().getNextMixUtxo() == null)) {
utxoEntry.setMixProgress(mixProgress);
}
}
}
}
use of com.sparrowwallet.sparrow.whirlpool.Whirlpool in project sparrow by sparrowwallet.
the class UtxosController method startMixing.
public void startMixing(ActionEvent event) {
startMix.setDisable(true);
stopMix.setDisable(false);
getWalletForm().getWallet().getMasterMixConfig().setMixOnStartup(Boolean.TRUE);
EventManager.get().post(new WalletMasterMixConfigChangedEvent(getWalletForm().getWallet()));
Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(getWalletForm().getWallet());
if (whirlpool != null && !whirlpool.isStarted() && AppServices.isConnected()) {
AppServices.getWhirlpoolServices().startWhirlpool(getWalletForm().getWallet(), whirlpool, true);
}
}
Aggregations