Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account signing: add signing state to payment account selection #3403

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,15 @@ offerbook.filterByCurrency=Filter by currency
offerbook.filterByPaymentMethod=Filter by payment method
offerbook.timeSinceSigning=Time since signing
offerbook.timeSinceSigning.info=This account was verified and {0}
offerbook.timeSinceSigning.info.arbitrator=signed by an arbitrator and can sign peers accounts
offerbook.timeSinceSigning.info.arbitrator=signed by an arbitrator and can sign peer accounts
offerbook.timeSinceSigning.info.peer=signed by a peer, waiting for limits to be lifted
offerbook.timeSinceSigning.info.peerLimitLifted=signed by a peer and limits were lifted
offerbook.timeSinceSigning.info.signer=signed by peer and can sign peer accounts
offerbook.timeSinceSigning.daysSinceSigning={0} days
offerbook.timeSinceSigning.daysSinceSigning.long={0} since signing

offerbook.timeSinceSigning.help=By trading with a payment account that was verified by an arbitrator or a peer, your account gets signed as well.\n\
30 days later the initial limit of 0.01 BTC gets lifted and after 90 days your account can sign other peers as well.
30 days later the initial limit of 0.01 BTC gets lifted and after 60 days your account can sign other peers as well.
offerbook.timeSinceSigning.notSigned=Not signed yet
offerbook.timeSinceSigning.notSigned.noNeed=Unsigned
shared.notSigned=This account hasn't been signed yet
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/main/java/bisq/desktop/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private void setupHandlers() {
});
bisqSetup.setSpvFileCorruptedHandler(msg -> new Popup<>().warning(msg)
.actionButtonText(Res.get("settings.net.reSyncSPVChainButton"))
.onAction(() -> GUIUtil.reSyncSPVChain(walletsSetup, preferences))
.onAction(() -> GUIUtil.reSyncSPVChain(preferences))
.show());
bisqSetup.setVoteResultExceptionHandler(voteResultException -> log.warn(voteResultException.toString()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ protected void initialize() {
paymentAccountsComboBox.setConverter(GUIUtil.getPaymentAccountsComboBoxStringConverter());
paymentAccountsComboBox.setButtonCell(GUIUtil.getComboBoxButtonCell(Res.get("shared.selectTradingAccount"),
paymentAccountsComboBox, false));
paymentAccountsComboBox.setCellFactory(model.getPaymentAccountListCellFactory(paymentAccountsComboBox));

doSetFocus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import bisq.desktop.util.validation.MonetaryValidator;
import bisq.desktop.util.validation.SecurityDepositValidator;

import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.btc.wallet.Restrictions;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
Expand Down Expand Up @@ -66,6 +67,10 @@

import javax.inject.Inject;

import javafx.scene.control.ComboBox;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
Expand All @@ -76,6 +81,8 @@
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;

import javafx.util.Callback;

import java.util.Optional;
import java.util.concurrent.TimeUnit;

Expand All @@ -86,6 +93,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
private final BsqValidator bsqValidator;
protected final SecurityDepositValidator securityDepositValidator;
private final PriceFeedService priceFeedService;
private AccountAgeWitnessService accountAgeWitnessService;
private final Navigation navigation;
private final Preferences preferences;
protected final BSFormatter btcFormatter;
Expand Down Expand Up @@ -185,6 +193,7 @@ public MutableOfferViewModel(M dataModel,
BsqValidator bsqValidator,
SecurityDepositValidator securityDepositValidator,
PriceFeedService priceFeedService,
AccountAgeWitnessService accountAgeWitnessService,
Navigation navigation,
Preferences preferences,
BSFormatter btcFormatter,
Expand All @@ -198,6 +207,7 @@ public MutableOfferViewModel(M dataModel,
this.bsqValidator = bsqValidator;
this.securityDepositValidator = securityDepositValidator;
this.priceFeedService = priceFeedService;
this.accountAgeWitnessService = accountAgeWitnessService;
this.navigation = navigation;
this.preferences = preferences;
this.btcFormatter = btcFormatter;
Expand Down Expand Up @@ -956,7 +966,7 @@ public String getSecurityDepositPopOverLabel(String depositInBTC) {

public String getSecurityDepositInfo() {
return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) +
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), dataModel.getAmount().get(), btcFormatter);
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), dataModel.getAmount().get());
}

public String getSecurityDepositWithCode() {
Expand All @@ -968,15 +978,15 @@ public String getTradeFee() {
final Coin makerFeeAsCoin = dataModel.getMakerFee();
final String makerFee = getFormatterForMakerFee().formatCoinWithCode(makerFeeAsCoin);
if (dataModel.isCurrencyForMakerFeeBtc())
return makerFee + GUIUtil.getPercentageOfTradeAmount(makerFeeAsCoin, dataModel.getAmount().get(), btcFormatter);
return makerFee + GUIUtil.getPercentageOfTradeAmount(makerFeeAsCoin, dataModel.getAmount().get());
else
return makerFee + " (" + Res.get("shared.tradingFeeInBsqInfo", btcFormatter.formatCoinWithCode(makerFeeAsCoin)) + ")";
}

public String getMakerFeePercentage() {
final Coin makerFeeAsCoin = dataModel.getMakerFee();
if (dataModel.isCurrencyForMakerFeeBtc())
return GUIUtil.getPercentage(makerFeeAsCoin, dataModel.getAmount().get(), btcFormatter);
return GUIUtil.getPercentage(makerFeeAsCoin, dataModel.getAmount().get());
else
return Res.get("dao.paidWithBsq");
}
Expand Down Expand Up @@ -1004,13 +1014,13 @@ public String getFundsStructure() {
public String getTxFee() {
Coin txFeeAsCoin = dataModel.getTxFee();
return btcFormatter.formatCoinWithCode(txFeeAsCoin) +
GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get(), btcFormatter);
GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get());

}

public String getTxFeePercentage() {
Coin txFeeAsCoin = dataModel.getTxFee();
return GUIUtil.getPercentage(txFeeAsCoin, dataModel.getAmount().get(), btcFormatter);
return GUIUtil.getPercentage(txFeeAsCoin, dataModel.getAmount().get());
}

public PaymentAccount getPaymentAccount() {
Expand Down Expand Up @@ -1042,11 +1052,15 @@ public Offer createAndGetOffer() {
return offer;
}

public Callback<ListView<PaymentAccount>, ListCell<PaymentAccount>> getPaymentAccountListCellFactory(
ComboBox<PaymentAccount> paymentAccountsComboBox) {
return GUIUtil.getPaymentAccountListCellFactory(paymentAccountsComboBox, accountAgeWitnessService);
}

public M getDataModel() {
return dataModel;
}


///////////////////////////////////////////////////////////////////////////////////////////
// Utils
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import bisq.desktop.util.validation.FiatVolumeValidator;
import bisq.desktop.util.validation.SecurityDepositValidator;

import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.user.Preferences;
import bisq.core.util.BSFormatter;
Expand All @@ -45,6 +46,7 @@ public CreateOfferViewModel(CreateOfferDataModel dataModel,
BsqValidator bsqValidator,
SecurityDepositValidator securityDepositValidator,
PriceFeedService priceFeedService,
AccountAgeWitnessService accountAgeWitnessService,
Navigation navigation,
Preferences preferences,
BSFormatter btcFormatter,
Expand All @@ -57,9 +59,9 @@ public CreateOfferViewModel(CreateOfferDataModel dataModel,
bsqValidator,
securityDepositValidator,
priceFeedService,
accountAgeWitnessService,
navigation,
preferences,
btcFormatter,
bsqFormatter);
btcFormatter, bsqFormatter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ private void addPaymentGroup() {
paymentAccountsComboBox = paymentAccountTuple.first;
HBox.setMargin(paymentAccountsComboBox, new Insets(Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0));
paymentAccountsComboBox.setConverter(GUIUtil.getPaymentAccountsComboBoxStringConverter());
paymentAccountsComboBox.setCellFactory(model.getPaymentAccountListCellFactory(paymentAccountsComboBox));
paymentAccountsComboBox.setVisible(false);
paymentAccountsComboBox.setManaged(false);
paymentAccountsComboBox.setOnAction(e -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.validation.BtcValidator;

import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.btc.setup.WalletsSetup;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
Expand Down Expand Up @@ -57,6 +58,10 @@

import javax.inject.Inject;

import javafx.scene.control.ComboBox;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
Expand All @@ -67,6 +72,8 @@

import javafx.collections.ObservableList;

import javafx.util.Callback;

import java.util.Optional;

import javax.annotation.Nullable;
Expand All @@ -81,6 +88,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
private final WalletsSetup walletsSetup;
private final Preferences preferences;
private final PriceFeedService priceFeedService;
private AccountAgeWitnessService accountAgeWitnessService;
private final Navigation navigation;
private final BSFormatter btcFormatter;
private final BsqFormatter bsqFormatter;
Expand Down Expand Up @@ -141,6 +149,7 @@ public TakeOfferViewModel(TakeOfferDataModel dataModel,
WalletsSetup walletsSetup,
Preferences preferences,
PriceFeedService priceFeedService,
AccountAgeWitnessService accountAgeWitnessService,
Navigation navigation,
BSFormatter btcFormatter,
BsqFormatter bsqFormatter) {
Expand All @@ -152,6 +161,7 @@ public TakeOfferViewModel(TakeOfferDataModel dataModel,
this.walletsSetup = walletsSetup;
this.preferences = preferences;
this.priceFeedService = priceFeedService;
this.accountAgeWitnessService = accountAgeWitnessService;
this.navigation = navigation;
this.btcFormatter = btcFormatter;
this.bsqFormatter = bsqFormatter;
Expand Down Expand Up @@ -698,7 +708,7 @@ String getTradeAmount() {

public String getSecurityDepositInfo() {
return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) +
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), dataModel.getAmount().get(), btcFormatter);
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), dataModel.getAmount().get());
}

public String getSecurityDepositWithCode() {
Expand All @@ -710,15 +720,15 @@ public String getTradeFee() {
final Coin takerFeeAsCoin = dataModel.getTakerFee();
final String takerFee = getFormatterForTakerFee().formatCoinWithCode(takerFeeAsCoin);
if (dataModel.isCurrencyForTakerFeeBtc())
return takerFee + GUIUtil.getPercentageOfTradeAmount(takerFeeAsCoin, dataModel.getAmount().get(), btcFormatter);
return takerFee + GUIUtil.getPercentageOfTradeAmount(takerFeeAsCoin, dataModel.getAmount().get());
else
return takerFee + " (" + Res.get("shared.tradingFeeInBsqInfo", btcFormatter.formatCoinWithCode(takerFeeAsCoin)) + ")";
}

public String getTakerFeePercentage() {
final Coin takerFeeAsCoin = dataModel.getTakerFee();
if (dataModel.isCurrencyForTakerFeeBtc())
return takerFeeAsCoin != null ? GUIUtil.getPercentage(takerFeeAsCoin, dataModel.getAmount().get(), btcFormatter) : Res.get("shared.na");
return takerFeeAsCoin != null ? GUIUtil.getPercentage(takerFeeAsCoin, dataModel.getAmount().get()) : Res.get("shared.na");
else
return Res.get("dao.paidWithBsq");
}
Expand All @@ -734,13 +744,13 @@ public String getTotalToPayInfo() {
public String getTxFee() {
Coin txFeeAsCoin = dataModel.getTotalTxFee();
return btcFormatter.formatCoinWithCode(txFeeAsCoin) +
GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get(), btcFormatter);
GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get());

}

public String getTxFeePercentage() {
Coin txFeeAsCoin = dataModel.getTotalTxFee();
return GUIUtil.getPercentage(txFeeAsCoin, dataModel.getAmount().get(), btcFormatter);
return GUIUtil.getPercentage(txFeeAsCoin, dataModel.getAmount().get());
}

public PaymentMethod getPaymentMethod() {
Expand Down Expand Up @@ -778,4 +788,9 @@ public String getSellerSecurityDeposit() {
private BSFormatter getFormatterForTakerFee() {
return dataModel.isCurrencyForTakerFeeBtc() ? btcFormatter : bsqFormatter;
}

public Callback<ListView<PaymentAccount>, ListCell<PaymentAccount>> getPaymentAccountListCellFactory(
ComboBox<PaymentAccount> paymentAccountsComboBox) {
return GUIUtil.getPaymentAccountListCellFactory(paymentAccountsComboBox, accountAgeWitnessService);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import bisq.desktop.util.validation.FiatVolumeValidator;
import bisq.desktop.util.validation.SecurityDepositValidator;

import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.offer.OpenOffer;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.user.Preferences;
Expand All @@ -48,6 +49,7 @@ public EditOfferViewModel(EditOfferDataModel dataModel,
BsqValidator bsqValidator,
SecurityDepositValidator securityDepositValidator,
PriceFeedService priceFeedService,
AccountAgeWitnessService accountAgeWitnessService,
Navigation navigation,
Preferences preferences,
BSFormatter btcFormatter,
Expand All @@ -60,10 +62,10 @@ public EditOfferViewModel(EditOfferDataModel dataModel,
bsqValidator,
securityDepositValidator,
priceFeedService,
accountAgeWitnessService,
navigation,
preferences,
btcFormatter,
bsqFormatter);
btcFormatter, bsqFormatter);
syncMinAmountWithAmount = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public String getFiatVolume() {
public String getTxFee() {
if (trade != null && trade.getTradeAmount() != null) {
Coin txFee = dataModel.getTxFee();
String percentage = GUIUtil.getPercentageOfTradeAmount(txFee, trade.getTradeAmount(), btcFormatter);
String percentage = GUIUtil.getPercentageOfTradeAmount(txFee, trade.getTradeAmount());
return btcFormatter.formatCoinWithCode(txFee) + percentage;
} else {
return "";
Expand All @@ -299,7 +299,7 @@ public String getTradeFee() {
if (dataModel.isMaker() && dataModel.getOffer().isCurrencyForMakerFeeBtc() ||
!dataModel.isMaker() && dataModel.getTrade().isCurrencyForTakerFeeBtc()) {
Coin tradeFeeInBTC = dataModel.getTradeFeeInBTC();
String percentage = GUIUtil.getPercentageOfTradeAmount(tradeFeeInBTC, trade.getTradeAmount(), btcFormatter);
String percentage = GUIUtil.getPercentageOfTradeAmount(tradeFeeInBTC, trade.getTradeAmount());
return btcFormatter.formatCoinWithCode(tradeFeeInBTC) + percentage;
} else {
return bsqFormatter.formatCoinWithCode(dataModel.getTradeFeeAsBsq());
Expand All @@ -316,7 +316,7 @@ public String getSecurityDeposit() {
Coin securityDeposit = dataModel.isBuyer() ?
offer.getBuyerSecurityDeposit()
: offer.getSellerSecurityDeposit();
String percentage = GUIUtil.getPercentageOfTradeAmount(securityDeposit, trade.getTradeAmount(), btcFormatter);
String percentage = GUIUtil.getPercentageOfTradeAmount(securityDeposit, trade.getTradeAmount());
return btcFormatter.formatCoinWithCode(securityDeposit) + percentage;
} else {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public void activate() {
}
});

reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain(walletsSetup, preferences));
reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain(preferences));

bitcoinPeersSubscription = EasyBind.subscribe(walletsSetup.connectedPeersProperty(),
connectedPeers -> updateBitcoinPeersTextArea());
Expand Down
Loading