mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Rename availableConfirmedBalance to availableBalance
It does not include only confirmed txs as we include the unconfirmed own change outputs.
This commit is contained in:
parent
dad19ba1c1
commit
88198be7ff
@ -124,7 +124,7 @@ public class BsqWalletTest extends MethodTest {
|
|||||||
genBtcBlocksThenWait(1, 4000);
|
genBtcBlocksThenWait(1, 4000);
|
||||||
|
|
||||||
BsqBalanceInfo alicesBsqBalances = aliceClient.getBalances().getBsq();
|
BsqBalanceInfo alicesBsqBalances = aliceClient.getBalances().getBsq();
|
||||||
BsqBalanceInfo bobsBsqBalances = waitForBsqNewAvailableConfirmedBalance(bobClient, 150000000);
|
BsqBalanceInfo bobsBsqBalances = waitForBsqNewAvailableBalance(bobClient, 150000000);
|
||||||
|
|
||||||
log.debug("See Available Confirmed BSQ Balances...");
|
log.debug("See Available Confirmed BSQ Balances...");
|
||||||
printBobAndAliceBsqBalances(testInfo,
|
printBobAndAliceBsqBalances(testInfo,
|
||||||
@ -166,8 +166,8 @@ public class BsqWalletTest extends MethodTest {
|
|||||||
return bsqBalance;
|
return bsqBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BsqBalanceInfo waitForBsqNewAvailableConfirmedBalance(GrpcClient grpcClient,
|
private BsqBalanceInfo waitForBsqNewAvailableBalance(GrpcClient grpcClient,
|
||||||
long staleBalance) {
|
long staleBalance) {
|
||||||
BsqBalanceInfo bsqBalance = grpcClient.getBsqBalances();
|
BsqBalanceInfo bsqBalance = grpcClient.getBsqBalances();
|
||||||
for (int numRequests = 1;
|
for (int numRequests = 1;
|
||||||
numRequests <= 15 && bsqBalance.getAvailableConfirmedBalance() == staleBalance;
|
numRequests <= 15 && bsqBalance.getAvailableConfirmedBalance() == staleBalance;
|
||||||
|
@ -38,13 +38,13 @@ public class WalletTestUtil {
|
|||||||
0);
|
0);
|
||||||
|
|
||||||
@SuppressWarnings("SameParameterValue")
|
@SuppressWarnings("SameParameterValue")
|
||||||
public static bisq.core.api.model.BsqBalanceInfo bsqBalanceModel(long availableConfirmedBalance,
|
public static bisq.core.api.model.BsqBalanceInfo bsqBalanceModel(long availableBalance,
|
||||||
long unverifiedBalance,
|
long unverifiedBalance,
|
||||||
long unconfirmedChangeBalance,
|
long unconfirmedChangeBalance,
|
||||||
long lockedForVotingBalance,
|
long lockedForVotingBalance,
|
||||||
long lockupBondsBalance,
|
long lockupBondsBalance,
|
||||||
long unlockingBondsBalance) {
|
long unlockingBondsBalance) {
|
||||||
return bisq.core.api.model.BsqBalanceInfo.valueOf(availableConfirmedBalance,
|
return bisq.core.api.model.BsqBalanceInfo.valueOf(availableBalance,
|
||||||
unverifiedBalance,
|
unverifiedBalance,
|
||||||
unconfirmedChangeBalance,
|
unconfirmedChangeBalance,
|
||||||
lockedForVotingBalance,
|
lockedForVotingBalance,
|
||||||
@ -54,7 +54,7 @@ public class WalletTestUtil {
|
|||||||
|
|
||||||
public static void verifyBsqBalances(bisq.core.api.model.BsqBalanceInfo expected,
|
public static void verifyBsqBalances(bisq.core.api.model.BsqBalanceInfo expected,
|
||||||
BsqBalanceInfo actual) {
|
BsqBalanceInfo actual) {
|
||||||
assertEquals(expected.getAvailableConfirmedBalance(), actual.getAvailableConfirmedBalance());
|
assertEquals(expected.getAvailableBalance(), actual.getAvailableConfirmedBalance());
|
||||||
assertEquals(expected.getUnverifiedBalance(), actual.getUnverifiedBalance());
|
assertEquals(expected.getUnverifiedBalance(), actual.getUnverifiedBalance());
|
||||||
assertEquals(expected.getUnconfirmedChangeBalance(), actual.getUnconfirmedChangeBalance());
|
assertEquals(expected.getUnconfirmedChangeBalance(), actual.getUnconfirmedChangeBalance());
|
||||||
assertEquals(expected.getLockedForVotingBalance(), actual.getLockedForVotingBalance());
|
assertEquals(expected.getLockedForVotingBalance(), actual.getLockedForVotingBalance());
|
||||||
|
@ -582,14 +582,14 @@ class CoreWalletsService {
|
|||||||
verifyWalletsAreAvailable();
|
verifyWalletsAreAvailable();
|
||||||
verifyEncryptedWalletIsUnlocked();
|
verifyEncryptedWalletIsUnlocked();
|
||||||
|
|
||||||
var availableConfirmedBalance = bsqWalletService.getAvailableConfirmedBalance();
|
var availableBalance = bsqWalletService.getAvailableBalance();
|
||||||
var unverifiedBalance = bsqWalletService.getUnverifiedBalance();
|
var unverifiedBalance = bsqWalletService.getUnverifiedBalance();
|
||||||
var unconfirmedChangeBalance = bsqWalletService.getUnconfirmedChangeBalance();
|
var unconfirmedChangeBalance = bsqWalletService.getUnconfirmedChangeBalance();
|
||||||
var lockedForVotingBalance = bsqWalletService.getLockedForVotingBalance();
|
var lockedForVotingBalance = bsqWalletService.getLockedForVotingBalance();
|
||||||
var lockupBondsBalance = bsqWalletService.getLockupBondsBalance();
|
var lockupBondsBalance = bsqWalletService.getLockupBondsBalance();
|
||||||
var unlockingBondsBalance = bsqWalletService.getUnlockingBondsBalance();
|
var unlockingBondsBalance = bsqWalletService.getUnlockingBondsBalance();
|
||||||
|
|
||||||
return new BsqBalanceInfo(availableConfirmedBalance.value,
|
return new BsqBalanceInfo(availableBalance.value,
|
||||||
unverifiedBalance.value,
|
unverifiedBalance.value,
|
||||||
unconfirmedChangeBalance.value,
|
unconfirmedChangeBalance.value,
|
||||||
lockedForVotingBalance.value,
|
lockedForVotingBalance.value,
|
||||||
|
@ -17,20 +17,20 @@ public class BsqBalanceInfo implements Payload {
|
|||||||
-1);
|
-1);
|
||||||
|
|
||||||
// All balances are in BSQ satoshis.
|
// All balances are in BSQ satoshis.
|
||||||
private final long availableConfirmedBalance;
|
private final long availableBalance;
|
||||||
private final long unverifiedBalance;
|
private final long unverifiedBalance;
|
||||||
private final long unconfirmedChangeBalance;
|
private final long unconfirmedChangeBalance;
|
||||||
private final long lockedForVotingBalance;
|
private final long lockedForVotingBalance;
|
||||||
private final long lockupBondsBalance;
|
private final long lockupBondsBalance;
|
||||||
private final long unlockingBondsBalance;
|
private final long unlockingBondsBalance;
|
||||||
|
|
||||||
public BsqBalanceInfo(long availableConfirmedBalance,
|
public BsqBalanceInfo(long availableBalance,
|
||||||
long unverifiedBalance,
|
long unverifiedBalance,
|
||||||
long unconfirmedChangeBalance,
|
long unconfirmedChangeBalance,
|
||||||
long lockedForVotingBalance,
|
long lockedForVotingBalance,
|
||||||
long lockupBondsBalance,
|
long lockupBondsBalance,
|
||||||
long unlockingBondsBalance) {
|
long unlockingBondsBalance) {
|
||||||
this.availableConfirmedBalance = availableConfirmedBalance;
|
this.availableBalance = availableBalance;
|
||||||
this.unverifiedBalance = unverifiedBalance;
|
this.unverifiedBalance = unverifiedBalance;
|
||||||
this.unconfirmedChangeBalance = unconfirmedChangeBalance;
|
this.unconfirmedChangeBalance = unconfirmedChangeBalance;
|
||||||
this.lockedForVotingBalance = lockedForVotingBalance;
|
this.lockedForVotingBalance = lockedForVotingBalance;
|
||||||
@ -39,14 +39,14 @@ public class BsqBalanceInfo implements Payload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static BsqBalanceInfo valueOf(long availableConfirmedBalance,
|
public static BsqBalanceInfo valueOf(long availableBalance,
|
||||||
long unverifiedBalance,
|
long unverifiedBalance,
|
||||||
long unconfirmedChangeBalance,
|
long unconfirmedChangeBalance,
|
||||||
long lockedForVotingBalance,
|
long lockedForVotingBalance,
|
||||||
long lockupBondsBalance,
|
long lockupBondsBalance,
|
||||||
long unlockingBondsBalance) {
|
long unlockingBondsBalance) {
|
||||||
// Convenience for creating a model instance instead of a proto.
|
// Convenience for creating a model instance instead of a proto.
|
||||||
return new BsqBalanceInfo(availableConfirmedBalance,
|
return new BsqBalanceInfo(availableBalance,
|
||||||
unverifiedBalance,
|
unverifiedBalance,
|
||||||
unconfirmedChangeBalance,
|
unconfirmedChangeBalance,
|
||||||
lockedForVotingBalance,
|
lockedForVotingBalance,
|
||||||
@ -57,11 +57,11 @@ public class BsqBalanceInfo implements Payload {
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// PROTO BUFFER
|
// PROTO BUFFER
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// TODO rename availableConfirmedBalance in proto if possible
|
||||||
@Override
|
@Override
|
||||||
public bisq.proto.grpc.BsqBalanceInfo toProtoMessage() {
|
public bisq.proto.grpc.BsqBalanceInfo toProtoMessage() {
|
||||||
return bisq.proto.grpc.BsqBalanceInfo.newBuilder()
|
return bisq.proto.grpc.BsqBalanceInfo.newBuilder()
|
||||||
.setAvailableConfirmedBalance(availableConfirmedBalance)
|
.setAvailableConfirmedBalance(availableBalance)
|
||||||
.setUnverifiedBalance(unverifiedBalance)
|
.setUnverifiedBalance(unverifiedBalance)
|
||||||
.setUnconfirmedChangeBalance(unconfirmedChangeBalance)
|
.setUnconfirmedChangeBalance(unconfirmedChangeBalance)
|
||||||
.setLockedForVotingBalance(lockedForVotingBalance)
|
.setLockedForVotingBalance(lockedForVotingBalance)
|
||||||
@ -83,7 +83,7 @@ public class BsqBalanceInfo implements Payload {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "BsqBalanceInfo{" +
|
return "BsqBalanceInfo{" +
|
||||||
"availableConfirmedBalance=" + availableConfirmedBalance +
|
"availableBalance=" + availableBalance +
|
||||||
", unverifiedBalance=" + unverifiedBalance +
|
", unverifiedBalance=" + unverifiedBalance +
|
||||||
", unconfirmedChangeBalance=" + unconfirmedChangeBalance +
|
", unconfirmedChangeBalance=" + unconfirmedChangeBalance +
|
||||||
", lockedForVotingBalance=" + lockedForVotingBalance +
|
", lockedForVotingBalance=" + lockedForVotingBalance +
|
||||||
|
@ -20,7 +20,7 @@ package bisq.core.btc.listeners;
|
|||||||
import org.bitcoinj.core.Coin;
|
import org.bitcoinj.core.Coin;
|
||||||
|
|
||||||
public interface BsqBalanceListener {
|
public interface BsqBalanceListener {
|
||||||
void onUpdateBalances(Coin availableConfirmedBalance,
|
void onUpdateBalances(Coin availableBalance,
|
||||||
Coin availableNonBsqBalance,
|
Coin availableNonBsqBalance,
|
||||||
Coin unverifiedBalance,
|
Coin unverifiedBalance,
|
||||||
Coin unconfirmedChangeBalance,
|
Coin unconfirmedChangeBalance,
|
||||||
|
@ -100,7 +100,7 @@ public class BsqWalletService extends WalletService implements DaoStateListener
|
|||||||
@Getter
|
@Getter
|
||||||
private Coin availableNonBsqBalance = Coin.ZERO;
|
private Coin availableNonBsqBalance = Coin.ZERO;
|
||||||
@Getter
|
@Getter
|
||||||
private Coin availableConfirmedBalance = Coin.ZERO;
|
private Coin availableBalance = Coin.ZERO;
|
||||||
@Getter
|
@Getter
|
||||||
private Coin unverifiedBalance = Coin.ZERO;
|
private Coin unverifiedBalance = Coin.ZERO;
|
||||||
@Getter
|
@Getter
|
||||||
@ -284,18 +284,18 @@ public class BsqWalletService extends WalletService implements DaoStateListener
|
|||||||
.mapToLong(TxOutput::getValue)
|
.mapToLong(TxOutput::getValue)
|
||||||
.sum());
|
.sum());
|
||||||
|
|
||||||
availableConfirmedBalance = bsqCoinSelector.select(NetworkParameters.MAX_MONEY,
|
availableBalance = bsqCoinSelector.select(NetworkParameters.MAX_MONEY,
|
||||||
wallet.calculateAllSpendCandidates()).valueGathered;
|
wallet.calculateAllSpendCandidates()).valueGathered;
|
||||||
|
|
||||||
if (availableConfirmedBalance.isNegative())
|
if (availableBalance.isNegative())
|
||||||
availableConfirmedBalance = Coin.ZERO;
|
availableBalance = Coin.ZERO;
|
||||||
|
|
||||||
unconfirmedChangeBalance = unconfirmedBsqChangeOutputListService.getBalance();
|
unconfirmedChangeBalance = unconfirmedBsqChangeOutputListService.getBalance();
|
||||||
|
|
||||||
availableNonBsqBalance = nonBsqCoinSelector.select(NetworkParameters.MAX_MONEY,
|
availableNonBsqBalance = nonBsqCoinSelector.select(NetworkParameters.MAX_MONEY,
|
||||||
wallet.calculateAllSpendCandidates()).valueGathered;
|
wallet.calculateAllSpendCandidates()).valueGathered;
|
||||||
|
|
||||||
bsqBalanceListeners.forEach(e -> e.onUpdateBalances(availableConfirmedBalance, availableNonBsqBalance, unverifiedBalance,
|
bsqBalanceListeners.forEach(e -> e.onUpdateBalances(availableBalance, availableNonBsqBalance, unverifiedBalance,
|
||||||
unconfirmedChangeBalance, lockedForVotingBalance, lockupBondsBalance, unlockingBondsBalance));
|
unconfirmedChangeBalance, lockedForVotingBalance, lockupBondsBalance, unlockingBondsBalance));
|
||||||
log.info("updateBsqBalance took {} ms", System.currentTimeMillis() - ts);
|
log.info("updateBsqBalance took {} ms", System.currentTimeMillis() - ts);
|
||||||
}
|
}
|
||||||
|
@ -482,7 +482,7 @@ public abstract class WalletService {
|
|||||||
// Balance
|
// Balance
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public Coin getAvailableConfirmedBalance() {
|
public Coin getAvailableBalance() {
|
||||||
return wallet != null ? wallet.getBalance(Wallet.BalanceType.AVAILABLE) : Coin.ZERO;
|
return wallet != null ? wallet.getBalance(Wallet.BalanceType.AVAILABLE) : Coin.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,7 +860,7 @@ public abstract class WalletService {
|
|||||||
if (balanceListener.getAddress() != null)
|
if (balanceListener.getAddress() != null)
|
||||||
balance = getBalanceForAddress(balanceListener.getAddress());
|
balance = getBalanceForAddress(balanceListener.getAddress());
|
||||||
else
|
else
|
||||||
balance = getAvailableConfirmedBalance();
|
balance = getAvailableBalance();
|
||||||
|
|
||||||
balanceListener.onBalanceChanged(balance, tx);
|
balanceListener.onBalanceChanged(balance, tx);
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ public class OfferUtil {
|
|||||||
// We have to keep a minimum amount of BSQ == bitcoin dust limit, otherwise there
|
// We have to keep a minimum amount of BSQ == bitcoin dust limit, otherwise there
|
||||||
// would be dust violations for change UTXOs; essentially means the minimum usable
|
// would be dust violations for change UTXOs; essentially means the minimum usable
|
||||||
// balance of BSQ is 5.46.
|
// balance of BSQ is 5.46.
|
||||||
Coin usableBsqBalance = bsqWalletService.getAvailableConfirmedBalance().subtract(getMinNonDustOutput());
|
Coin usableBsqBalance = bsqWalletService.getAvailableBalance().subtract(getMinNonDustOutput());
|
||||||
return usableBsqBalance.isNegative() ? Coin.ZERO : usableBsqBalance;
|
return usableBsqBalance.isNegative() ? Coin.ZERO : usableBsqBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ public class OfferUtil {
|
|||||||
* @return {@code true} if the balance is sufficient, {@code false} otherwise
|
* @return {@code true} if the balance is sufficient, {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isBsqForMakerFeeAvailable(@Nullable Coin amount) {
|
public boolean isBsqForMakerFeeAvailable(@Nullable Coin amount) {
|
||||||
Coin availableBalance = bsqWalletService.getAvailableConfirmedBalance();
|
Coin availableBalance = bsqWalletService.getAvailableBalance();
|
||||||
Coin makerFee = CoinUtil.getMakerFee(false, amount);
|
Coin makerFee = CoinUtil.getMakerFee(false, amount);
|
||||||
|
|
||||||
// If we don't know yet the maker fee (amount is not set) we return true,
|
// If we don't know yet the maker fee (amount is not set) we return true,
|
||||||
@ -277,7 +277,7 @@ public class OfferUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBsqForTakerFeeAvailable(@Nullable Coin amount) {
|
public boolean isBsqForTakerFeeAvailable(@Nullable Coin amount) {
|
||||||
Coin availableBalance = bsqWalletService.getAvailableConfirmedBalance();
|
Coin availableBalance = bsqWalletService.getAvailableBalance();
|
||||||
Coin takerFee = getTakerFee(false, amount);
|
Coin takerFee = getTakerFee(false, amount);
|
||||||
|
|
||||||
// If we don't know yet the maker fee (amount is not set) we return true,
|
// If we don't know yet the maker fee (amount is not set) we return true,
|
||||||
|
@ -217,14 +217,14 @@ public class MyReputationView extends ActivatableView<GridPane, Void> implements
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateBalances(Coin availableConfirmedBalance,
|
public void onUpdateBalances(Coin availableBalance,
|
||||||
Coin availableNonBsqBalance,
|
Coin availableNonBsqBalance,
|
||||||
Coin unverifiedBalance,
|
Coin unverifiedBalance,
|
||||||
Coin unconfirmedChangeBalance,
|
Coin unconfirmedChangeBalance,
|
||||||
Coin lockedForVotingBalance,
|
Coin lockedForVotingBalance,
|
||||||
Coin lockupBondsBalance,
|
Coin lockupBondsBalance,
|
||||||
Coin unlockingBondsBalance) {
|
Coin unlockingBondsBalance) {
|
||||||
bsqValidator.setAvailableBalance(availableConfirmedBalance);
|
bsqValidator.setAvailableBalance(availableBalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public class AssetFeeView extends ActivatableView<GridPane, Void> implements Bsq
|
|||||||
assetService.updateAssetStates();
|
assetService.updateAssetStates();
|
||||||
updateList();
|
updateList();
|
||||||
|
|
||||||
onUpdateAvailableConfirmedBalance(bsqWalletService.getAvailableConfirmedBalance());
|
onUpdateAvailableBalance(bsqWalletService.getAvailableBalance());
|
||||||
|
|
||||||
payFeeButton.setOnAction((event) -> {
|
payFeeButton.setOnAction((event) -> {
|
||||||
Coin listingFee = getListingFee();
|
Coin listingFee = getListingFee();
|
||||||
@ -235,7 +235,7 @@ public class AssetFeeView extends ActivatableView<GridPane, Void> implements Bsq
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateBalances(Coin availableConfirmedBalance,
|
public void onUpdateBalances(Coin availableBalance,
|
||||||
Coin availableNonBsqBalance,
|
Coin availableNonBsqBalance,
|
||||||
Coin unverifiedBalance,
|
Coin unverifiedBalance,
|
||||||
Coin unconfirmedChangeBalance,
|
Coin unconfirmedChangeBalance,
|
||||||
@ -243,7 +243,7 @@ public class AssetFeeView extends ActivatableView<GridPane, Void> implements Bsq
|
|||||||
Coin lockupBondsBalance,
|
Coin lockupBondsBalance,
|
||||||
Coin unlockingBondsBalance) {
|
Coin unlockingBondsBalance) {
|
||||||
|
|
||||||
onUpdateAvailableConfirmedBalance(availableConfirmedBalance);
|
onUpdateAvailableBalance(availableBalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -278,8 +278,8 @@ public class AssetFeeView extends ActivatableView<GridPane, Void> implements Bsq
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUpdateAvailableConfirmedBalance(Coin availableConfirmedBalance) {
|
private void onUpdateAvailableBalance(Coin availableBalance) {
|
||||||
bsqValidator.setAvailableBalance(availableConfirmedBalance);
|
bsqValidator.setAvailableBalance(availableBalance);
|
||||||
updateButtonState();
|
updateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ public class ProofOfBurnView extends ActivatableView<GridPane, Void> implements
|
|||||||
|
|
||||||
proofOfBurnService.getUpdateFlag().addListener(updateListener);
|
proofOfBurnService.getUpdateFlag().addListener(updateListener);
|
||||||
bsqWalletService.addBsqBalanceListener(this);
|
bsqWalletService.addBsqBalanceListener(this);
|
||||||
onUpdateAvailableConfirmedBalance(bsqWalletService.getAvailableConfirmedBalance());
|
onUpdateAvailableBalance(bsqWalletService.getAvailableBalance());
|
||||||
|
|
||||||
burnButton.setOnAction((event) -> {
|
burnButton.setOnAction((event) -> {
|
||||||
Coin amount = getAmountFee();
|
Coin amount = getAmountFee();
|
||||||
@ -216,14 +216,14 @@ public class ProofOfBurnView extends ActivatableView<GridPane, Void> implements
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateBalances(Coin availableConfirmedBalance,
|
public void onUpdateBalances(Coin availableBalance,
|
||||||
Coin availableNonBsqBalance,
|
Coin availableNonBsqBalance,
|
||||||
Coin unverifiedBalance,
|
Coin unverifiedBalance,
|
||||||
Coin unconfirmedChangeBalance,
|
Coin unconfirmedChangeBalance,
|
||||||
Coin lockedForVotingBalance,
|
Coin lockedForVotingBalance,
|
||||||
Coin lockupBondsBalance,
|
Coin lockupBondsBalance,
|
||||||
Coin unlockingBondsBalance) {
|
Coin unlockingBondsBalance) {
|
||||||
onUpdateAvailableConfirmedBalance(availableConfirmedBalance);
|
onUpdateAvailableBalance(availableBalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -255,8 +255,8 @@ public class ProofOfBurnView extends ActivatableView<GridPane, Void> implements
|
|||||||
updateListener = observable -> updateList();
|
updateListener = observable -> updateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUpdateAvailableConfirmedBalance(Coin availableConfirmedBalance) {
|
private void onUpdateAvailableBalance(Coin availableBalance) {
|
||||||
bsqValidator.setAvailableBalance(availableConfirmedBalance);
|
bsqValidator.setAvailableBalance(availableBalance);
|
||||||
updateButtonState();
|
updateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ import bisq.core.dao.state.model.governance.Proposal;
|
|||||||
import bisq.core.dao.state.model.governance.Role;
|
import bisq.core.dao.state.model.governance.Role;
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
import bisq.core.util.FormattingUtils;
|
import bisq.core.util.FormattingUtils;
|
||||||
import bisq.core.util.coin.BsqFormatter;
|
|
||||||
import bisq.core.util.ParsingUtils;
|
import bisq.core.util.ParsingUtils;
|
||||||
|
import bisq.core.util.coin.BsqFormatter;
|
||||||
import bisq.core.util.coin.CoinFormatter;
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
import bisq.asset.Asset;
|
import bisq.asset.Asset;
|
||||||
@ -291,7 +291,7 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> implements
|
|||||||
checkNotNull(proposalDisplay.bondedRoleTypeComboBox, "proposalDisplay.bondedRoleTypeComboBox must not be null");
|
checkNotNull(proposalDisplay.bondedRoleTypeComboBox, "proposalDisplay.bondedRoleTypeComboBox must not be null");
|
||||||
BondedRoleType bondedRoleType = proposalDisplay.bondedRoleTypeComboBox.getSelectionModel().getSelectedItem();
|
BondedRoleType bondedRoleType = proposalDisplay.bondedRoleTypeComboBox.getSelectionModel().getSelectedItem();
|
||||||
long requiredBond = daoFacade.getRequiredBond(bondedRoleType);
|
long requiredBond = daoFacade.getRequiredBond(bondedRoleType);
|
||||||
long availableBalance = bsqWalletService.getAvailableConfirmedBalance().value;
|
long availableBalance = bsqWalletService.getAvailableBalance().value;
|
||||||
|
|
||||||
if (requiredBond > availableBalance) {
|
if (requiredBond > availableBalance) {
|
||||||
long missing = requiredBond - availableBalance;
|
long missing = requiredBond - availableBalance;
|
||||||
|
@ -222,7 +222,7 @@ public class ProposalsView extends ActivatableView<GridPane, Void> implements Bs
|
|||||||
stakeInputTextField.textProperty().addListener(stakeListener);
|
stakeInputTextField.textProperty().addListener(stakeListener);
|
||||||
voteButton.setOnAction(e -> onVote());
|
voteButton.setOnAction(e -> onVote());
|
||||||
|
|
||||||
onUpdateBalances(bsqWalletService.getAvailableConfirmedBalance(),
|
onUpdateBalances(bsqWalletService.getAvailableBalance(),
|
||||||
bsqWalletService.getAvailableNonBsqBalance(),
|
bsqWalletService.getAvailableNonBsqBalance(),
|
||||||
bsqWalletService.getUnverifiedBalance(),
|
bsqWalletService.getUnverifiedBalance(),
|
||||||
bsqWalletService.getUnconfirmedChangeBalance(),
|
bsqWalletService.getUnconfirmedChangeBalance(),
|
||||||
@ -272,7 +272,7 @@ public class ProposalsView extends ActivatableView<GridPane, Void> implements Bs
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateBalances(Coin availableConfirmedBalance,
|
public void onUpdateBalances(Coin availableBalance,
|
||||||
Coin availableNonBsqBalance,
|
Coin availableNonBsqBalance,
|
||||||
Coin unverifiedBalance,
|
Coin unverifiedBalance,
|
||||||
Coin unconfirmedChangeBalance,
|
Coin unconfirmedChangeBalance,
|
||||||
@ -281,7 +281,7 @@ public class ProposalsView extends ActivatableView<GridPane, Void> implements Bs
|
|||||||
Coin unlockingBondsBalance) {
|
Coin unlockingBondsBalance) {
|
||||||
Coin blindVoteFee = BlindVoteConsensus.getFee(daoStateService, daoStateService.getChainHeight());
|
Coin blindVoteFee = BlindVoteConsensus.getFee(daoStateService, daoStateService.getChainHeight());
|
||||||
if (isBlindVotePhaseButNotLastBlock()) {
|
if (isBlindVotePhaseButNotLastBlock()) {
|
||||||
Coin availableForVoting = availableConfirmedBalance.subtract(blindVoteFee);
|
Coin availableForVoting = availableBalance.subtract(blindVoteFee);
|
||||||
if (availableForVoting.isNegative())
|
if (availableForVoting.isNegative())
|
||||||
availableForVoting = Coin.valueOf(0);
|
availableForVoting = Coin.valueOf(0);
|
||||||
stakeInputTextField.setPromptText(Res.get("dao.proposal.myVote.stake.prompt",
|
stakeInputTextField.setPromptText(Res.get("dao.proposal.myVote.stake.prompt",
|
||||||
|
@ -135,7 +135,7 @@ public class BsqBalanceUtil implements BsqBalanceListener, DaoStateListener {
|
|||||||
|
|
||||||
|
|
||||||
private void triggerUpdate() {
|
private void triggerUpdate() {
|
||||||
onUpdateBalances(bsqWalletService.getAvailableConfirmedBalance(),
|
onUpdateBalances(bsqWalletService.getAvailableBalance(),
|
||||||
bsqWalletService.getAvailableNonBsqBalance(),
|
bsqWalletService.getAvailableNonBsqBalance(),
|
||||||
bsqWalletService.getUnverifiedBalance(),
|
bsqWalletService.getUnverifiedBalance(),
|
||||||
bsqWalletService.getUnconfirmedChangeBalance(),
|
bsqWalletService.getUnconfirmedChangeBalance(),
|
||||||
|
@ -242,14 +242,14 @@ public class BsqSendView extends ActivatableView<GridPane, Void> implements BsqB
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateBalances(Coin availableConfirmedBalance,
|
public void onUpdateBalances(Coin availableBalance,
|
||||||
Coin availableNonBsqBalance,
|
Coin availableNonBsqBalance,
|
||||||
Coin unverifiedBalance,
|
Coin unverifiedBalance,
|
||||||
Coin unconfirmedChangeBalance,
|
Coin unconfirmedChangeBalance,
|
||||||
Coin lockedForVotingBalance,
|
Coin lockedForVotingBalance,
|
||||||
Coin lockupBondsBalance,
|
Coin lockupBondsBalance,
|
||||||
Coin unlockingBondsBalance) {
|
Coin unlockingBondsBalance) {
|
||||||
updateBsqValidator(availableConfirmedBalance);
|
updateBsqValidator(availableBalance);
|
||||||
updateBtcValidator(availableNonBsqBalance);
|
updateBtcValidator(availableNonBsqBalance);
|
||||||
|
|
||||||
setSendBtcGroupVisibleState(availableNonBsqBalance.isPositive());
|
setSendBtcGroupVisibleState(availableNonBsqBalance.isPositive());
|
||||||
@ -260,15 +260,15 @@ public class BsqSendView extends ActivatableView<GridPane, Void> implements BsqB
|
|||||||
receiversAddressInputTextField.setText(tuple.second);
|
receiversAddressInputTextField.setText(tuple.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBsqValidator(Coin availableConfirmedBalance) {
|
private void updateBsqValidator(Coin availableBalance) {
|
||||||
bsqValidator.setAvailableBalance(availableConfirmedBalance);
|
bsqValidator.setAvailableBalance(availableBalance);
|
||||||
boolean isValid = bsqAddressValidator.validate(receiversAddressInputTextField.getText()).isValid &&
|
boolean isValid = bsqAddressValidator.validate(receiversAddressInputTextField.getText()).isValid &&
|
||||||
bsqValidator.validate(amountInputTextField.getText()).isValid;
|
bsqValidator.validate(amountInputTextField.getText()).isValid;
|
||||||
sendBsqButton.setDisable(!isValid);
|
sendBsqButton.setDisable(!isValid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBtcValidator(Coin availableConfirmedBalance) {
|
private void updateBtcValidator(Coin availableBalance) {
|
||||||
btcValidator.setMaxValue(availableConfirmedBalance);
|
btcValidator.setMaxValue(availableBalance);
|
||||||
boolean isValid = btcAddressValidator.validate(receiversBtcAddressInputTextField.getText()).isValid &&
|
boolean isValid = btcAddressValidator.validate(receiversBtcAddressInputTextField.getText()).isValid &&
|
||||||
btcValidator.validate(btcAmountInputTextField.getText()).isValid;
|
btcValidator.validate(btcAmountInputTextField.getText()).isValid;
|
||||||
sendBtcButton.setDisable(!isValid);
|
sendBtcButton.setDisable(!isValid);
|
||||||
@ -359,11 +359,11 @@ public class BsqSendView extends ActivatableView<GridPane, Void> implements BsqB
|
|||||||
amountInputTextField.refreshValidation();
|
amountInputTextField.refreshValidation();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have used input selection it is the sum of our selected inputs, otherwise the availableConfirmedBalance
|
// We have used input selection it is the sum of our selected inputs, otherwise the availableBalance
|
||||||
private Coin getSpendableBsqBalance() {
|
private Coin getSpendableBsqBalance() {
|
||||||
return bsqUtxoCandidates != null ?
|
return bsqUtxoCandidates != null ?
|
||||||
Coin.valueOf(bsqUtxoCandidates.stream().mapToLong(e -> e.getValue().value).sum()) :
|
Coin.valueOf(bsqUtxoCandidates.stream().mapToLong(e -> e.getValue().value).sum()) :
|
||||||
bsqWalletService.getAvailableConfirmedBalance();
|
bsqWalletService.getAvailableBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSendBtcGroupVisibleState(boolean visible) {
|
private void setSendBtcGroupVisibleState(boolean visible) {
|
||||||
|
@ -268,7 +268,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateBalances(Coin availableConfirmedBalance,
|
public void onUpdateBalances(Coin availableBalance,
|
||||||
Coin availableNonBsqBalance,
|
Coin availableNonBsqBalance,
|
||||||
Coin unverifiedBalance,
|
Coin unverifiedBalance,
|
||||||
Coin unconfirmedChangeBalance,
|
Coin unconfirmedChangeBalance,
|
||||||
|
@ -420,7 +420,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateBalances(Coin availableConfirmedBalance,
|
public void onUpdateBalances(Coin availableBalance,
|
||||||
Coin availableNonBsqBalance,
|
Coin availableNonBsqBalance,
|
||||||
Coin unverifiedBalance,
|
Coin unverifiedBalance,
|
||||||
Coin unconfirmedChangeBalance,
|
Coin unconfirmedChangeBalance,
|
||||||
|
@ -672,7 +672,7 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||||||
// we have to keep a minimum amount of BSQ == bitcoin dust limit
|
// we have to keep a minimum amount of BSQ == bitcoin dust limit
|
||||||
// otherwise there would be dust violations for change UTXOs
|
// otherwise there would be dust violations for change UTXOs
|
||||||
// essentially means the minimum usable balance of BSQ is 5.46
|
// essentially means the minimum usable balance of BSQ is 5.46
|
||||||
Coin usableBsqBalance = bsqWalletService.getAvailableConfirmedBalance().subtract(Restrictions.getMinNonDustOutput());
|
Coin usableBsqBalance = bsqWalletService.getAvailableBalance().subtract(Restrictions.getMinNonDustOutput());
|
||||||
if (usableBsqBalance.isNegative())
|
if (usableBsqBalance.isNegative())
|
||||||
usableBsqBalance = Coin.ZERO;
|
usableBsqBalance = Coin.ZERO;
|
||||||
return usableBsqBalance;
|
return usableBsqBalance;
|
||||||
|
@ -60,7 +60,7 @@ public final class BsqEmptyWalletWindow extends Overlay<BsqEmptyWalletWindow> {
|
|||||||
gridPane.getColumnConstraints().remove(1);
|
gridPane.getColumnConstraints().remove(1);
|
||||||
|
|
||||||
addTopLabelTextField(gridPane, ++rowIndex, Res.get("emptyWalletWindow.balance"),
|
addTopLabelTextField(gridPane, ++rowIndex, Res.get("emptyWalletWindow.balance"),
|
||||||
bsqFormatter.formatCoinWithCode(bsqWalletService.getAvailableConfirmedBalance()), 10);
|
bsqFormatter.formatCoinWithCode(bsqWalletService.getAvailableBalance()), 10);
|
||||||
|
|
||||||
addTopLabelTextField(gridPane, ++rowIndex, Res.get("emptyWalletWindow.bsq.btcBalance"),
|
addTopLabelTextField(gridPane, ++rowIndex, Res.get("emptyWalletWindow.bsq.btcBalance"),
|
||||||
bsqFormatter.formatBTCWithCode(bsqWalletService.getAvailableNonBsqBalance().value), 10);
|
bsqFormatter.formatBTCWithCode(bsqWalletService.getAvailableNonBsqBalance().value), 10);
|
||||||
|
@ -103,7 +103,7 @@ public final class BtcEmptyWalletWindow extends Overlay<BtcEmptyWalletWindow> {
|
|||||||
private void addContent() {
|
private void addContent() {
|
||||||
addMultilineLabel(gridPane, ++rowIndex, Res.get("emptyWalletWindow.info"), 0);
|
addMultilineLabel(gridPane, ++rowIndex, Res.get("emptyWalletWindow.info"), 0);
|
||||||
|
|
||||||
Coin totalBalance = btcWalletService.getAvailableConfirmedBalance();
|
Coin totalBalance = btcWalletService.getAvailableBalance();
|
||||||
balanceTextField = addTopLabelTextField(gridPane, ++rowIndex, Res.get("emptyWalletWindow.balance"),
|
balanceTextField = addTopLabelTextField(gridPane, ++rowIndex, Res.get("emptyWalletWindow.balance"),
|
||||||
btcFormatter.formatCoinWithCode(totalBalance), 10).second;
|
btcFormatter.formatCoinWithCode(totalBalance), 10).second;
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ public final class BtcEmptyWalletWindow extends Overlay<BtcEmptyWalletWindow> {
|
|||||||
aesKey,
|
aesKey,
|
||||||
() -> {
|
() -> {
|
||||||
closeButton.updateText(Res.get("shared.close"));
|
closeButton.updateText(Res.get("shared.close"));
|
||||||
balanceTextField.setText(btcFormatter.formatCoinWithCode(btcWalletService.getAvailableConfirmedBalance()));
|
balanceTextField.setText(btcFormatter.formatCoinWithCode(btcWalletService.getAvailableBalance()));
|
||||||
emptyWalletButton.setDisable(true);
|
emptyWalletButton.setDisable(true);
|
||||||
log.debug("wallet empty successful");
|
log.debug("wallet empty successful");
|
||||||
onClose(() -> UserThread.runAfter(() -> new Popup()
|
onClose(() -> UserThread.runAfter(() -> new Popup()
|
||||||
|
@ -119,7 +119,7 @@ public class CreateOfferViewModelTest {
|
|||||||
when(accountAgeWitnessService.getMyTradeLimit(any(), any(), any())).thenReturn(100000000L);
|
when(accountAgeWitnessService.getMyTradeLimit(any(), any(), any())).thenReturn(100000000L);
|
||||||
when(preferences.getUserCountry()).thenReturn(new Country("ES", "Spain", null));
|
when(preferences.getUserCountry()).thenReturn(new Country("ES", "Spain", null));
|
||||||
when(bsqFormatter.formatCoin(any())).thenReturn("0");
|
when(bsqFormatter.formatCoin(any())).thenReturn("0");
|
||||||
when(bsqWalletService.getAvailableConfirmedBalance()).thenReturn(Coin.ZERO);
|
when(bsqWalletService.getAvailableBalance()).thenReturn(Coin.ZERO);
|
||||||
when(createOfferService.getRandomOfferId()).thenReturn(UUID.randomUUID().toString());
|
when(createOfferService.getRandomOfferId()).thenReturn(UUID.randomUUID().toString());
|
||||||
when(tradeStats.getObservableTradeStatisticsSet()).thenReturn(FXCollections.observableSet());
|
when(tradeStats.getObservableTradeStatisticsSet()).thenReturn(FXCollections.observableSet());
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public class EditOfferDataModelTest {
|
|||||||
when(accountAgeWitnessService.getMyTradeLimit(any(), any(), any())).thenReturn(100000000L);
|
when(accountAgeWitnessService.getMyTradeLimit(any(), any(), any())).thenReturn(100000000L);
|
||||||
when(preferences.getUserCountry()).thenReturn(new Country("US", "United States", null));
|
when(preferences.getUserCountry()).thenReturn(new Country("US", "United States", null));
|
||||||
when(bsqFormatter.formatCoin(any())).thenReturn("0");
|
when(bsqFormatter.formatCoin(any())).thenReturn("0");
|
||||||
when(bsqWalletService.getAvailableConfirmedBalance()).thenReturn(Coin.ZERO);
|
when(bsqWalletService.getAvailableBalance()).thenReturn(Coin.ZERO);
|
||||||
when(createOfferService.getRandomOfferId()).thenReturn(UUID.randomUUID().toString());
|
when(createOfferService.getRandomOfferId()).thenReturn(UUID.randomUUID().toString());
|
||||||
|
|
||||||
model = new EditOfferDataModel(createOfferService,
|
model = new EditOfferDataModel(createOfferService,
|
||||||
|
@ -620,7 +620,7 @@ message BalancesInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message BsqBalanceInfo {
|
message BsqBalanceInfo {
|
||||||
uint64 availableConfirmedBalance = 1;
|
uint64 availableConfirmedBalance = 1; // todo rename to availableBalance if possible
|
||||||
uint64 unverifiedBalance = 2;
|
uint64 unverifiedBalance = 2;
|
||||||
uint64 unconfirmedChangeBalance = 3;
|
uint64 unconfirmedChangeBalance = 3;
|
||||||
uint64 lockedForVotingBalance = 4;
|
uint64 lockedForVotingBalance = 4;
|
||||||
|
Loading…
Reference in New Issue
Block a user