mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-05-22 08:21:18 -04:00
take offer funded from available balance
This commit is contained in:
parent
2b7beff84e
commit
06c2ce432b
10 changed files with 105 additions and 78 deletions
|
@ -664,7 +664,7 @@ public class XmrWalletService {
|
|||
for (XmrBalanceListener balanceListener : balanceListeners) {
|
||||
Coin balance;
|
||||
if (balanceListener.getSubaddressIndex() != null && balanceListener.getSubaddressIndex() != 0) balance = getBalanceForSubaddress(balanceListener.getSubaddressIndex());
|
||||
else balance = getAvailableConfirmedBalance();
|
||||
else balance = getAvailableBalance();
|
||||
UserThread.execute(new Runnable() { // TODO (woodser): don't execute on UserThread
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -940,12 +940,16 @@ public class XmrWalletService {
|
|||
return HavenoUtils.atomicUnitsToCoin(wallet.getBalance(0, subaddressIndex));
|
||||
}
|
||||
|
||||
public Coin getAvailableConfirmedBalance() {
|
||||
return wallet != null ? HavenoUtils.atomicUnitsToCoin(wallet.getUnlockedBalance(0)) : Coin.ZERO;
|
||||
public Coin getAvailableBalanceForSubaddress(int subaddressIndex) {
|
||||
return HavenoUtils.atomicUnitsToCoin(wallet.getUnlockedBalance(0, subaddressIndex));
|
||||
}
|
||||
|
||||
public Coin getSavingWalletBalance() {
|
||||
return wallet != null ? Coin.valueOf(wallet.getBalance(0).longValueExact()) : Coin.ZERO;
|
||||
public Coin getBalance() {
|
||||
return wallet != null ? HavenoUtils.atomicUnitsToCoin(wallet.getBalance(0)) : Coin.ZERO;
|
||||
}
|
||||
|
||||
public Coin getAvailableBalance() {
|
||||
return wallet != null ? HavenoUtils.atomicUnitsToCoin(wallet.getUnlockedBalance(0)) : Coin.ZERO;
|
||||
}
|
||||
|
||||
public Stream<XmrAddressEntry> getAddressEntriesForAvailableBalanceStream() {
|
||||
|
|
|
@ -80,7 +80,7 @@ public class TakeOfferModel implements Model {
|
|||
@Getter
|
||||
private Coin totalAvailableBalance;
|
||||
@Getter
|
||||
private Coin balance;
|
||||
private Coin availableBalance;
|
||||
@Getter
|
||||
private boolean isXmrWalletFunded;
|
||||
@Getter
|
||||
|
@ -154,10 +154,10 @@ public class TakeOfferModel implements Model {
|
|||
}
|
||||
|
||||
private void updateBalance() {
|
||||
totalAvailableBalance = xmrWalletService.getSavingWalletBalance();
|
||||
if (totalToPayAsCoin != null) balance = minCoin(totalToPayAsCoin, totalAvailableBalance);
|
||||
missingCoin = offerUtil.getBalanceShortage(totalToPayAsCoin, balance);
|
||||
isXmrWalletFunded = offerUtil.isBalanceSufficient(totalToPayAsCoin, balance);
|
||||
totalAvailableBalance = xmrWalletService.getAvailableBalance();
|
||||
if (totalToPayAsCoin != null) availableBalance = minCoin(totalToPayAsCoin, totalAvailableBalance);
|
||||
missingCoin = offerUtil.getBalanceShortage(totalToPayAsCoin, availableBalance);
|
||||
isXmrWalletFunded = offerUtil.isBalanceSufficient(totalToPayAsCoin, availableBalance);
|
||||
}
|
||||
|
||||
private long getMaxTradeLimit() {
|
||||
|
@ -184,7 +184,7 @@ public class TakeOfferModel implements Model {
|
|||
private void clearModel() {
|
||||
this.addressEntry = null;
|
||||
this.amount = null;
|
||||
this.balance = null;
|
||||
this.availableBalance = null;
|
||||
this.isXmrWalletFunded = false;
|
||||
this.missingCoin = ZERO;
|
||||
this.offer = null;
|
||||
|
@ -212,7 +212,7 @@ public class TakeOfferModel implements Model {
|
|||
", totalToPayAsCoin=" + totalToPayAsCoin + "\n" +
|
||||
", missingCoin=" + missingCoin + "\n" +
|
||||
", totalAvailableBalance=" + totalAvailableBalance + "\n" +
|
||||
", balance=" + balance + "\n" +
|
||||
", availableBalance=" + availableBalance + "\n" +
|
||||
", volume=" + volume + "\n" +
|
||||
", fundsNeededForTrade=" + getFundsNeededForTrade() + "\n" +
|
||||
", isXmrWalletFunded=" + isXmrWalletFunded + "\n" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue