use wallet unit when displaying pool denomination

This commit is contained in:
Craig Raw 2021-09-27 09:33:41 +02:00
parent 712241873f
commit 761e9c9b7e

View file

@ -115,8 +115,18 @@ public class WhirlpoolController {
pool.setConverter(new StringConverter<Pool>() {
@Override
public String toString(Pool pool) {
return pool == null ? "Fetching pools..." : pool.getPoolId().replace("btc", " BTC");
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