mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-05-20 07:20:41 -04:00
Savings wallet, fixed wrong access to trade wallet (WIP)
This commit is contained in:
parent
59b41c7a4f
commit
f07aa9ba6a
8 changed files with 161 additions and 109 deletions
|
@ -205,25 +205,6 @@ public class DepositView extends ActivatableView<VBox, Void> {
|
|||
};
|
||||
}
|
||||
|
||||
private Coin getAmountAsCoin() {
|
||||
Coin senderAmount = formatter.parseToCoin(amountTextField.getText());
|
||||
if (!Restrictions.isAboveFixedTxFeeAndDust(senderAmount)) {
|
||||
senderAmount = Coin.ZERO;
|
||||
/* new Popup()
|
||||
.warning("The amount is lower than the transaction fee and the min. possible tx value (dust).")
|
||||
.show();*/
|
||||
}
|
||||
return senderAmount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getBitcoinURI() {
|
||||
return BitcoinURI.convertToBitcoinURI(addressTextField.getAddress(),
|
||||
getAmountAsCoin(),
|
||||
paymentLabel,
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
tableView.getSelectionModel().selectedItemProperty().addListener(tableViewSelectionListener);
|
||||
|
@ -236,6 +217,9 @@ public class DepositView extends ActivatableView<VBox, Void> {
|
|||
addressTextField.setAmountAsCoin(formatter.parseToCoin(t));
|
||||
updateQRCode();
|
||||
});
|
||||
|
||||
if (tableView.getSelectionModel().getSelectedItem() == null && !sortedList.isEmpty())
|
||||
tableView.getSelectionModel().select(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -309,6 +293,24 @@ public class DepositView extends ActivatableView<VBox, Void> {
|
|||
.forEach(e -> observableList.add(new DepositListItem(e, walletService, formatter)));
|
||||
}
|
||||
|
||||
private Coin getAmountAsCoin() {
|
||||
Coin senderAmount = formatter.parseToCoin(amountTextField.getText());
|
||||
if (!Restrictions.isAboveFixedTxFeeAndDust(senderAmount)) {
|
||||
senderAmount = Coin.ZERO;
|
||||
/* new Popup()
|
||||
.warning("The amount is lower than the transaction fee and the min. possible tx value (dust).")
|
||||
.show();*/
|
||||
}
|
||||
return senderAmount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getBitcoinURI() {
|
||||
return BitcoinURI.convertToBitcoinURI(addressTextField.getAddress(),
|
||||
getAmountAsCoin(),
|
||||
paymentLabel,
|
||||
null);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ColumnCellFactories
|
||||
|
|
|
@ -228,7 +228,6 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
|
||||
calculateVolume();
|
||||
calculateTotalToPay();
|
||||
updateBalance();
|
||||
}
|
||||
|
||||
void onTabSelected(boolean isSelected) {
|
||||
|
@ -394,11 +393,13 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
}
|
||||
|
||||
void calculateTotalToPay() {
|
||||
if (securityDepositAsCoin != null) {
|
||||
if (direction != null && amountAsCoin.get() != null) {
|
||||
Coin feeAndSecDeposit = offerFeeAsCoin.add(networkFeeAsCoin).add(securityDepositAsCoin);
|
||||
Coin feeAndSecDepositAndAmount = feeAndSecDeposit.add(amountAsCoin.get() == null ? Coin.ZERO : amountAsCoin.get());
|
||||
Coin feeAndSecDepositAndAmount = feeAndSecDeposit.add(amountAsCoin.get());
|
||||
Coin required = direction == Offer.Direction.BUY ? feeAndSecDeposit : feeAndSecDepositAndAmount;
|
||||
totalToPayAsCoin.set(required);
|
||||
log.debug("totalToPayAsCoin " + totalToPayAsCoin.get().toFriendlyString());
|
||||
updateBalance();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,11 +408,12 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
if (useSavingsWallet) {
|
||||
Coin savingWalletBalance = walletService.getSavingWalletBalance();
|
||||
totalAvailableBalance = savingWalletBalance.add(tradeWalletBalance);
|
||||
|
||||
if (totalToPayAsCoin.get() != null && totalAvailableBalance.compareTo(totalToPayAsCoin.get()) > 0)
|
||||
balance.set(totalToPayAsCoin.get());
|
||||
else
|
||||
balance.set(totalAvailableBalance);
|
||||
if (totalToPayAsCoin.get() != null) {
|
||||
if (totalAvailableBalance.compareTo(totalToPayAsCoin.get()) > 0)
|
||||
balance.set(totalToPayAsCoin.get());
|
||||
else
|
||||
balance.set(totalAvailableBalance);
|
||||
}
|
||||
} else {
|
||||
balance.set(tradeWalletBalance);
|
||||
}
|
||||
|
@ -422,6 +424,8 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
missingCoin.set(Coin.ZERO);
|
||||
}
|
||||
|
||||
log.debug("missingCoin " + missingCoin.get().toFriendlyString());
|
||||
|
||||
isWalletFunded.set(isBalanceSufficient(balance.get()));
|
||||
if (totalToPayAsCoin.get() != null && isWalletFunded.get() && walletFundedNotification == null) {
|
||||
walletFundedNotification = new Notification()
|
||||
|
|
|
@ -176,7 +176,6 @@ class TakeOfferDataModel extends ActivatableDataModel {
|
|||
|
||||
calculateVolume();
|
||||
calculateTotalToPay();
|
||||
updateBalance();
|
||||
|
||||
balanceListener = new BalanceListener(addressEntry.getAddress()) {
|
||||
@Override
|
||||
|
@ -325,11 +324,21 @@ class TakeOfferDataModel extends ActivatableDataModel {
|
|||
}
|
||||
}
|
||||
|
||||
void setAmount(Coin amount) {
|
||||
amountAsCoin.set(amount);
|
||||
calculateTotalToPay();
|
||||
}
|
||||
|
||||
void calculateTotalToPay() {
|
||||
if (getDirection() == Offer.Direction.SELL)
|
||||
totalToPayAsCoin.set(takerFeeAsCoin.add(networkFeeAsCoin).add(securityDepositAsCoin));
|
||||
else
|
||||
totalToPayAsCoin.set(takerFeeAsCoin.add(networkFeeAsCoin).add(securityDepositAsCoin).add(amountAsCoin.get()));
|
||||
if (offer != null && amountAsCoin.get() != null) {
|
||||
if (getDirection() == Offer.Direction.SELL)
|
||||
totalToPayAsCoin.set(takerFeeAsCoin.add(networkFeeAsCoin).add(securityDepositAsCoin));
|
||||
else
|
||||
totalToPayAsCoin.set(takerFeeAsCoin.add(networkFeeAsCoin).add(securityDepositAsCoin).add(amountAsCoin.get()));
|
||||
|
||||
updateBalance();
|
||||
log.debug("totalToPayAsCoin " + totalToPayAsCoin.get().toFriendlyString());
|
||||
}
|
||||
}
|
||||
|
||||
void updateBalance() {
|
||||
|
@ -337,11 +346,12 @@ class TakeOfferDataModel extends ActivatableDataModel {
|
|||
if (useSavingsWallet) {
|
||||
Coin savingWalletBalance = walletService.getSavingWalletBalance();
|
||||
totalAvailableBalance = savingWalletBalance.add(tradeWalletBalance);
|
||||
|
||||
if (totalToPayAsCoin.get() != null && totalAvailableBalance.compareTo(totalToPayAsCoin.get()) > 0)
|
||||
balance.set(totalToPayAsCoin.get());
|
||||
else
|
||||
balance.set(totalAvailableBalance);
|
||||
if (totalToPayAsCoin.get() != null) {
|
||||
if (totalAvailableBalance.compareTo(totalToPayAsCoin.get()) > 0)
|
||||
balance.set(totalToPayAsCoin.get());
|
||||
else
|
||||
balance.set(totalAvailableBalance);
|
||||
}
|
||||
} else {
|
||||
balance.set(tradeWalletBalance);
|
||||
}
|
||||
|
@ -350,17 +360,18 @@ class TakeOfferDataModel extends ActivatableDataModel {
|
|||
if (missingCoin.get().isNegative())
|
||||
missingCoin.set(Coin.ZERO);
|
||||
}
|
||||
log.debug("missingCoin " + missingCoin.get().toFriendlyString());
|
||||
|
||||
isWalletFunded.set(isBalanceSufficient(balance.get()));
|
||||
if (totalToPayAsCoin.get() != null && isWalletFunded.get() && walletFundedNotification == null) {
|
||||
walletFundedNotification = new Notification()
|
||||
.headLine("Trading wallet update")
|
||||
.notification("Your trading wallet is sufficiently funded.\n" +
|
||||
"Amount: " + formatter.formatCoinWithCode(totalToPayAsCoin.get()))
|
||||
.autoClose();
|
||||
walletFundedNotification = new Notification()
|
||||
.headLine("Trading wallet update")
|
||||
.notification("Your trading wallet is sufficiently funded.\n" +
|
||||
"Amount: " + formatter.formatCoinWithCode(totalToPayAsCoin.get()))
|
||||
.autoClose();
|
||||
|
||||
walletFundedNotification.show();
|
||||
}
|
||||
walletFundedNotification.show();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBalanceSufficient(Coin balance) {
|
||||
|
|
|
@ -520,7 +520,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
}
|
||||
|
||||
private void setAmountToModel() {
|
||||
dataModel.amountAsCoin.set(formatter.parseToCoinWith4Decimals(amount.get()));
|
||||
dataModel.setAmount(formatter.parseToCoinWith4Decimals(amount.get()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ public class SellerStep3View extends TradeStepView {
|
|||
if (model.p2PService.isBootstrapped()) {
|
||||
Preferences preferences = model.dataModel.preferences;
|
||||
String key = "confirmPaymentReceived";
|
||||
if (preferences.showAgain(key)) {
|
||||
if (!BitsquareApp.DEV_MODE && preferences.showAgain(key)) {
|
||||
new Popup()
|
||||
.headLine("Confirm that you have received the payment")
|
||||
.confirmation("Have you received the " + CurrencyUtil.getNameByCode(model.dataModel.getCurrencyCode()) +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue