use of bisq.common.crypto.KeyRing in project bisq-core by bisq-network.
the class EncryptionTest method setup.
@Before
public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException {
Security.addProvider(new BouncyCastleProvider());
dir = File.createTempFile("temp_tests", "");
// noinspection ResultOfMethodCallIgnored
dir.delete();
// noinspection ResultOfMethodCallIgnored
dir.mkdir();
KeyStorage keyStorage = new KeyStorage(dir);
keyRing = new KeyRing(keyStorage);
}
use of bisq.common.crypto.KeyRing in project bisq-core by bisq-network.
the class SigTest method setup.
@Before
public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException {
Security.addProvider(new BouncyCastleProvider());
dir = File.createTempFile("temp_tests", "");
// noinspection ResultOfMethodCallIgnored
dir.delete();
// noinspection ResultOfMethodCallIgnored
dir.mkdir();
KeyStorage keyStorage = new KeyStorage(dir);
keyRing = new KeyRing(keyStorage);
}
use of bisq.common.crypto.KeyRing in project bisq-desktop by bisq-network.
the class TradesChartsViewModelTest method setup.
@Before
public void setup() throws IOException {
Security.addProvider(new BouncyCastleProvider());
dir = File.createTempFile("temp_tests1", "");
// noinspection ResultOfMethodCallIgnored
dir.delete();
// noinspection ResultOfMethodCallIgnored
dir.mkdir();
keyRing = new KeyRing(new KeyStorage(dir));
}
use of bisq.common.crypto.KeyRing in project bisq-desktop by bisq-network.
the class OfferDetailsWindow method addContent.
private void addContent() {
int rows = 5;
List<String> acceptedBanks = offer.getAcceptedBankIds();
boolean showAcceptedBanks = acceptedBanks != null && !acceptedBanks.isEmpty();
List<String> acceptedCountryCodes = offer.getAcceptedCountryCodes();
boolean showAcceptedCountryCodes = acceptedCountryCodes != null && !acceptedCountryCodes.isEmpty();
if (!takeOfferHandlerOptional.isPresent())
rows++;
if (showAcceptedBanks)
rows++;
if (showAcceptedCountryCodes)
rows++;
addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("shared.Offer"));
String fiatDirectionInfo = ":";
String btcDirectionInfo = ":";
OfferPayload.Direction direction = offer.getDirection();
String currencyCode = offer.getCurrencyCode();
String offerTypeLabel = Res.getWithCol("shared.offerType");
String toReceive = " " + Res.get("shared.toReceive");
String toSpend = " " + Res.get("shared.toSpend");
double firstRowDistance = Layout.FIRST_ROW_DISTANCE;
if (takeOfferHandlerOptional.isPresent()) {
addLabelTextField(gridPane, rowIndex, offerTypeLabel, formatter.getDirectionForTakeOffer(direction, currencyCode), firstRowDistance);
fiatDirectionInfo = direction == OfferPayload.Direction.BUY ? toReceive : toSpend;
btcDirectionInfo = direction == OfferPayload.Direction.SELL ? toReceive : toSpend;
} else if (placeOfferHandlerOptional.isPresent()) {
addLabelTextField(gridPane, rowIndex, offerTypeLabel, formatter.getOfferDirectionForCreateOffer(direction, currencyCode), firstRowDistance);
fiatDirectionInfo = direction == OfferPayload.Direction.SELL ? toReceive : toSpend;
btcDirectionInfo = direction == OfferPayload.Direction.BUY ? toReceive : toSpend;
} else {
addLabelTextField(gridPane, rowIndex, offerTypeLabel, formatter.getDirectionBothSides(direction, currencyCode), firstRowDistance);
}
String btcAmount = Res.get("shared.btcAmount");
if (takeOfferHandlerOptional.isPresent()) {
addLabelTextField(gridPane, ++rowIndex, btcAmount + btcDirectionInfo, formatter.formatCoinWithCode(tradeAmount));
addLabelTextField(gridPane, ++rowIndex, formatter.formatVolumeLabel(currencyCode) + fiatDirectionInfo, formatter.formatVolumeWithCode(offer.getVolumeByAmount(tradeAmount)));
} else {
addLabelTextField(gridPane, ++rowIndex, btcAmount + btcDirectionInfo, formatter.formatCoinWithCode(offer.getAmount()));
addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.minBtcAmount"), formatter.formatCoinWithCode(offer.getMinAmount()));
String volume = formatter.formatVolumeWithCode(offer.getVolume());
String minVolume = "";
if (offer.getVolume() != null && offer.getMinVolume() != null && !offer.getVolume().equals(offer.getMinVolume()))
minVolume = " " + Res.get("offerDetailsWindow.min", formatter.formatVolumeWithCode(offer.getMinVolume()));
addLabelTextField(gridPane, ++rowIndex, formatter.formatVolumeLabel(currencyCode) + fiatDirectionInfo, volume + minVolume);
}
String priceLabel = Res.getWithCol("shared.price");
if (takeOfferHandlerOptional.isPresent()) {
addLabelTextField(gridPane, ++rowIndex, priceLabel, formatter.formatPrice(tradePrice));
} else {
Price price = offer.getPrice();
if (offer.isUseMarketBasedPrice()) {
addLabelTextField(gridPane, ++rowIndex, priceLabel, formatter.formatPrice(price) + " " + Res.get("offerDetailsWindow.distance", formatter.formatPercentagePrice(offer.getMarketPriceMargin())));
} else {
addLabelTextField(gridPane, ++rowIndex, priceLabel, formatter.formatPrice(price));
}
}
final PaymentMethod paymentMethod = offer.getPaymentMethod();
final String makerPaymentAccountId = offer.getMakerPaymentAccountId();
final PaymentAccount paymentAccount = user.getPaymentAccount(makerPaymentAccountId);
String bankId = offer.getBankId();
if (bankId == null || bankId.equals("null"))
bankId = "";
else
bankId = " (" + bankId + ")";
final boolean isSpecificBanks = paymentMethod.equals(PaymentMethod.SPECIFIC_BANKS);
final boolean isNationalBanks = paymentMethod.equals(PaymentMethod.NATIONAL_BANK);
final boolean isSepa = paymentMethod.equals(PaymentMethod.SEPA);
if (offer.isMyOffer(keyRing) && makerPaymentAccountId != null && paymentAccount != null) {
addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.myTradingAccount"), paymentAccount.getAccountName());
} else {
final String method = Res.get(paymentMethod.getId());
String paymentMethodLabel = Res.getWithCol("shared.paymentMethod");
if (isNationalBanks || isSpecificBanks || isSepa) {
String methodWithBankId = method + bankId;
if (BankUtil.isBankIdRequired(offer.getCountryCode()))
addLabelTextField(gridPane, ++rowIndex, paymentMethodLabel + " " + Res.get("offerDetailsWindow.offererBankId"), methodWithBankId);
else if (BankUtil.isBankNameRequired(offer.getCountryCode()))
addLabelTextField(gridPane, ++rowIndex, paymentMethodLabel + " " + Res.get("offerDetailsWindow.offerersBankName"), methodWithBankId);
} else {
addLabelTextField(gridPane, ++rowIndex, paymentMethodLabel, method);
}
}
if (showAcceptedBanks) {
if (paymentMethod.equals(PaymentMethod.SAME_BANK)) {
addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.bankId"), acceptedBanks.get(0));
} else if (isSpecificBanks) {
String value = Joiner.on(", ").join(acceptedBanks);
String acceptedBanksLabel = Res.getWithCol("shared.acceptedBanks");
Tooltip tooltip = new Tooltip(acceptedBanksLabel + " " + value);
TextField acceptedBanksTextField = addLabelTextField(gridPane, ++rowIndex, acceptedBanksLabel, value).second;
acceptedBanksTextField.setMouseTransparent(false);
acceptedBanksTextField.setTooltip(tooltip);
}
}
if (showAcceptedCountryCodes) {
String countries;
Tooltip tooltip = null;
if (CountryUtil.containsAllSepaEuroCountries(acceptedCountryCodes)) {
countries = Res.getWithCol("shared.allEuroCountries");
} else {
if (acceptedCountryCodes.size() == 1) {
countries = CountryUtil.getNameAndCode(acceptedCountryCodes.get(0));
tooltip = new Tooltip(countries);
} else {
countries = CountryUtil.getCodesString(acceptedCountryCodes);
tooltip = new Tooltip(CountryUtil.getNamesByCodesString(acceptedCountryCodes));
}
}
TextField acceptedCountries = addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.acceptedTakerCountries"), countries).second;
if (tooltip != null) {
acceptedCountries.setMouseTransparent(false);
acceptedCountries.setTooltip(tooltip);
}
}
rows = 5;
String paymentMethodCountryCode = offer.getCountryCode();
if (paymentMethodCountryCode != null)
rows++;
if (offer.getOfferFeePaymentTxId() != null)
rows++;
addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("shared.details"), Layout.GROUP_DISTANCE);
addLabelTextFieldWithCopyIcon(gridPane, rowIndex, Res.getWithCol("shared.offerId"), offer.getId(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("offerDetailsWindow.makersOnion"), offer.getMakerNodeAddress().getFullAddress());
addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.creationDate"), formatter.formatDateTime(offer.getDate()));
String value = Res.getWithColAndCap("shared.buyer") + " " + formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) + " / " + Res.getWithColAndCap("shared.seller") + " " + formatter.formatCoinWithCode(offer.getSellerSecurityDeposit());
addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.securityDeposit"), value);
if (paymentMethodCountryCode != null)
addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.countryBank"), CountryUtil.getNameAndCode(paymentMethodCountryCode));
addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("offerDetailsWindow.acceptedArbitrators"), formatter.arbitratorAddressesToString(offer.getArbitratorNodeAddresses()));
if (offer.getOfferFeePaymentTxId() != null)
addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.makerFeeTxId"), offer.getOfferFeePaymentTxId());
if (placeOfferHandlerOptional.isPresent()) {
addTitledGroupBg(gridPane, ++rowIndex, 1, Res.get("offerDetailsWindow.commitment"), Layout.GROUP_DISTANCE);
addLabelTextField(gridPane, rowIndex, Res.get("offerDetailsWindow.agree"), Res.get("createOffer.tac"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addConfirmAndCancelButtons(true);
} else if (takeOfferHandlerOptional.isPresent()) {
addTitledGroupBg(gridPane, ++rowIndex, 1, Res.get("shared.contract"), Layout.GROUP_DISTANCE);
addLabelTextField(gridPane, rowIndex, Res.get("offerDetailsWindow.tac"), Res.get("takeOffer.tac"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addConfirmAndCancelButtons(false);
} else {
Button closeButton = addButtonAfterGroup(gridPane, ++rowIndex, Res.get("shared.close"));
closeButton.setOnAction(e -> {
closeHandlerOptional.ifPresent(Runnable::run);
hide();
});
}
}
Aggregations