use of bisq.core.payment.CryptoCurrencyAccount in project bisq-desktop by bisq-network.
the class MainViewModel method setupDevDummyPaymentAccounts.
private void setupDevDummyPaymentAccounts() {
if (user.getPaymentAccounts() != null && user.getPaymentAccounts().isEmpty()) {
PerfectMoneyAccount perfectMoneyAccount = new PerfectMoneyAccount();
perfectMoneyAccount.init();
perfectMoneyAccount.setAccountNr("dummy_" + new Random().nextInt(100));
// Don't translate only for dev
perfectMoneyAccount.setAccountName("PerfectMoney dummy");
perfectMoneyAccount.setSelectedTradeCurrency(GlobalSettings.getDefaultTradeCurrency());
user.addPaymentAccount(perfectMoneyAccount);
if (p2PService.isBootstrapped()) {
accountAgeWitnessService.publishMyAccountAgeWitness(perfectMoneyAccount.getPaymentAccountPayload());
} else {
p2PService.addP2PServiceListener(new BootstrapListener() {
@Override
public void onUpdatedDataReceived() {
accountAgeWitnessService.publishMyAccountAgeWitness(perfectMoneyAccount.getPaymentAccountPayload());
}
});
}
CryptoCurrencyAccount cryptoCurrencyAccount = new CryptoCurrencyAccount();
cryptoCurrencyAccount.init();
// Don't translate only for dev
cryptoCurrencyAccount.setAccountName("ETH dummy");
cryptoCurrencyAccount.setAddress("0x" + new Random().nextInt(1000000));
cryptoCurrencyAccount.setSingleTradeCurrency(CurrencyUtil.getCryptoCurrency("ETH").get());
user.addPaymentAccount(cryptoCurrencyAccount);
}
}
use of bisq.core.payment.CryptoCurrencyAccount in project bisq-desktop by bisq-network.
the class AltCoinAccountsDataModel method onSaveNewAccount.
// /////////////////////////////////////////////////////////////////////////////////////////
// UI actions
// /////////////////////////////////////////////////////////////////////////////////////////
public void onSaveNewAccount(PaymentAccount paymentAccount) {
user.addPaymentAccount(paymentAccount);
TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
List<TradeCurrency> tradeCurrencies = paymentAccount.getTradeCurrencies();
if (singleTradeCurrency != null) {
if (singleTradeCurrency instanceof FiatCurrency)
preferences.addFiatCurrency((FiatCurrency) singleTradeCurrency);
else
preferences.addCryptoCurrency((CryptoCurrency) singleTradeCurrency);
} else if (tradeCurrencies != null && !tradeCurrencies.isEmpty()) {
tradeCurrencies.stream().forEach(tradeCurrency -> {
if (tradeCurrency instanceof FiatCurrency)
preferences.addFiatCurrency((FiatCurrency) tradeCurrency);
else
preferences.addCryptoCurrency((CryptoCurrency) tradeCurrency);
});
}
if (!(paymentAccount instanceof CryptoCurrencyAccount))
accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload());
}
use of bisq.core.payment.CryptoCurrencyAccount in project bisq-desktop by bisq-network.
the class PaymentMethodForm method addLimitations.
protected void addLimitations() {
long hours = paymentAccount.getPaymentMethod().getMaxTradePeriod() / 3600_000;
final TradeCurrency tradeCurrency;
if (paymentAccount.getSingleTradeCurrency() != null)
tradeCurrency = paymentAccount.getSingleTradeCurrency();
else if (paymentAccount.getSelectedTradeCurrency() != null)
tradeCurrency = paymentAccount.getSelectedTradeCurrency();
else if (!paymentAccount.getTradeCurrencies().isEmpty())
tradeCurrency = paymentAccount.getTradeCurrencies().get(0);
else
tradeCurrency = paymentAccount instanceof CryptoCurrencyAccount ? CurrencyUtil.getAllSortedCryptoCurrencies().get(0) : CurrencyUtil.getDefaultTradeCurrency();
final boolean isAddAccountScreen = paymentAccount.getAccountName() == null;
final long accountAge = !isAddAccountScreen ? accountAgeWitnessService.getMyAccountAge(paymentAccount.getPaymentAccountPayload()) : 0L;
addLabelTextField(gridPane, ++gridRow, Res.get("payment.limitations"), Res.get("payment.maxPeriodAndLimit", getTimeText(hours), formatter.formatCoinWithCode(Coin.valueOf(accountAgeWitnessService.getMyTradeLimit(paymentAccount, tradeCurrency.getCode()))), formatter.formatAccountAge(accountAge)));
if (isAddAccountScreen) {
InputTextField inputTextField = addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.salt"), 0).second;
inputTextField.setText(Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt()));
inputTextField.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.isEmpty()) {
try {
// test if input is hex
Utilities.decodeFromHex(newValue);
paymentAccount.setSaltAsHex(newValue);
} catch (Throwable t) {
new Popup().warning(Res.get("payment.error.noHexSalt")).show();
inputTextField.setText(Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt()));
log.warn(t.toString());
}
}
});
} else {
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.salt", Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt())), Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt()));
}
}
use of bisq.core.payment.CryptoCurrencyAccount in project bisq-desktop by bisq-network.
the class OfferBookViewModelTest method getCryptoAccount.
private PaymentAccount getCryptoAccount(String currencyCode) {
PaymentAccount paymentAccount = new CryptoCurrencyAccount();
paymentAccount.addCurrency(new CryptoCurrency(currencyCode, null));
return paymentAccount;
}
Aggregations