use of com.sparrowwallet.drongo.BitcoinUnit in project sparrow by sparrowwallet.
the class SendController method bitcoinUnitChanged.
@Subscribe
public void bitcoinUnitChanged(BitcoinUnitChangedEvent event) {
BitcoinUnit unit = getBitcoinUnit(event.getBitcoinUnit());
feeAmountUnit.getSelectionModel().select(BitcoinUnit.BTC.equals(unit) ? 0 : 1);
}
use of com.sparrowwallet.drongo.BitcoinUnit in project sparrow by sparrowwallet.
the class WhirlpoolController method initializeView.
public void initializeView(String walletId, Wallet wallet, List<UtxoEntry> utxoEntries) {
this.walletId = walletId;
this.wallet = wallet;
this.utxoEntries = utxoEntries;
this.mixConfig = wallet.getMasterMixConfig();
step1.managedProperty().bind(step1.visibleProperty());
step2.managedProperty().bind(step2.visibleProperty());
step3.managedProperty().bind(step3.visibleProperty());
step4.managedProperty().bind(step4.visibleProperty());
step2.setVisible(false);
step3.setVisible(false);
step4.setVisible(false);
scode.setText(mixConfig.getScode() == null ? "" : mixConfig.getScode());
scode.setTextFormatter(new TextFormatter<>((change) -> {
change.setText(change.getText().toUpperCase());
return change;
}));
scode.textProperty().addListener((observable, oldValue, newValue) -> {
pool.setItems(FXCollections.emptyObservableList());
tx0PreviewProperty.set(null);
mixConfig.setScode(newValue);
EventManager.get().post(new WalletMasterMixConfigChangedEvent(wallet));
});
premixPriority.setMin(0);
premixPriority.setMax(FEE_TARGETS.size() - 1);
premixPriority.setMajorTickUnit(1);
premixPriority.setMinorTickCount(0);
premixPriority.setLabelFormatter(new StringConverter<>() {
@Override
public String toString(Double object) {
return object.intValue() == 0 ? "Low" : (object.intValue() == 1 ? "Normal" : "High");
}
@Override
public Double fromString(String string) {
return null;
}
});
premixPriority.valueProperty().addListener((observable, oldValue, newValue) -> {
pool.setItems(FXCollections.emptyObservableList());
tx0Previews = null;
tx0PreviewProperty.set(null);
Tx0FeeTarget tx0FeeTarget = FEE_TARGETS.get(newValue.intValue());
premixFeeRate.setText(SparrowMinerFeeSupplier.getFee(Integer.parseInt(tx0FeeTarget.getFeeTarget().getValue())) + " sats/vB");
});
premixPriority.setValue(1);
if (mixConfig.getScode() != null) {
step1.setVisible(false);
step3.setVisible(true);
}
pool.setConverter(new StringConverter<Pool>() {
@Override
public String toString(Pool selectedPool) {
if (selectedPool == null) {
pool.setTooltip(null);
return "Fetching pools...";
}
BitcoinUnit bitcoinUnit = wallet.getAutoUnit();
String satsValue = String.format(Locale.ENGLISH, "%,d", selectedPool.getDenomination()) + " sats";
String btcValue = CoinLabel.BTC_FORMAT.format((double) selectedPool.getDenomination() / Transaction.SATOSHIS_PER_BITCOIN) + " BTC";
pool.setTooltip(bitcoinUnit == BitcoinUnit.BTC ? new Tooltip(satsValue) : new Tooltip(btcValue));
return bitcoinUnit == BitcoinUnit.BTC ? btcValue : satsValue;
}
@Override
public Pool fromString(String string) {
return null;
}
});
pool.valueProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == null) {
selectedPool.setVisible(false);
} else {
poolFee.setValue(newValue.getFeeValue());
poolAnonset.setText(newValue.getMixAnonymitySet() + " UTXOs");
selectedPool.setVisible(true);
fetchTx0Preview(newValue);
}
});
step4.visibleProperty().addListener((observable, oldValue, newValue) -> {
if (newValue && pool.getItems().isEmpty()) {
fetchPools();
}
});
selectedPool.managedProperty().bind(selectedPool.visibleProperty());
selectedPool.setVisible(false);
pool.managedProperty().bind(pool.visibleProperty());
poolInsufficient.managedProperty().bind(poolInsufficient.visibleProperty());
poolInsufficient.visibleProperty().bind(pool.visibleProperty().not());
discountFeeBox.managedProperty().bind(discountFeeBox.visibleProperty());
discountFeeBox.setVisible(false);
nbOutputsBox.managedProperty().bind(nbOutputsBox.visibleProperty());
nbOutputsBox.setVisible(false);
nbOutputsLoading.managedProperty().bind(nbOutputsLoading.visibleProperty());
nbOutputs.managedProperty().bind(nbOutputs.visibleProperty());
nbOutputsLoading.visibleProperty().bind(nbOutputs.visibleProperty().not());
nbOutputs.setVisible(false);
tx0PreviewProperty.addListener((observable, oldValue, tx0Preview) -> {
if (tx0Preview == null) {
nbOutputsBox.setVisible(true);
nbOutputsLoading.setText("Calculating...");
nbOutputs.setVisible(false);
discountFeeBox.setVisible(false);
} else {
discountFeeBox.setVisible(tx0Preview.getPool().getFeeValue() != tx0Preview.getTx0Data().getFeeValue());
discountFee.setValue(tx0Preview.getTx0Data().getFeeValue());
nbOutputsBox.setVisible(true);
nbOutputs.setText(tx0Preview.getNbPremix() + " UTXOs");
nbOutputs.setVisible(true);
}
});
}
use of com.sparrowwallet.drongo.BitcoinUnit in project sparrow by sparrowwallet.
the class CopyableCoinLabel method setValueAsText.
private void setValueAsText(Long value, BitcoinUnit bitcoinUnit) {
setTooltip(tooltip);
setContextMenu(contextMenu);
String satsValue = String.format(Locale.ENGLISH, "%,d", value) + " sats";
String btcValue = CoinLabel.getBTCFormat().format(value.doubleValue() / Transaction.SATOSHIS_PER_BITCOIN) + " BTC";
BitcoinUnit unit = bitcoinUnit;
if (unit == null || unit.equals(BitcoinUnit.AUTO)) {
unit = (value >= BitcoinUnit.getAutoThreshold() ? BitcoinUnit.BTC : BitcoinUnit.SATOSHIS);
}
if (unit.equals(BitcoinUnit.BTC)) {
tooltip.setText(satsValue);
setText(btcValue);
} else {
tooltip.setText(btcValue);
setText(satsValue);
}
}
use of com.sparrowwallet.drongo.BitcoinUnit in project sparrow by sparrowwallet.
the class UtxosChart method initialize.
public void initialize(WalletUtxosEntry walletUtxosEntry) {
utxoSeries = new XYChart.Series<>();
getData().add(utxoSeries);
update(walletUtxosEntry);
BitcoinUnit unit = Config.get().getBitcoinUnit();
setBitcoinUnit(walletUtxosEntry.getWallet(), unit);
}
Aggregations