update locked -> pending balance

This commit is contained in:
woodser 2022-08-17 11:50:30 -04:00
parent cb10a65a83
commit f464110fb5
23 changed files with 72 additions and 72 deletions

View File

@ -53,6 +53,7 @@ class BtcBalanceTableBuilder extends AbstractTableBuilder {
this.colLockedBalance = new SatoshiColumn(COL_HEADER_LOCKED_BALANCE);
}
@Override
public Table build() {
BtcBalanceInfo balance = (BtcBalanceInfo) protos.get(0);

View File

@ -553,14 +553,14 @@ class CoreWalletsService {
if (reservedBalance == null)
throw new IllegalStateException("reserved balance is not yet available");
var lockedBalance = balances.getLockedBalance().get();
if (lockedBalance == null)
var pendingBalance = balances.getPendingBalance().get();
if (pendingBalance == null)
throw new IllegalStateException("locked balance is not yet available");
return new BtcBalanceInfo(availableBalance.value,
reservedBalance.value,
availableBalance.add(reservedBalance).value,
lockedBalance.value);
pendingBalance.value);
}
private XmrBalanceInfo getXmrBalances() {
@ -571,8 +571,8 @@ class CoreWalletsService {
if (availableBalance == null)
throw new IllegalStateException("available balance is not yet available");
var lockedBalance = balances.getLockedBalance().get();
if (lockedBalance == null)
var pendingBalance = balances.getPendingBalance().get();
if (pendingBalance == null)
throw new IllegalStateException("locked balance is not yet available");
var reservedOfferBalance = balances.getReservedOfferBalance().get();
@ -583,9 +583,9 @@ class CoreWalletsService {
if (reservedTradeBalance == null)
throw new IllegalStateException("reserved trade balance is not yet available");
return new XmrBalanceInfo(availableBalance.longValue() + lockedBalance.longValue(),
return new XmrBalanceInfo(availableBalance.longValue() + pendingBalance.longValue(),
availableBalance.longValue(),
lockedBalance.longValue(),
pendingBalance.longValue(),
reservedOfferBalance.longValue(),
reservedTradeBalance.longValue());
}

View File

@ -17,8 +17,8 @@ public class XmrBalanceInfo implements Payload {
// all balances are in atomic units
private final long balance;
private final long unlockedBalance;
private final long lockedBalance;
private final long availableBalance;
private final long pendingBalance;
private final long reservedOfferBalance;
private final long reservedTradeBalance;
@ -28,21 +28,21 @@ public class XmrBalanceInfo implements Payload {
long reservedOfferBalance,
long reservedTradeBalance) {
this.balance = balance;
this.unlockedBalance = unlockedBalance;
this.lockedBalance = lockedBalance;
this.availableBalance = unlockedBalance;
this.pendingBalance = lockedBalance;
this.reservedOfferBalance = reservedOfferBalance;
this.reservedTradeBalance = reservedTradeBalance;
}
@VisibleForTesting
public static XmrBalanceInfo valueOf(long balance,
long unlockedBalance,
long lockedBalance,
long availableBalance,
long pendingBalance,
long reservedOfferBalance,
long reservedTradeBalance) {
return new XmrBalanceInfo(balance,
unlockedBalance,
lockedBalance,
availableBalance,
pendingBalance,
reservedOfferBalance,
reservedTradeBalance);
}
@ -55,8 +55,8 @@ public class XmrBalanceInfo implements Payload {
public bisq.proto.grpc.XmrBalanceInfo toProtoMessage() {
return bisq.proto.grpc.XmrBalanceInfo.newBuilder()
.setBalance(balance)
.setUnlockedBalance(unlockedBalance)
.setLockedBalance(lockedBalance)
.setAvailableBalance(availableBalance)
.setPendingBalance(pendingBalance)
.setReservedOfferBalance(reservedOfferBalance)
.setReservedTradeBalance(reservedTradeBalance)
.build();
@ -64,8 +64,8 @@ public class XmrBalanceInfo implements Payload {
public static XmrBalanceInfo fromProto(bisq.proto.grpc.XmrBalanceInfo proto) {
return new XmrBalanceInfo(proto.getBalance(),
proto.getUnlockedBalance(),
proto.getLockedBalance(),
proto.getAvailableBalance(),
proto.getPendingBalance(),
proto.getReservedOfferBalance(),
proto.getReservedTradeBalance());
}
@ -74,8 +74,8 @@ public class XmrBalanceInfo implements Payload {
public String toString() {
return "XmrBalanceInfo{" +
"balance=" + balance +
"unlockedBalance=" + unlockedBalance +
", lockedBalance=" + lockedBalance +
"unlockedBalance=" + availableBalance +
", lockedBalance=" + pendingBalance +
", reservedOfferBalance=" + reservedOfferBalance +
", reservedTradeBalance=" + reservedTradeBalance +
'}';

View File

@ -58,7 +58,7 @@ public class Balances {
@Getter
private final ObjectProperty<Coin> availableBalance = new SimpleObjectProperty<>();
@Getter
private final ObjectProperty<Coin> lockedBalance = new SimpleObjectProperty<>();
private final ObjectProperty<Coin> pendingBalance = new SimpleObjectProperty<>();
@Getter
private final ObjectProperty<Coin> reservedOfferBalance = new SimpleObjectProperty<>();
@Getter
@ -98,7 +98,7 @@ public class Balances {
// Need to delay a bit to get the balances correct
UserThread.execute(() -> { // TODO (woodser): running on user thread because JFX properties updated for legacy app
updateAvailableBalance();
updateLockedBalance();
updatePendingBalance();
updateReservedOfferBalance();
updateReservedTradeBalance();
updateReservedBalance();
@ -111,10 +111,10 @@ public class Balances {
availableBalance.set(Coin.valueOf(xmrWalletService.getWallet() == null ? 0 : xmrWalletService.getWallet().getUnlockedBalance(0).longValueExact()));
}
private void updateLockedBalance() {
private void updatePendingBalance() {
BigInteger balance = xmrWalletService.getWallet() == null ? new BigInteger("0") : xmrWalletService.getWallet().getBalance(0);
BigInteger unlockedBalance = xmrWalletService.getWallet() == null ? new BigInteger("0") : xmrWalletService.getWallet().getUnlockedBalance(0);
lockedBalance.set(Coin.valueOf(balance.subtract(unlockedBalance).longValueExact()));
pendingBalance.set(Coin.valueOf(balance.subtract(unlockedBalance).longValueExact()));
}
private void updateReservedOfferBalance() {

View File

@ -36,22 +36,21 @@ public class BalancePresentation {
@Getter
private final StringProperty availableBalance = new SimpleStringProperty();
@Getter
private final StringProperty reservedBalance = new SimpleStringProperty();
private final StringProperty pendingBalance = new SimpleStringProperty();
@Getter
private final StringProperty lockedBalance = new SimpleStringProperty();
private final StringProperty reservedBalance = new SimpleStringProperty();
@Inject
public BalancePresentation(Balances balances) {
balances.getAvailableBalance().addListener((observable, oldValue, newValue) -> {
availableBalance.set(longToXmr(newValue.value));
});
balances.getPendingBalance().addListener((observable, oldValue, newValue) -> {
pendingBalance.set(longToXmr(newValue.value));
});
balances.getReservedBalance().addListener((observable, oldValue, newValue) -> {
reservedBalance.set(longToXmr(newValue.value));
});
balances.getLockedBalance().addListener((observable, oldValue, newValue) -> {
lockedBalance.set(longToXmr(newValue.value));
});
}
// TODO: truncate full precision with ellipses to not break layout?

View File

@ -251,9 +251,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=There is no market price from ext
mainView.marketPrice.tooltip=Market price is provided by {0}{1}\nLast update: {2}\nProvider node URL: {3}
mainView.balance.available=Available balance
mainView.balance.reserved=Reserved in offers
mainView.balance.locked=Locked in trades
mainView.balance.pending=Pending balance
mainView.balance.reserved.short=Reserved
mainView.balance.locked.short=Locked
mainView.balance.pending.short=Pending
mainView.footer.usingTor=(via Tor)
mainView.footer.localhostBitcoinNode=(localhost)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=Neexistují tržní ceny od exter
mainView.marketPrice.tooltip=Tržní cena je poskytována {0}{1}\nPoslední aktualizace: {2}\nURL uzlu poskytovatele: {3}
mainView.balance.available=Dostupný zůstatek
mainView.balance.reserved=Rezervováno v nabídkách
mainView.balance.locked=Zamčené v obchodech
mainView.balance.pending=Zamčené v obchodech
mainView.balance.reserved.short=Rezervováno
mainView.balance.locked.short=Zamčeno
mainView.balance.pending.short=Zamčeno
mainView.footer.usingTor=(přes Tor)
mainView.footer.localhostBitcoinNode=(localhost)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=Es ist kein Marktpreis von extern
mainView.marketPrice.tooltip=Marktpreis bereitgestellt von {0}{1}\nLetzte Aktualisierung: {2}\nURL des Knoten-Anbieters: {3}
mainView.balance.available=Verfügbarer Betrag
mainView.balance.reserved=In Angeboten reserviert
mainView.balance.locked=In Trades gesperrt
mainView.balance.pending=In Trades gesperrt
mainView.balance.reserved.short=Reserviert
mainView.balance.locked.short=Gesperrt
mainView.balance.pending.short=Gesperrt
mainView.footer.usingTor=(über Tor)
mainView.footer.localhostBitcoinNode=(localhost)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=No existe un precio de mercado di
mainView.marketPrice.tooltip=Precio de mercado ofrecido por {0}{1}\nÚltima actualización: {2}\nURL del nodo proveedor: {3}
mainView.balance.available=Saldo disponible
mainView.balance.reserved=Reservado en ofertas
mainView.balance.locked=Bloqueado en intercambios
mainView.balance.pending=Bloqueado en intercambios
mainView.balance.reserved.short=Reservado
mainView.balance.locked.short=Bloqueado
mainView.balance.pending.short=Bloqueado
mainView.footer.usingTor=(via Tor)
mainView.footer.localhostBitcoinNode=(localhost)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=قیمت بازارهای خار
mainView.marketPrice.tooltip=قیمت بازار توسط {0}{1} ارائه شده است\nآخرین به روز رسانی: {2}\nURL لینک Node ارائه دهنده: {3}
mainView.balance.available=موجودی در دسترس
mainView.balance.reserved=رزرو شده در پیشنهادها
mainView.balance.locked=قفل شده در معاملات
mainView.balance.pending=قفل شده در معاملات
mainView.balance.reserved.short=اندوخته
mainView.balance.locked.short=قفل شده
mainView.balance.pending.short=قفل شده
mainView.footer.usingTor=(via Tor)
mainView.footer.localhostBitcoinNode=(لوکال هاست)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=Il n'y a pas de cours de marché
mainView.marketPrice.tooltip=Le prix de marché est fourni par {0}{1}\nDernière mise à jour: {2}\nURL du noeud: {3}
mainView.balance.available=Solde disponible
mainView.balance.reserved=Réservé en ordres
mainView.balance.locked=Bloqué en transactions
mainView.balance.pending=Bloqué en transactions
mainView.balance.reserved.short=Réservé
mainView.balance.locked.short=Vérouillé
mainView.balance.pending.short=Vérouillé
mainView.footer.usingTor=(à travers Tor)
mainView.footer.localhostBitcoinNode=(localhost)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=Non è disponibile alcun prezzo d
mainView.marketPrice.tooltip=Il prezzo di mercato é fornito da {0}{1}\nUltimo aggiornamento: {2}\nURL del nodo del provider: {3}
mainView.balance.available=Saldo disponibile
mainView.balance.reserved=Riservati nelle offerte
mainView.balance.locked=Bloccati in scambi
mainView.balance.pending=Bloccati in scambi
mainView.balance.reserved.short=Riservati
mainView.balance.locked.short=Bloccati
mainView.balance.pending.short=Bloccati
mainView.footer.usingTor=(via Tor)
mainView.footer.localhostBitcoinNode=(localhost)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=利用可能な外部価格フィ
mainView.marketPrice.tooltip=市場価格は{0}{1}に提供されています\n最終更新: {2}\n提供者のードのURL: {3}
mainView.balance.available=利用可能残高
mainView.balance.reserved=オファーのために予約済み
mainView.balance.locked=トレードにロック中
mainView.balance.pending=トレードにロック中
mainView.balance.reserved.short=予約済
mainView.balance.locked.short=ロック中
mainView.balance.pending.short=ロック中
mainView.footer.usingTor=(Tor経由で)
mainView.footer.localhostBitcoinNode=(ローカルホスト)

View File

@ -246,9 +246,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=Não foi encontrado preço de mer
mainView.marketPrice.tooltip=Preço de Mercado fornecido por {0}{1}\nÚltima atualização: {2}\nURL do provedor: {3}
mainView.balance.available=Saldo disponível
mainView.balance.reserved=Reservado em ofertas
mainView.balance.locked=Travado em negociações
mainView.balance.pending=Travado em negociações
mainView.balance.reserved.short=Reservado
mainView.balance.locked.short=Travado
mainView.balance.pending.short=Travado
mainView.footer.usingTor=(via Tor)
mainView.footer.localhostBitcoinNode=(localhost)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=Não há preço de mercado de for
mainView.marketPrice.tooltip=O preço de mercado é fornecido por {0} {1}\nÚltima atualização: {2}\nURL do nó do provedor: {3}
mainView.balance.available=Saldo disponível
mainView.balance.reserved=Reservado em ofertas
mainView.balance.locked=Bloqueado em negócios
mainView.balance.pending=Bloqueado em negócios
mainView.balance.reserved.short=Reservado
mainView.balance.locked.short=Bloqueado
mainView.balance.pending.short=Bloqueado
mainView.footer.usingTor=(via Tor)
mainView.footer.localhostBitcoinNode=(localhost)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=Нет данных от исто
mainView.marketPrice.tooltip=Рыночный курс предоставлен {0}{1}\nОбновление: {2}\nURL источника данных: {3}
mainView.balance.available=Доступный баланс
mainView.balance.reserved=Выделено на предложения
mainView.balance.locked=Используется в сделках
mainView.balance.pending=Используется в сделках
mainView.balance.reserved.short=Выделено
mainView.balance.locked.short=В сделках
mainView.balance.pending.short=В сделках
mainView.footer.usingTor=(via Tor)
mainView.footer.localhostBitcoinNode=(локальный узел)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=ไม่มีราคาตล
mainView.marketPrice.tooltip=ราคาตลาดจัดทำโดย {0} {1} \nอัปเดตล่าสุด: {2} \nnode URL ของผู้ให้บริการ: {3}
mainView.balance.available=ยอดคงเหลือที่พร้อมใช้งาน
mainView.balance.reserved=ข้อเสนอได้รับการจองแล้ว
mainView.balance.locked=ล็อคในการซื้อขาย
mainView.balance.pending=ล็อคในการซื้อขาย
mainView.balance.reserved.short=จองแล้ว
mainView.balance.locked.short=ถูกล็อคไว้
mainView.balance.pending.short=ถูกล็อคไว้
mainView.footer.usingTor=(via Tor)
mainView.footer.localhostBitcoinNode=(แม่ข่ายเฉพาะที่)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=Không có giá thị trường t
mainView.marketPrice.tooltip=Giá thị trường được cung cấp bởi {0}{1}\nCập nhật mới nhất: {2}\nURL nút nhà cung cấp: {3}
mainView.balance.available=Số dư hiện có
mainView.balance.reserved=Phần được bảo lưu trong báo giá
mainView.balance.locked=Khóa trong giao dịch
mainView.balance.pending=Khóa trong giao dịch
mainView.balance.reserved.short=Bảo lưu
mainView.balance.locked.short=Bị khóa
mainView.balance.pending.short=Bị khóa
mainView.footer.usingTor=(via Tor)
mainView.footer.localhostBitcoinNode=(Máy chủ nội bộ)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=外部交易所供应商没有可
mainView.marketPrice.tooltip=交易所价格提供者 {0}{1}\n最后更新{2}\n提供者节点 URL{3}
mainView.balance.available=可用余额
mainView.balance.reserved=保证金
mainView.balance.locked=冻结余额
mainView.balance.pending=冻结余额
mainView.balance.reserved.short=保证
mainView.balance.locked.short=冻结
mainView.balance.pending.short=冻结
mainView.footer.usingTor=(通过 Tor
mainView.footer.localhostBitcoinNode=(本地主机)

View File

@ -243,9 +243,9 @@ mainView.marketPrice.tooltip.bisqInternalPrice=外部交易所供應商沒有可
mainView.marketPrice.tooltip=交易所價格提供者 {0}{1}\n最後更新{2}\n提供者節點 URL{3}
mainView.balance.available=可用餘額
mainView.balance.reserved=保證金
mainView.balance.locked=凍結餘額
mainView.balance.pending=凍結餘額
mainView.balance.reserved.short=保證
mainView.balance.locked.short=凍結
mainView.balance.pending.short=凍結
mainView.footer.usingTor=(via Tor)
mainView.footer.localhostBitcoinNode=(本地主機)

View File

@ -278,21 +278,21 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
}
});
Tuple2<Label, VBox> lockedBalanceBox = getBalanceBox(Res.get("mainView.balance.locked.short"));
lockedBalanceBox.first.textProperty().bind(model.getLockedBalance());
lockedBalanceBox.first.tooltipProperty().bind(new ObjectBinding<>() {
Tuple2<Label, VBox> pendingBalanceBox = getBalanceBox(Res.get("mainView.balance.pending.short"));
pendingBalanceBox.first.textProperty().bind(model.getPendingBalance());
pendingBalanceBox.first.tooltipProperty().bind(new ObjectBinding<>() {
{
bind(model.getLockedBalance());
bind(model.getPendingBalance());
bind(model.getMarketPrice());
}
@Override
protected Tooltip computeValue() {
String tooltipText = Res.get("mainView.balance.locked");
String tooltipText = Res.get("mainView.balance.pending");
try {
String preferredTradeCurrency = model.getPreferences().getPreferredTradeCurrency().getCode();
double lockedBalance = Double.parseDouble(
model.getLockedBalance().getValue().replace("XMR", ""));
model.getPendingBalance().getValue().replace("XMR", ""));
double marketPrice = Double.parseDouble(model.getMarketPrice(preferredTradeCurrency).getValue());
tooltipText += "\n" + currencyFormat.format(lockedBalance * marketPrice) +
" " + preferredTradeCurrency;
@ -318,7 +318,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
secondaryNav.setAlignment(Pos.CENTER);
HBox priceAndBalance = new HBox(marketPriceBox.second, getNavigationSeparator(), availableBalanceBox.second,
getNavigationSeparator(), lockedBalanceBox.second, getNavigationSeparator(), reservedBalanceBox.second);
getNavigationSeparator(), pendingBalanceBox.second, getNavigationSeparator(), reservedBalanceBox.second);
priceAndBalance.setMaxHeight(41);
priceAndBalance.setAlignment(Pos.CENTER);

View File

@ -653,8 +653,8 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
return balancePresentation.getReservedBalance();
}
StringProperty getLockedBalance() {
return balancePresentation.getLockedBalance();
StringProperty getPendingBalance() {
return balancePresentation.getPendingBalance();
}

View File

@ -1126,8 +1126,8 @@ message BtcBalanceInfo {
message XmrBalanceInfo {
uint64 balance = 1 [jstype = JS_STRING];
uint64 unlocked_balance = 2 [jstype = JS_STRING];
uint64 locked_balance = 3 [jstype = JS_STRING];
uint64 available_balance = 2 [jstype = JS_STRING];
uint64 pending_balance = 3 [jstype = JS_STRING];
uint64 reserved_offer_balance = 4 [jstype = JS_STRING];
uint64 reserved_trade_balance = 5 [jstype = JS_STRING];
}