add gold and silver, refactor money types to traditional and crypto
This commit is contained in:
parent
65bc78d3d7
commit
29706339ef
@ -52,7 +52,7 @@ printbreak
|
||||
|
||||
registerdisputeagents
|
||||
|
||||
# Demonstrate how to create an XMR altcoin payment account.
|
||||
# Demonstrate how to create an XMR payment account.
|
||||
|
||||
printdate "Create Alice's XMR Trading Payment Account."
|
||||
# Note: Having problems passing a double quoted --account-name param to function.
|
||||
|
@ -6,7 +6,7 @@ import com.google.gson.stream.JsonWriter;
|
||||
import haveno.apitest.method.MethodTest;
|
||||
import haveno.cli.GrpcClient;
|
||||
import haveno.core.api.model.PaymentAccountForm;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.PaymentAccount;
|
||||
@ -168,11 +168,11 @@ public class AbstractPaymentAccountTest extends MethodTest {
|
||||
assertEquals(expectedCurrencyCode, paymentAccount.getSingleTradeCurrency().getCode());
|
||||
}
|
||||
|
||||
protected final void verifyAccountTradeCurrencies(Collection<FiatCurrency> expectedFiatCurrencies,
|
||||
protected final void verifyAccountTradeCurrencies(Collection<TraditionalCurrency> expectedTraditionalCurrencies,
|
||||
PaymentAccount paymentAccount) {
|
||||
assertNotNull(paymentAccount.getTradeCurrencies());
|
||||
List<TradeCurrency> expectedTradeCurrencies = new ArrayList<>() {{
|
||||
addAll(expectedFiatCurrencies);
|
||||
addAll(expectedTraditionalCurrencies);
|
||||
}};
|
||||
assertArrayEquals(expectedTradeCurrencies.toArray(), paymentAccount.getTradeCurrencies().toArray());
|
||||
}
|
||||
@ -206,8 +206,8 @@ public class AbstractPaymentAccountTest extends MethodTest {
|
||||
return jsonString;
|
||||
}
|
||||
|
||||
protected final String getCommaDelimitedFiatCurrencyCodes(Collection<FiatCurrency> fiatCurrencies) {
|
||||
return fiatCurrencies.stream()
|
||||
protected final String getCommaDelimitedTraditionalCurrencyCodes(Collection<TraditionalCurrency> traditionalCurrencies) {
|
||||
return traditionalCurrencies.stream()
|
||||
.sorted(Comparator.comparing(TradeCurrency::getCode))
|
||||
.map(c -> c.getCurrency().getCurrencyCode())
|
||||
.collect(Collectors.joining(","));
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.apitest.method.payment;
|
||||
|
||||
import haveno.cli.table.builder.TableBuilder;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.AdvancedCashAccount;
|
||||
import haveno.core.payment.AliPayAccount;
|
||||
@ -78,7 +78,7 @@ import static haveno.apitest.config.ApiTestConfig.EUR;
|
||||
import static haveno.apitest.config.ApiTestConfig.USD;
|
||||
import static haveno.apitest.config.HavenoAppConfig.alicedaemon;
|
||||
import static haveno.cli.table.builder.TableType.PAYMENT_ACCOUNT_TBL;
|
||||
import static haveno.core.locale.CurrencyUtil.getAllSortedFiatCurrencies;
|
||||
import static haveno.core.locale.CurrencyUtil.getAllSortedTraditionalCurrencies;
|
||||
import static haveno.core.locale.CurrencyUtil.getTradeCurrency;
|
||||
import static haveno.core.payment.payload.PaymentMethod.ADVANCED_CASH_ID;
|
||||
import static haveno.core.payment.payload.PaymentMethod.ALI_PAY_ID;
|
||||
@ -844,9 +844,9 @@ public class CreatePaymentAccountTest extends AbstractPaymentAccountTest {
|
||||
PROPERTY_NAME_BANK_SWIFT_CODE);
|
||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PAYMENT_METHOD_ID, SWIFT_ID);
|
||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NAME, "IT Swift Acct w/ DE Intermediary");
|
||||
Collection<FiatCurrency> swiftCurrenciesSortedByCode = getAllSortedFiatCurrencies(comparing(TradeCurrency::getCode));
|
||||
String allFiatCodes = getCommaDelimitedFiatCurrencyCodes(swiftCurrenciesSortedByCode);
|
||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, allFiatCodes);
|
||||
Collection<TraditionalCurrency> swiftCurrenciesSortedByCode = getAllSortedTraditionalCurrencies(comparing(TradeCurrency::getCode));
|
||||
String allTraditionalCodes = getCommaDelimitedTraditionalCurrencyCodes(swiftCurrenciesSortedByCode);
|
||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, allTraditionalCodes);
|
||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SELECTED_TRADE_CURRENCY, EUR);
|
||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_BANK_SWIFT_CODE, "PASCITMMFIR");
|
||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_BANK_COUNTRY_CODE, "IT");
|
||||
|
@ -45,10 +45,10 @@ public class MakerBotProtocol extends BotProtocol {
|
||||
var trade = makeTrade.apply(randomOffer);
|
||||
|
||||
var makerIsBuyer = trade.getOffer().getDirection().equalsIgnoreCase(BUY);
|
||||
Function<TradeInfo, TradeInfo> completeFiatTransaction = makerIsBuyer
|
||||
Function<TradeInfo, TradeInfo> completeTraditionalTransaction = makerIsBuyer
|
||||
? sendPaymentSentMessage.andThen(waitForPaymentReceivedConfirmation)
|
||||
: waitForPaymentSentMessage.andThen(sendPaymentReceivedMessage);
|
||||
completeFiatTransaction.apply(trade);
|
||||
completeTraditionalTransaction.apply(trade);
|
||||
|
||||
currentProtocolStep = DONE;
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ public class TakerBotProtocol extends BotProtocol {
|
||||
var trade = takeTrade.apply(findOffer.get());
|
||||
|
||||
var takerIsSeller = trade.getOffer().getDirection().equalsIgnoreCase(BUY);
|
||||
Function<TradeInfo, TradeInfo> completeFiatTransaction = takerIsSeller
|
||||
Function<TradeInfo, TradeInfo> completeTraditionalTransaction = takerIsSeller
|
||||
? waitForPaymentSentMessage.andThen(sendPaymentReceivedMessage)
|
||||
: sendPaymentSentMessage.andThen(waitForPaymentReceivedConfirmation);
|
||||
completeFiatTransaction.apply(trade);
|
||||
completeTraditionalTransaction.apply(trade);
|
||||
|
||||
currentProtocolStep = DONE;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class AddressValidationResult {
|
||||
}
|
||||
|
||||
public static AddressValidationResult invalidAddress(String cause) {
|
||||
return invalidAddress(cause, "validation.altcoin.invalidAddress");
|
||||
return invalidAddress(cause, "validation.crypto.invalidAddress");
|
||||
}
|
||||
|
||||
public static AddressValidationResult invalidAddress(String cause, String i18nKey) {
|
||||
@ -68,6 +68,6 @@ public class AddressValidationResult {
|
||||
}
|
||||
|
||||
public static AddressValidationResult invalidStructure() {
|
||||
return invalidAddress("", "validation.altcoin.wrongStructure");
|
||||
return invalidAddress("", "validation.crypto.wrongStructure");
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ import java.lang.annotation.Target;
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface AltCoinAccountDisclaimer {
|
||||
public @interface CryptoAccountDisclaimer {
|
||||
|
||||
/**
|
||||
* Translation key of the message to show, i.e. "account.altcoin.popup.xmr.msg"
|
||||
* Translation key of the message to show, i.e. "account.crypto.popup.xmr.msg"
|
||||
* @return translation key
|
||||
*/
|
||||
String value();
|
@ -4,6 +4,6 @@ public class LiquidBitcoinAddressValidator extends RegexAddressValidator {
|
||||
static private final String REGEX = "^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,87}|[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,87})$";
|
||||
|
||||
public LiquidBitcoinAddressValidator() {
|
||||
super(REGEX, "validation.altcoin.liquidBitcoin.invalidAddress");
|
||||
super(REGEX, "validation.crypto.liquidBitcoin.invalidAddress");
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,11 @@
|
||||
|
||||
package haveno.asset.coins;
|
||||
|
||||
import haveno.asset.AltCoinAccountDisclaimer;
|
||||
import haveno.asset.CryptoAccountDisclaimer;
|
||||
import haveno.asset.Coin;
|
||||
import haveno.asset.CryptoNoteAddressValidator;
|
||||
|
||||
@AltCoinAccountDisclaimer("account.altcoin.popup.xmr.msg")
|
||||
@CryptoAccountDisclaimer("account.crypto.popup.xmr.msg")
|
||||
public class Monero extends Coin {
|
||||
|
||||
public Monero() {
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Haveno's family of abstractions representing different ("crypto")
|
||||
* {@link haveno.asset.Asset} types such as {@link haveno.asset.Coin},
|
||||
* {@link haveno.asset.Token} and {@link haveno.asset.Erc20Token}, as well as concrete
|
||||
* implementations of each, such as {@link haveno.asset.coins.Bitcoin} itself, altcoins like
|
||||
* implementations of each, such as {@link haveno.asset.coins.Bitcoin} itself, cryptos like
|
||||
* {@link haveno.asset.coins.Litecoin} and {@link haveno.asset.coins.Ether} and tokens like
|
||||
* {@link haveno.asset.tokens.DaiStablecoin}.
|
||||
* <p>
|
||||
|
@ -19,10 +19,10 @@
|
||||
# Please try to keep the length of the translated string similar to English. If it is longer it might break layout or
|
||||
# get truncated. We will need some adjustments in the UI code to support that but we want to keep effort at the minimum.
|
||||
|
||||
account.altcoin.popup.validation.XCP=XCP address must start with '1' and must have 34 characters.
|
||||
account.altcoin.popup.validation.DCR=DCR address must start with 'Dk' or 'Ds' or 'De' or 'DS' or 'Dc' or 'Pm' and must have 34 characters.
|
||||
account.altcoin.popup.validation.ETC=ETC address must start with '0x' and made up of letters A to F and numbers which are 40 characters long.
|
||||
account.altcoin.popup.validation.NMC=NMC address must start with 'N' or 'M' and must be 34 characters long.
|
||||
account.altcoin.popup.validation.SF= Siafund address must be made up of letters A to F and numbers which are 76 characters long.
|
||||
account.altcoin.popup.validation.UNO=UNO address must start with 'u' and must have 34 characters.
|
||||
account.altcoin.popup.validation.XZC=XZC address must start with 'a' and must have 34 characters.
|
||||
account.crypto.popup.validation.XCP=XCP address must start with '1' and must have 34 characters.
|
||||
account.crypto.popup.validation.DCR=DCR address must start with 'Dk' or 'Ds' or 'De' or 'DS' or 'Dc' or 'Pm' and must have 34 characters.
|
||||
account.crypto.popup.validation.ETC=ETC address must start with '0x' and made up of letters A to F and numbers which are 40 characters long.
|
||||
account.crypto.popup.validation.NMC=NMC address must start with 'N' or 'M' and must be 34 characters long.
|
||||
account.crypto.popup.validation.SF= Siafund address must be made up of letters A to F and numbers which are 76 characters long.
|
||||
account.crypto.popup.validation.UNO=UNO address must start with 'u' and must have 34 characters.
|
||||
account.crypto.popup.validation.XZC=XZC address must start with 'a' and must have 34 characters.
|
@ -52,7 +52,7 @@ class ColumnHeaderConstants {
|
||||
static final String COL_HEADER_NAME = "Name";
|
||||
static final String COL_HEADER_PAYMENT_METHOD = "Payment Method";
|
||||
static final String COL_HEADER_PRICE = "Price in %-3s for 1 BTC";
|
||||
static final String COL_HEADER_PRICE_OF_ALTCOIN = "Price in BTC for 1 %-3s";
|
||||
static final String COL_HEADER_PRICE_OF_CRYPTO = "Price in BTC for 1 %-3s";
|
||||
static final String COL_HEADER_TRADE_AMOUNT = padStart("Amount(%-3s)", 12, ' ');
|
||||
static final String COL_HEADER_TRADE_BUYER_COST = padEnd("Buyer Cost(%-3s)", 15, ' ');
|
||||
static final String COL_HEADER_TRADE_DEPOSIT_CONFIRMED = "Deposit Confirmed";
|
||||
|
@ -35,7 +35,7 @@ public class CreateCryptoCurrencyPaymentAcctOptionParser extends AbstractMethodO
|
||||
final OptionSpec<String> currencyCodeOpt = parser.accepts(OPT_CURRENCY_CODE, "crypto currency code (xmr)")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<String> addressOpt = parser.accepts(OPT_ADDRESS, "altcoin address")
|
||||
final OptionSpec<String> addressOpt = parser.accepts(OPT_ADDRESS, "crypto address")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<Boolean> tradeInstantOpt = parser.accepts(OPT_TRADE_INSTANT, "create trade instant account")
|
||||
|
@ -28,7 +28,7 @@ import java.util.function.Predicate;
|
||||
*/
|
||||
abstract class AbstractTableBuilder {
|
||||
|
||||
protected final Predicate<OfferInfo> isFiatOffer = (o) -> o.getBaseCurrencyCode().equals("BTC");
|
||||
protected final Predicate<OfferInfo> isTraditionalOffer = (o) -> o.getBaseCurrencyCode().equals("XMR");
|
||||
|
||||
protected final TableType tableType;
|
||||
protected final List<?> protos;
|
||||
|
@ -91,7 +91,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
||||
@Nullable
|
||||
protected final Column<Boolean> colIsPaymentReceivedMessageSent;
|
||||
@Nullable
|
||||
protected final Column<String> colAltcoinReceiveAddressColumn;
|
||||
protected final Column<String> colCryptoReceiveAddressColumn;
|
||||
|
||||
AbstractTradeListBuilder(TableType tableType, List<?> protos) {
|
||||
super(tableType, protos);
|
||||
@ -127,7 +127,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
||||
this.colIsPaymentSentMessageSent = colSupplier.paymentSentMessageSentColumn.get();
|
||||
this.colIsPaymentReceivedMessageSent = colSupplier.paymentReceivedMessageSentColumn.get();
|
||||
//noinspection ConstantConditions
|
||||
this.colAltcoinReceiveAddressColumn = colSupplier.altcoinReceiveAddressColumn.get();
|
||||
this.colCryptoReceiveAddressColumn = colSupplier.cryptoReceiveAddressColumn.get();
|
||||
}
|
||||
|
||||
protected void validate() {
|
||||
@ -142,7 +142,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
||||
// Helper Functions
|
||||
|
||||
private final Supplier<Boolean> isTradeDetailTblBuilder = () -> tableType.equals(TRADE_DETAIL_TBL);
|
||||
protected final Predicate<TradeInfo> isFiatTrade = (t) -> isFiatOffer.test(t.getOffer());
|
||||
protected final Predicate<TradeInfo> isTraditionalTrade = (t) -> isTraditionalOffer.test(t.getOffer());
|
||||
protected final Predicate<TradeInfo> isMyOffer = (t) -> t.getOffer().getIsMyOffer();
|
||||
protected final Predicate<TradeInfo> isTaker = (t) -> t.getRole().toLowerCase().contains("taker");
|
||||
protected final Predicate<TradeInfo> isSellOffer = (t) -> t.getOffer().getDirection().equals(SELL.name());
|
||||
@ -152,23 +152,23 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
||||
|
||||
// Column Value Functions
|
||||
|
||||
// Altcoin volumes from server are string representations of decimals.
|
||||
// Crypto volumes from server are string representations of decimals.
|
||||
// Converting them to longs ("sats") requires shifting the decimal points
|
||||
// to left: 2 for BSQ, 8 for other altcoins.
|
||||
protected final Function<TradeInfo, Long> toAltcoinTradeVolumeAsLong = (t) -> new BigDecimal(t.getTradeVolume()).movePointRight(8).longValue();
|
||||
// to left: 2 for BSQ, 8 for other cryptos.
|
||||
protected final Function<TradeInfo, Long> toCryptoTradeVolumeAsLong = (t) -> new BigDecimal(t.getTradeVolume()).movePointRight(8).longValue();
|
||||
|
||||
protected final Function<TradeInfo, String> toTradeVolumeAsString = (t) ->
|
||||
isFiatTrade.test(t)
|
||||
isTraditionalTrade.test(t)
|
||||
? t.getTradeVolume()
|
||||
: formatSatoshis(t.getAmount());
|
||||
|
||||
protected final Function<TradeInfo, Long> toTradeVolumeAsLong = (t) ->
|
||||
isFiatTrade.test(t)
|
||||
isTraditionalTrade.test(t)
|
||||
? Long.parseLong(t.getTradeVolume())
|
||||
: toAltcoinTradeVolumeAsLong.apply(t);
|
||||
: toCryptoTradeVolumeAsLong.apply(t);
|
||||
|
||||
protected final Function<TradeInfo, Long> toTradeAmount = (t) ->
|
||||
isFiatTrade.test(t)
|
||||
isTraditionalTrade.test(t)
|
||||
? t.getAmount()
|
||||
: toTradeVolumeAsLong.apply(t);
|
||||
|
||||
@ -177,7 +177,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
||||
+ t.getOffer().getCounterCurrencyCode();
|
||||
|
||||
protected final Function<TradeInfo, String> toPaymentCurrencyCode = (t) ->
|
||||
isFiatTrade.test(t)
|
||||
isTraditionalTrade.test(t)
|
||||
? t.getOffer().getCounterCurrencyCode()
|
||||
: t.getOffer().getBaseCurrencyCode();
|
||||
|
||||
@ -202,7 +202,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
||||
};
|
||||
|
||||
protected final Function<TradeInfo, String> toOfferType = (t) -> {
|
||||
if (isFiatTrade.test(t)) {
|
||||
if (isTraditionalTrade.test(t)) {
|
||||
return t.getOffer().getDirection() + " " + t.getOffer().getBaseCurrencyCode();
|
||||
} else {
|
||||
if (t.getOffer().getDirection().equals("BUY")) {
|
||||
@ -213,8 +213,8 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
||||
}
|
||||
};
|
||||
|
||||
protected final Predicate<TradeInfo> showAltCoinBuyerAddress = (t) -> {
|
||||
if (isFiatTrade.test(t)) {
|
||||
protected final Predicate<TradeInfo> showCryptoBuyerAddress = (t) -> {
|
||||
if (isTraditionalTrade.test(t)) {
|
||||
return false;
|
||||
} else {
|
||||
ContractInfo contract = t.getContract();
|
||||
@ -227,8 +227,8 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
||||
}
|
||||
};
|
||||
|
||||
protected final Function<TradeInfo, String> toAltcoinReceiveAddress = (t) -> {
|
||||
if (showAltCoinBuyerAddress.test(t)) {
|
||||
protected final Function<TradeInfo, String> toCryptoReceiveAddress = (t) -> {
|
||||
if (showCryptoBuyerAddress.test(t)) {
|
||||
ContractInfo contract = t.getContract();
|
||||
boolean isBuyerMakerAndSellerTaker = contract.getIsBuyerMakerAndSellerTaker();
|
||||
return isBuyerMakerAndSellerTaker // (is BTC buyer / maker)
|
||||
|
@ -34,7 +34,7 @@ import java.util.stream.Collectors;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_AMOUNT_RANGE;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_CREATION_DATE;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DETAILED_PRICE;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DETAILED_PRICE_OF_ALTCOIN;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DETAILED_PRICE_OF_CRYPTO;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DIRECTION;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_ENABLED;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_PAYMENT_METHOD;
|
||||
@ -56,7 +56,7 @@ import static protobuf.OfferDirection.SELL;
|
||||
*/
|
||||
class OfferTableBuilder extends AbstractTableBuilder {
|
||||
|
||||
// Columns common to both fiat and cryptocurrency offers.
|
||||
// Columns common to both traditional and cryptocurrency offers.
|
||||
private final Column<String> colOfferId = new StringColumn(COL_HEADER_UUID, LEFT);
|
||||
private final Column<String> colDirection = new StringColumn(COL_HEADER_DIRECTION, LEFT);
|
||||
private final Column<Long> colAmount = new SatoshiColumn("Temp Amount", NONE);
|
||||
@ -71,20 +71,20 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
@Override
|
||||
public Table build() {
|
||||
List<OfferInfo> offers = protos.stream().map(p -> (OfferInfo) p).collect(Collectors.toList());
|
||||
return isShowingFiatOffers.get()
|
||||
? buildFiatOfferTable(offers)
|
||||
return isShowingTraditionalOffers.get()
|
||||
? buildTraditionalOfferTable(offers)
|
||||
: buildCryptoCurrencyOfferTable(offers);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public Table buildFiatOfferTable(List<OfferInfo> offers) {
|
||||
public Table buildTraditionalOfferTable(List<OfferInfo> offers) {
|
||||
@Nullable
|
||||
Column<String> colEnabled = enabledColumn.get(); // Not boolean: "YES", "NO", or "PENDING"
|
||||
Column<String> colFiatPrice = new StringColumn(format(COL_HEADER_DETAILED_PRICE, fiatTradeCurrency.get()), RIGHT);
|
||||
Column<String> colVolume = new StringColumn(format("Temp Volume (%s)", fiatTradeCurrency.get()), NONE);
|
||||
Column<String> colMinVolume = new StringColumn(format("Temp Min Volume (%s)", fiatTradeCurrency.get()), NONE);
|
||||
Column<String> colTraditionalPrice = new StringColumn(format(COL_HEADER_DETAILED_PRICE, traditionalTradeCurrency.get()), RIGHT);
|
||||
Column<String> colVolume = new StringColumn(format("Temp Volume (%s)", traditionalTradeCurrency.get()), NONE);
|
||||
Column<String> colMinVolume = new StringColumn(format("Temp Min Volume (%s)", traditionalTradeCurrency.get()), NONE);
|
||||
@Nullable
|
||||
Column<String> colTriggerPrice = fiatTriggerPriceColumn.get();
|
||||
Column<String> colTriggerPrice = traditionalTriggerPriceColumn.get();
|
||||
|
||||
// Populate columns with offer info.
|
||||
|
||||
@ -93,7 +93,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
colEnabled.addRow(toEnabled.apply(o));
|
||||
|
||||
colDirection.addRow(o.getDirection());
|
||||
colFiatPrice.addRow(o.getPrice());
|
||||
colTraditionalPrice.addRow(o.getPrice());
|
||||
colMinAmount.addRow(o.getMinAmount());
|
||||
colAmount.addRow(o.getAmount());
|
||||
colVolume.addRow(o.getVolume());
|
||||
@ -109,7 +109,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
|
||||
ZippedStringColumns amountRange = zippedAmountRangeColumns.get();
|
||||
ZippedStringColumns volumeRange =
|
||||
new ZippedStringColumns(format(COL_HEADER_VOLUME_RANGE, fiatTradeCurrency.get()),
|
||||
new ZippedStringColumns(format(COL_HEADER_VOLUME_RANGE, traditionalTradeCurrency.get()),
|
||||
RIGHT,
|
||||
" - ",
|
||||
colMinVolume.asStringColumn(),
|
||||
@ -120,7 +120,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
if (isShowingMyOffers.get()) {
|
||||
return new Table(colEnabled.asStringColumn(),
|
||||
colDirection,
|
||||
colFiatPrice.justify(),
|
||||
colTraditionalPrice.justify(),
|
||||
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||
colTriggerPrice.justify(),
|
||||
@ -129,7 +129,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
colOfferId);
|
||||
} else {
|
||||
return new Table(colDirection,
|
||||
colFiatPrice.justify(),
|
||||
colTraditionalPrice.justify(),
|
||||
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||
colPaymentMethod,
|
||||
@ -142,11 +142,11 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
public Table buildCryptoCurrencyOfferTable(List<OfferInfo> offers) {
|
||||
@Nullable
|
||||
Column<String> colEnabled = enabledColumn.get(); // Not boolean: YES, NO, or PENDING
|
||||
Column<String> colBtcPrice = new StringColumn(format(COL_HEADER_DETAILED_PRICE_OF_ALTCOIN, altcoinTradeCurrency.get()), RIGHT);
|
||||
Column<String> colVolume = new StringColumn(format("Temp Volume (%s)", altcoinTradeCurrency.get()), NONE);
|
||||
Column<String> colMinVolume = new StringColumn(format("Temp Min Volume (%s)", altcoinTradeCurrency.get()), NONE);
|
||||
Column<String> colBtcPrice = new StringColumn(format(COL_HEADER_DETAILED_PRICE_OF_CRYPTO, cryptoTradeCurrency.get()), RIGHT);
|
||||
Column<String> colVolume = new StringColumn(format("Temp Volume (%s)", cryptoTradeCurrency.get()), NONE);
|
||||
Column<String> colMinVolume = new StringColumn(format("Temp Min Volume (%s)", cryptoTradeCurrency.get()), NONE);
|
||||
@Nullable
|
||||
Column<String> colTriggerPrice = altcoinTriggerPriceColumn.get();
|
||||
Column<String> colTriggerPrice = cryptoTriggerPriceColumn.get();
|
||||
|
||||
// Populate columns with offer info.
|
||||
|
||||
@ -171,7 +171,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
|
||||
ZippedStringColumns amountRange = zippedAmountRangeColumns.get();
|
||||
ZippedStringColumns volumeRange =
|
||||
new ZippedStringColumns(format(COL_HEADER_VOLUME_RANGE, altcoinTradeCurrency.get()),
|
||||
new ZippedStringColumns(format(COL_HEADER_VOLUME_RANGE, cryptoTradeCurrency.get()),
|
||||
RIGHT,
|
||||
" - ",
|
||||
colMinVolume.asStringColumn(),
|
||||
@ -214,11 +214,11 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
private final Function<String, String> toBlankOrNonZeroValue = (s) -> s.trim().equals("0") ? "" : s;
|
||||
private final Supplier<OfferInfo> firstOfferInList = () -> (OfferInfo) protos.get(0);
|
||||
private final Supplier<Boolean> isShowingMyOffers = () -> firstOfferInList.get().getIsMyOffer();
|
||||
private final Supplier<Boolean> isShowingFiatOffers = () -> isFiatOffer.test(firstOfferInList.get());
|
||||
private final Supplier<String> fiatTradeCurrency = () -> firstOfferInList.get().getCounterCurrencyCode();
|
||||
private final Supplier<String> altcoinTradeCurrency = () -> firstOfferInList.get().getBaseCurrencyCode();
|
||||
private final Supplier<Boolean> isShowingTraditionalOffers = () -> isTraditionalOffer.test(firstOfferInList.get());
|
||||
private final Supplier<String> traditionalTradeCurrency = () -> firstOfferInList.get().getCounterCurrencyCode();
|
||||
private final Supplier<String> cryptoTradeCurrency = () -> firstOfferInList.get().getBaseCurrencyCode();
|
||||
private final Supplier<Boolean> isShowingBsqOffers = () ->
|
||||
!isFiatOffer.test(firstOfferInList.get()) && altcoinTradeCurrency.get().equals("BSQ");
|
||||
!isTraditionalOffer.test(firstOfferInList.get()) && cryptoTradeCurrency.get().equals("BSQ");
|
||||
|
||||
@Nullable // Not a boolean column: YES, NO, or PENDING.
|
||||
private final Supplier<StringColumn> enabledColumn = () ->
|
||||
@ -226,14 +226,14 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
? new StringColumn(COL_HEADER_ENABLED, LEFT)
|
||||
: null;
|
||||
@Nullable
|
||||
private final Supplier<StringColumn> fiatTriggerPriceColumn = () ->
|
||||
private final Supplier<StringColumn> traditionalTriggerPriceColumn = () ->
|
||||
isShowingMyOffers.get()
|
||||
? new StringColumn(format(COL_HEADER_TRIGGER_PRICE, fiatTradeCurrency.get()), RIGHT)
|
||||
? new StringColumn(format(COL_HEADER_TRIGGER_PRICE, traditionalTradeCurrency.get()), RIGHT)
|
||||
: null;
|
||||
@Nullable
|
||||
private final Supplier<StringColumn> altcoinTriggerPriceColumn = () ->
|
||||
private final Supplier<StringColumn> cryptoTriggerPriceColumn = () ->
|
||||
isShowingMyOffers.get() && !isShowingBsqOffers.get()
|
||||
? new StringColumn(format(COL_HEADER_TRIGGER_PRICE, altcoinTradeCurrency.get()), RIGHT)
|
||||
? new StringColumn(format(COL_HEADER_TRIGGER_PRICE, cryptoTradeCurrency.get()), RIGHT)
|
||||
: null;
|
||||
|
||||
private final Function<OfferInfo, String> toEnabled = (o) -> {
|
||||
@ -244,7 +244,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
d.equalsIgnoreCase(BUY.name()) ? SELL.name() : BUY.name();
|
||||
|
||||
private final Function<OfferInfo, String> directionFormat = (o) -> {
|
||||
if (isFiatOffer.test(o)) {
|
||||
if (isTraditionalOffer.test(o)) {
|
||||
return o.getBaseCurrencyCode();
|
||||
} else {
|
||||
// Return "Sell BSQ (Buy BTC)", or "Buy BSQ (Sell BTC)".
|
||||
|
@ -46,7 +46,7 @@ class TableBuilderConstants {
|
||||
static final String COL_HEADER_DATE_TIME = "Date/Time (UTC)";
|
||||
static final String COL_HEADER_DETAILED_AMOUNT = "Amount(%-3s)";
|
||||
static final String COL_HEADER_DETAILED_PRICE = "Price in %-3s for 1 BTC";
|
||||
static final String COL_HEADER_DETAILED_PRICE_OF_ALTCOIN = "Price in BTC for 1 %-3s";
|
||||
static final String COL_HEADER_DETAILED_PRICE_OF_CRYPTO = "Price in BTC for 1 %-3s";
|
||||
static final String COL_HEADER_DIRECTION = "Buy/Sell";
|
||||
static final String COL_HEADER_ENABLED = "Enabled";
|
||||
static final String COL_HEADER_MARKET = "Market";
|
||||
@ -55,7 +55,7 @@ class TableBuilderConstants {
|
||||
static final String COL_HEADER_PAYMENT_METHOD = "Payment Method";
|
||||
static final String COL_HEADER_PRICE = "Price";
|
||||
static final String COL_HEADER_STATUS = "Status";
|
||||
static final String COL_HEADER_TRADE_ALTCOIN_BUYER_ADDRESS = "%-3s Buyer Address";
|
||||
static final String COL_HEADER_TRADE_CRYPTO_BUYER_ADDRESS = "%-3s Buyer Address";
|
||||
static final String COL_HEADER_TRADE_BUYER_COST = "Buyer Cost(%-3s)";
|
||||
static final String COL_HEADER_TRADE_DEPOSIT_CONFIRMED = "Deposit Confirmed";
|
||||
static final String COL_HEADER_TRADE_DEPOSIT_PUBLISHED = "Deposit Published";
|
||||
|
@ -66,8 +66,8 @@ class TradeDetailTableBuilder extends AbstractTradeListBuilder {
|
||||
colIsPaymentReceivedMessageSent.addRow(trade.getIsPaymentReceived());
|
||||
colIsPayoutPublished.addRow(trade.getIsPayoutPublished());
|
||||
colIsCompleted.addRow(trade.getIsCompleted());
|
||||
if (colAltcoinReceiveAddressColumn != null)
|
||||
colAltcoinReceiveAddressColumn.addRow(toAltcoinReceiveAddress.apply(trade));
|
||||
if (colCryptoReceiveAddressColumn != null)
|
||||
colCryptoReceiveAddressColumn.addRow(toCryptoReceiveAddress.apply(trade));
|
||||
}
|
||||
|
||||
private List<Column<?>> defineColumnList(TradeInfo trade) {
|
||||
@ -90,8 +90,8 @@ class TradeDetailTableBuilder extends AbstractTradeListBuilder {
|
||||
add(colIsCompleted.asStringColumn());
|
||||
}};
|
||||
|
||||
if (colAltcoinReceiveAddressColumn != null)
|
||||
columns.add(colAltcoinReceiveAddressColumn);
|
||||
if (colCryptoReceiveAddressColumn != null)
|
||||
columns.add(colCryptoReceiveAddressColumn);
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package haveno.cli.table.builder;
|
||||
|
||||
import haveno.cli.table.column.AltcoinVolumeColumn;
|
||||
import haveno.cli.table.column.CryptoVolumeColumn;
|
||||
import haveno.cli.table.column.BooleanColumn;
|
||||
import haveno.cli.table.column.BtcColumn;
|
||||
import haveno.cli.table.column.Column;
|
||||
@ -43,14 +43,14 @@ import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_CURRENCY
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DATE_TIME;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DETAILED_AMOUNT;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DETAILED_PRICE;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DETAILED_PRICE_OF_ALTCOIN;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DETAILED_PRICE_OF_CRYPTO;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DEVIATION;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_MARKET;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_OFFER_TYPE;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_PAYMENT_METHOD;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_PRICE;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_STATUS;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_TRADE_ALTCOIN_BUYER_ADDRESS;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_TRADE_CRYPTO_BUYER_ADDRESS;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_TRADE_BUYER_COST;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_TRADE_DEPOSIT_CONFIRMED;
|
||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_TRADE_DEPOSIT_PUBLISHED;
|
||||
@ -69,8 +69,8 @@ import static haveno.cli.table.builder.TableType.CLOSED_TRADES_TBL;
|
||||
import static haveno.cli.table.builder.TableType.FAILED_TRADES_TBL;
|
||||
import static haveno.cli.table.builder.TableType.OPEN_TRADES_TBL;
|
||||
import static haveno.cli.table.builder.TableType.TRADE_DETAIL_TBL;
|
||||
import static haveno.cli.table.column.AltcoinVolumeColumn.DISPLAY_MODE.ALTCOIN_VOLUME;
|
||||
import static haveno.cli.table.column.AltcoinVolumeColumn.DISPLAY_MODE.BSQ_VOLUME;
|
||||
import static haveno.cli.table.column.CryptoVolumeColumn.DISPLAY_MODE.CRYPTO_VOLUME;
|
||||
import static haveno.cli.table.column.CryptoVolumeColumn.DISPLAY_MODE.BSQ_VOLUME;
|
||||
import static haveno.cli.table.column.Column.JUSTIFICATION.LEFT;
|
||||
import static haveno.cli.table.column.Column.JUSTIFICATION.RIGHT;
|
||||
import static java.lang.String.format;
|
||||
@ -97,8 +97,8 @@ class TradeTableColumnSupplier {
|
||||
private final Supplier<Boolean> isClosedTradeTblBuilder = () -> getTableType().equals(CLOSED_TRADES_TBL);
|
||||
private final Supplier<Boolean> isFailedTradeTblBuilder = () -> getTableType().equals(FAILED_TRADES_TBL);
|
||||
private final Supplier<TradeInfo> firstRow = () -> getTrades().get(0);
|
||||
private final Predicate<OfferInfo> isFiatOffer = (o) -> o.getBaseCurrencyCode().equals("BTC");
|
||||
private final Predicate<TradeInfo> isFiatTrade = (t) -> isFiatOffer.test(t.getOffer());
|
||||
private final Predicate<OfferInfo> isTraditionalOffer = (o) -> o.getBaseCurrencyCode().equals("XMR");
|
||||
private final Predicate<TradeInfo> isTraditionalTrade = (t) -> isTraditionalOffer.test(t.getOffer());
|
||||
private final Predicate<TradeInfo> isTaker = (t) -> t.getRole().toLowerCase().contains("taker");
|
||||
|
||||
final Supplier<StringColumn> tradeIdColumn = () -> isTradeDetailTblBuilder.get()
|
||||
@ -114,9 +114,9 @@ class TradeTableColumnSupplier {
|
||||
: new StringColumn(COL_HEADER_MARKET);
|
||||
|
||||
private final Function<TradeInfo, Column<String>> toDetailedPriceColumn = (t) -> {
|
||||
String colHeader = isFiatTrade.test(t)
|
||||
String colHeader = isTraditionalTrade.test(t)
|
||||
? format(COL_HEADER_DETAILED_PRICE, t.getOffer().getCounterCurrencyCode())
|
||||
: format(COL_HEADER_DETAILED_PRICE_OF_ALTCOIN, t.getOffer().getBaseCurrencyCode());
|
||||
: format(COL_HEADER_DETAILED_PRICE_OF_CRYPTO, t.getOffer().getBaseCurrencyCode());
|
||||
return new StringColumn(colHeader, RIGHT);
|
||||
};
|
||||
|
||||
@ -135,13 +135,13 @@ class TradeTableColumnSupplier {
|
||||
private final Function<TradeInfo, Column<Long>> toDetailedAmountColumn = (t) -> {
|
||||
String headerCurrencyCode = t.getOffer().getBaseCurrencyCode();
|
||||
String colHeader = format(COL_HEADER_DETAILED_AMOUNT, headerCurrencyCode);
|
||||
AltcoinVolumeColumn.DISPLAY_MODE displayMode = headerCurrencyCode.equals("BSQ") ? BSQ_VOLUME : ALTCOIN_VOLUME;
|
||||
return isFiatTrade.test(t)
|
||||
CryptoVolumeColumn.DISPLAY_MODE displayMode = headerCurrencyCode.equals("BSQ") ? BSQ_VOLUME : CRYPTO_VOLUME;
|
||||
return isTraditionalTrade.test(t)
|
||||
? new SatoshiColumn(colHeader)
|
||||
: new AltcoinVolumeColumn(colHeader, displayMode);
|
||||
: new CryptoVolumeColumn(colHeader, displayMode);
|
||||
};
|
||||
|
||||
// Can be fiat, btc or altcoin amount represented as longs. Placing the decimal
|
||||
// Can be tradional or crypto amount represented as longs. Placing the decimal
|
||||
// in the displayed string representation is done in the Column implementation.
|
||||
final Supplier<Column<Long>> amountColumn = () -> isTradeDetailTblBuilder.get()
|
||||
? toDetailedAmountColumn.apply(firstRow.get())
|
||||
@ -222,7 +222,7 @@ class TradeTableColumnSupplier {
|
||||
};
|
||||
|
||||
final Function<TradeInfo, String> toPaymentCurrencyCode = (t) ->
|
||||
isFiatTrade.test(t)
|
||||
isTraditionalTrade.test(t)
|
||||
? t.getOffer().getCounterCurrencyCode()
|
||||
: t.getOffer().getBaseCurrencyCode();
|
||||
|
||||
@ -257,8 +257,8 @@ class TradeTableColumnSupplier {
|
||||
}
|
||||
};
|
||||
|
||||
final Predicate<TradeInfo> showAltCoinBuyerAddress = (t) -> {
|
||||
if (isFiatTrade.test(t)) {
|
||||
final Predicate<TradeInfo> showCryptoBuyerAddress = (t) -> {
|
||||
if (isTraditionalTrade.test(t)) {
|
||||
return false;
|
||||
} else {
|
||||
ContractInfo contract = t.getContract();
|
||||
@ -272,12 +272,12 @@ class TradeTableColumnSupplier {
|
||||
};
|
||||
|
||||
@Nullable
|
||||
final Supplier<Column<String>> altcoinReceiveAddressColumn = () -> {
|
||||
final Supplier<Column<String>> cryptoReceiveAddressColumn = () -> {
|
||||
if (isTradeDetailTblBuilder.get()) {
|
||||
TradeInfo t = firstRow.get();
|
||||
if (showAltCoinBuyerAddress.test(t)) {
|
||||
if (showCryptoBuyerAddress.test(t)) {
|
||||
String headerCurrencyCode = toPaymentCurrencyCode.apply(t);
|
||||
String colHeader = format(COL_HEADER_TRADE_ALTCOIN_BUYER_ADDRESS, headerCurrencyCode);
|
||||
String colHeader = format(COL_HEADER_TRADE_CRYPTO_BUYER_ADDRESS, headerCurrencyCode);
|
||||
return new StringColumn(colHeader);
|
||||
} else {
|
||||
return null;
|
||||
|
@ -24,23 +24,23 @@ import java.util.stream.IntStream;
|
||||
import static haveno.cli.table.column.Column.JUSTIFICATION.RIGHT;
|
||||
|
||||
/**
|
||||
* For displaying altcoin volume with appropriate precision.
|
||||
* For displaying crypto volume with appropriate precision.
|
||||
*/
|
||||
public class AltcoinVolumeColumn extends LongColumn {
|
||||
public class CryptoVolumeColumn extends LongColumn {
|
||||
|
||||
public enum DISPLAY_MODE {
|
||||
ALTCOIN_VOLUME,
|
||||
CRYPTO_VOLUME,
|
||||
BSQ_VOLUME,
|
||||
}
|
||||
|
||||
private final DISPLAY_MODE displayMode;
|
||||
|
||||
// The default AltcoinVolumeColumn JUSTIFICATION is RIGHT.
|
||||
public AltcoinVolumeColumn(String name, DISPLAY_MODE displayMode) {
|
||||
// The default CryptoVolumeColumn JUSTIFICATION is RIGHT.
|
||||
public CryptoVolumeColumn(String name, DISPLAY_MODE displayMode) {
|
||||
this(name, RIGHT, displayMode);
|
||||
}
|
||||
|
||||
public AltcoinVolumeColumn(String name,
|
||||
public CryptoVolumeColumn(String name,
|
||||
JUSTIFICATION justification,
|
||||
DISPLAY_MODE displayMode) {
|
||||
super(name, justification);
|
||||
@ -65,7 +65,7 @@ public class AltcoinVolumeColumn extends LongColumn {
|
||||
|
||||
@Override
|
||||
public StringColumn asStringColumn() {
|
||||
// We cached the formatted altcoin value strings, but we did
|
||||
// We cached the formatted crypto value strings, but we did
|
||||
// not know how much padding each string needed until now.
|
||||
IntStream.range(0, stringColumn.getRows().size()).forEach(rowIndex -> {
|
||||
String unjustified = stringColumn.getRow(rowIndex);
|
||||
@ -77,7 +77,7 @@ public class AltcoinVolumeColumn extends LongColumn {
|
||||
|
||||
private final BiFunction<Long, DISPLAY_MODE, String> toFormattedString = (value, displayMode) -> {
|
||||
switch (displayMode) {
|
||||
case ALTCOIN_VOLUME:
|
||||
case CRYPTO_VOLUME:
|
||||
return value > 0 ? new BigDecimal(value).movePointLeft(8).toString() : "";
|
||||
case BSQ_VOLUME:
|
||||
return value > 0 ? new BigDecimal(value).movePointLeft(2).toString() : "";
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* This file is part of Haveno.
|
||||
*
|
||||
* Haveno is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Haveno is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Haveno. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package haveno.cli.table.column;
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static haveno.cli.CurrencyFormat.formatFiatVolume;
|
||||
import static haveno.cli.CurrencyFormat.formatPrice;
|
||||
import static haveno.cli.table.column.Column.JUSTIFICATION.RIGHT;
|
||||
import static haveno.cli.table.column.FiatColumn.DISPLAY_MODE.FIAT_PRICE;
|
||||
|
||||
/**
|
||||
* For displaying fiat volume or price with appropriate precision.
|
||||
*/
|
||||
public class FiatColumn extends LongColumn {
|
||||
|
||||
public enum DISPLAY_MODE {
|
||||
FIAT_PRICE,
|
||||
FIAT_VOLUME
|
||||
}
|
||||
|
||||
private final DISPLAY_MODE displayMode;
|
||||
|
||||
// The default FiatColumn JUSTIFICATION is RIGHT.
|
||||
// The default FiatColumn DISPLAY_MODE is PRICE.
|
||||
public FiatColumn(String name) {
|
||||
this(name, RIGHT, FIAT_PRICE);
|
||||
}
|
||||
|
||||
public FiatColumn(String name, DISPLAY_MODE displayMode) {
|
||||
this(name, RIGHT, displayMode);
|
||||
}
|
||||
|
||||
public FiatColumn(String name,
|
||||
JUSTIFICATION justification,
|
||||
DISPLAY_MODE displayMode) {
|
||||
super(name, justification);
|
||||
this.displayMode = displayMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRow(Long value) {
|
||||
rows.add(value);
|
||||
|
||||
String s = displayMode.equals(FIAT_PRICE) ? formatPrice(value) : formatFiatVolume(value);
|
||||
|
||||
stringColumn.addRow(s);
|
||||
|
||||
if (isNewMaxWidth.test(s))
|
||||
maxWidth = s.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRowAsFormattedString(int rowIndex) {
|
||||
return getRow(rowIndex).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringColumn asStringColumn() {
|
||||
// We cached the formatted fiat price strings, but we did
|
||||
// not know how much padding each string needed until now.
|
||||
IntStream.range(0, stringColumn.getRows().size()).forEach(rowIndex -> {
|
||||
String unjustified = stringColumn.getRow(rowIndex);
|
||||
String justified = stringColumn.toJustifiedString(unjustified);
|
||||
stringColumn.updateRow(rowIndex, justified);
|
||||
});
|
||||
return this.stringColumn;
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ public abstract class AbstractCliTest {
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
protected final BiFunction<Double, Double, String> randomFixedAltcoinPrice = (min, max) -> {
|
||||
protected final BiFunction<Double, Double, String> randomFixedCryptoPrice = (min, max) -> {
|
||||
String random = Double.valueOf(ThreadLocalRandom.current().nextDouble(min, max)).toString();
|
||||
BigDecimal bd = new BigDecimal(random).setScale(8, HALF_UP);
|
||||
return bd.toPlainString();
|
||||
@ -114,7 +114,7 @@ public abstract class AbstractCliTest {
|
||||
log.info("NEW Console OUT:\n{}", tbl);
|
||||
}
|
||||
|
||||
protected List<OfferInfo> getMyAltcoinOffers(String currencyCode) {
|
||||
protected List<OfferInfo> getMyCryptoOffers(String currencyCode) {
|
||||
String[] args = getMyOffersCommand("buy", currencyCode);
|
||||
out.print(">>>>> haveno-cli ");
|
||||
stream(args).forEach(a -> out.print(a + " "));
|
||||
|
@ -28,16 +28,16 @@ public class EditXmrOffersSmokeTest extends AbstractCliTest {
|
||||
|
||||
test.doOfferPriceEdits();
|
||||
|
||||
List<OfferInfo> offers = test.getMyAltcoinOffers("xmr");
|
||||
List<OfferInfo> offers = test.getMyCryptoOffers("xmr");
|
||||
test.disableOffers(offers);
|
||||
|
||||
test.sleep(6);
|
||||
|
||||
offers = test.getMyAltcoinOffers("xmr");
|
||||
offers = test.getMyCryptoOffers("xmr");
|
||||
test.enableOffers(offers);
|
||||
|
||||
// A final look after last edit.
|
||||
test.getMyAltcoinOffers("xmr");
|
||||
test.getMyCryptoOffers("xmr");
|
||||
}
|
||||
|
||||
private void doOfferPriceEdits() {
|
||||
@ -48,7 +48,7 @@ public class EditXmrOffersSmokeTest extends AbstractCliTest {
|
||||
}
|
||||
|
||||
private void editPriceMargin() {
|
||||
var offers = getMyAltcoinOffers("xmr");
|
||||
var offers = getMyCryptoOffers("xmr");
|
||||
out.println("Edit XMR offers' price margin");
|
||||
var margins = randomMarginBasedPrices.apply(-301, 300);
|
||||
for (int i = 0; i < offers.size(); i++) {
|
||||
@ -59,7 +59,7 @@ public class EditXmrOffersSmokeTest extends AbstractCliTest {
|
||||
}
|
||||
|
||||
private void editTriggerPrice() {
|
||||
var offers = getMyAltcoinOffers("xmr");
|
||||
var offers = getMyCryptoOffers("xmr");
|
||||
out.println("Edit XMR offers' trigger price");
|
||||
for (int i = 0; i < offers.size(); i++) {
|
||||
var offer = offers.get(i);
|
||||
@ -74,7 +74,7 @@ public class EditXmrOffersSmokeTest extends AbstractCliTest {
|
||||
}
|
||||
|
||||
private void editPriceMarginAndTriggerPrice() {
|
||||
var offers = getMyAltcoinOffers("xmr");
|
||||
var offers = getMyCryptoOffers("xmr");
|
||||
out.println("Edit XMR offers' price margin and trigger price");
|
||||
for (int i = 0; i < offers.size(); i++) {
|
||||
var offer = offers.get(i);
|
||||
@ -89,10 +89,10 @@ public class EditXmrOffersSmokeTest extends AbstractCliTest {
|
||||
}
|
||||
|
||||
private void editFixedPrice() {
|
||||
var offers = getMyAltcoinOffers("xmr");
|
||||
var offers = getMyCryptoOffers("xmr");
|
||||
out.println("Edit XMR offers' fixed price");
|
||||
for (int i = 0; i < offers.size(); i++) {
|
||||
String randomFixedPrice = randomFixedAltcoinPrice.apply(0.004, 0.0075);
|
||||
String randomFixedPrice = randomFixedCryptoPrice.apply(0.004, 0.0075);
|
||||
editOfferFixedPrice(offers.get(i), randomFixedPrice, new Random().nextBoolean());
|
||||
sleep(5);
|
||||
}
|
||||
|
@ -210,16 +210,16 @@ public class AccountAgeWitnessService {
|
||||
}
|
||||
|
||||
private void onBootStrapped() {
|
||||
republishAllFiatAccounts();
|
||||
republishAllTraditionalAccounts();
|
||||
signAndPublishSameNameAccounts();
|
||||
}
|
||||
|
||||
|
||||
// At startup we re-publish the witness data of all fiat accounts to ensure we got our data well distributed.
|
||||
private void republishAllFiatAccounts() {
|
||||
// At startup we re-publish the witness data of all traditional accounts to ensure we got our data well distributed.
|
||||
private void republishAllTraditionalAccounts() {
|
||||
if (user.getPaymentAccounts() != null)
|
||||
user.getPaymentAccounts().stream()
|
||||
.filter(account -> account.getPaymentMethod().isFiat())
|
||||
.filter(account -> account.getPaymentMethod().isTraditional())
|
||||
.forEach(account -> {
|
||||
AccountAgeWitness myWitness = getMyWitness(account.getPaymentAccountPayload());
|
||||
// We only publish if the date of our witness is inside the date tolerance.
|
||||
|
@ -19,8 +19,10 @@ package haveno.core.api;
|
||||
|
||||
import haveno.common.crypto.KeyRing;
|
||||
import haveno.common.handlers.ErrorMessageHandler;
|
||||
import haveno.core.monetary.Altcoin;
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.monetary.CryptoMoney;
|
||||
import haveno.core.monetary.Price;
|
||||
import haveno.core.monetary.TraditionalMoney;
|
||||
import haveno.core.offer.CreateOfferService;
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.offer.OfferBookService;
|
||||
@ -35,7 +37,6 @@ import haveno.core.user.User;
|
||||
import haveno.core.util.PriceUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -53,7 +54,6 @@ import java.util.stream.Collectors;
|
||||
import static haveno.common.util.MathUtils.exactMultiply;
|
||||
import static haveno.common.util.MathUtils.roundDoubleToLong;
|
||||
import static haveno.common.util.MathUtils.scaleUpByPowerOf10;
|
||||
import static haveno.core.locale.CurrencyUtil.isCryptoCurrency;
|
||||
import static haveno.core.offer.OfferDirection.BUY;
|
||||
import static haveno.core.payment.PaymentAccountUtil.isPaymentAccountValidForOffer;
|
||||
import static java.lang.String.format;
|
||||
@ -285,7 +285,7 @@ public class CoreOffersService {
|
||||
if ("".equals(direction)) direction = null;
|
||||
if ("".equals(currencyCode)) currencyCode = null;
|
||||
var offerOfWantedDirection = direction == null || offer.getDirection().name().equalsIgnoreCase(direction);
|
||||
var counterAssetCode = isCryptoCurrency(currencyCode) ? offer.getOfferPayload().getBaseCurrencyCode() : offer.getOfferPayload().getCounterCurrencyCode(); // TODO: crypto pairs invert base and counter currencies
|
||||
var counterAssetCode = CurrencyUtil.isCryptoCurrency(currencyCode) ? offer.getOfferPayload().getBaseCurrencyCode() : offer.getOfferPayload().getCounterCurrencyCode();
|
||||
var offerInWantedCurrency = currencyCode == null || counterAssetCode.equalsIgnoreCase(currencyCode);
|
||||
return offerOfWantedDirection && offerInWantedCurrency;
|
||||
}
|
||||
@ -299,7 +299,7 @@ public class CoreOffersService {
|
||||
}
|
||||
|
||||
private long priceStringToLong(String priceAsString, String currencyCode) {
|
||||
int precision = isCryptoCurrency(currencyCode) ? Altcoin.SMALLEST_UNIT_EXPONENT : Fiat.SMALLEST_UNIT_EXPONENT;
|
||||
int precision = CurrencyUtil.isTraditionalCurrency(currencyCode) ? TraditionalMoney.SMALLEST_UNIT_EXPONENT : CryptoMoney.SMALLEST_UNIT_EXPONENT;
|
||||
double priceAsDouble = new BigDecimal(priceAsString).doubleValue();
|
||||
double scaled = scaleUpByPowerOf10(priceAsDouble, precision);
|
||||
return roundDoubleToLong(scaled);
|
||||
|
@ -153,7 +153,7 @@ class CorePaymentAccountsService {
|
||||
|
||||
List<PaymentMethod> getCryptoCurrencyPaymentMethods() {
|
||||
return PaymentMethod.getPaymentMethods().stream()
|
||||
.filter(PaymentMethod::isAltcoin)
|
||||
.filter(PaymentMethod::isCrypto)
|
||||
.sorted(Comparator.comparing(PaymentMethod::getId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class CorePriceService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Price per 1 XMR in the given currency (fiat or crypto)
|
||||
* @return Price per 1 XMR in the given currency (traditional or crypto)
|
||||
*/
|
||||
public double getMarketPrice(String currencyCode) throws ExecutionException, InterruptedException, TimeoutException, IllegalArgumentException {
|
||||
var marketPrice = priceFeedService.requestAllPrices().get(currencyCode);
|
||||
@ -64,7 +64,7 @@ class CorePriceService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Price per 1 XMR in all supported currencies (fiat & crypto)
|
||||
* @return Price per 1 XMR in all supported currencies (traditional & crypto)
|
||||
*/
|
||||
public List<MarketPriceInfo> getMarketPrices() throws ExecutionException, InterruptedException, TimeoutException {
|
||||
return priceFeedService.requestAllPrices().values().stream()
|
||||
@ -84,8 +84,8 @@ class CorePriceService {
|
||||
// Offer price can be null (if price feed unavailable), thus a null-tolerant comparator is used.
|
||||
Comparator<Offer> offerPriceComparator = Comparator.comparing(Offer::getPrice, Comparator.nullsLast(Comparator.naturalOrder()));
|
||||
|
||||
// Trading btc-fiat is considered as buying/selling BTC, but trading btc-altcoin is
|
||||
// considered as buying/selling Altcoin. Because of this, when viewing a btc-altcoin pair,
|
||||
// Trading xmr-traditional is considered as buying/selling XMR, but trading xmr-crypto is
|
||||
// considered as buying/selling crypto. Because of this, when viewing a xmr-crypto pair,
|
||||
// the buy column is actually the sell column and vice versa. To maintain the expected
|
||||
// ordering, we have to reverse the price comparator.
|
||||
boolean isCrypto = CurrencyUtil.isCryptoCurrency(currencyCode);
|
||||
@ -141,14 +141,14 @@ class CorePriceService {
|
||||
}
|
||||
|
||||
/**
|
||||
* PriceProvider returns different values for crypto and fiat,
|
||||
* PriceProvider returns different values for crypto and traditional,
|
||||
* e.g. 1 XMR = X USD
|
||||
* but 1 DOGE = X XMR
|
||||
* Here we convert all to:
|
||||
* 1 XMR = X (FIAT or CRYPTO)
|
||||
*/
|
||||
private double mapPriceFeedServicePrice(double price, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
|
||||
return price;
|
||||
}
|
||||
return price == 0 ? 0 : 1 / price;
|
||||
|
@ -62,8 +62,8 @@ public class OfferInfo implements Payload {
|
||||
private final String paymentAccountId;
|
||||
private final String paymentMethodId;
|
||||
private final String paymentMethodShortName;
|
||||
// For fiat offer the baseCurrencyCode is BTC and the counterCurrencyCode is the fiat currency
|
||||
// For altcoin offers it is the opposite. baseCurrencyCode is the altcoin and the counterCurrencyCode is BTC.
|
||||
// For traditional offer the baseCurrencyCode is XMR and the counterCurrencyCode is the traditional currency
|
||||
// For crypto offers it is the opposite. baseCurrencyCode is the crypto and the counterCurrencyCode is XMR.
|
||||
private final String baseCurrencyCode;
|
||||
private final String counterCurrencyCode;
|
||||
private final long date;
|
||||
|
@ -17,18 +17,19 @@
|
||||
|
||||
package haveno.core.locale;
|
||||
|
||||
import haveno.core.monetary.TraditionalMoney;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode
|
||||
public class CurrencyTuple {
|
||||
public final String code;
|
||||
public final String name;
|
||||
public final int precision; // precision 4 is 1/10000 -> 0.0001 is smallest unit
|
||||
public final int precision; // precision 8 is 1/100000000 -> 0.00000001 is smallest unit
|
||||
|
||||
public CurrencyTuple(String code, String name) {
|
||||
// We use Fiat class and the precision is 4
|
||||
// We use TraditionalCurrency class and the precision is 8
|
||||
// In future we might add custom precision per currency
|
||||
this(code, name, 4);
|
||||
this(code, name, TraditionalMoney.SMALLEST_UNIT_EXPONENT);
|
||||
}
|
||||
|
||||
public CurrencyTuple(String code, String name, int precision) {
|
||||
|
@ -56,16 +56,16 @@ public class CurrencyUtil {
|
||||
|
||||
private static String baseCurrencyCode = "XMR";
|
||||
|
||||
// Calls to isFiatCurrency and isCryptoCurrency are very frequent so we use a cache of the results.
|
||||
// Calls to isTraditionalCurrency and isCryptoCurrency are very frequent so we use a cache of the results.
|
||||
// The main improvement was already achieved with using memoize for the source maps, but
|
||||
// the caching still reduces performance costs by about 20% for isCryptoCurrency (1752 ms vs 2121 ms) and about 50%
|
||||
// for isFiatCurrency calls (1777 ms vs 3467 ms).
|
||||
// for isTraditionalCurrency calls (1777 ms vs 3467 ms).
|
||||
// See: https://github.com/bisq-network/bisq/pull/4955#issuecomment-745302802
|
||||
private static final Map<String, Boolean> isFiatCurrencyMap = new ConcurrentHashMap<>();
|
||||
private static final Map<String, Boolean> isTraditionalCurrencyMap = new ConcurrentHashMap<>();
|
||||
private static final Map<String, Boolean> isCryptoCurrencyMap = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Supplier<Map<String, FiatCurrency>> fiatCurrencyMapSupplier = Suppliers.memoize(
|
||||
CurrencyUtil::createFiatCurrencyMap);
|
||||
private static final Supplier<Map<String, TraditionalCurrency>> traditionalCurrencyMapSupplier = Suppliers.memoize(
|
||||
CurrencyUtil::createTraditionalCurrencyMap);
|
||||
private static final Supplier<Map<String, CryptoCurrency>> cryptoCurrencyMapSupplier = Suppliers.memoize(
|
||||
CurrencyUtil::createCryptoCurrencyMap);
|
||||
|
||||
@ -73,48 +73,52 @@ public class CurrencyUtil {
|
||||
CurrencyUtil.baseCurrencyCode = baseCurrencyCode;
|
||||
}
|
||||
|
||||
public static Collection<FiatCurrency> getAllSortedFiatCurrencies() {
|
||||
return fiatCurrencyMapSupplier.get().values(); // sorted by currency name
|
||||
public static Collection<TraditionalCurrency> getAllSortedTraditionalCurrencies() {
|
||||
return traditionalCurrencyMapSupplier.get().values(); // sorted by currency name
|
||||
}
|
||||
|
||||
public static List<TradeCurrency> getAllFiatCurrencies() {
|
||||
return new ArrayList<>(fiatCurrencyMapSupplier.get().values());
|
||||
public static List<TradeCurrency> getAllTraditionalCurrencies() {
|
||||
return new ArrayList<>(traditionalCurrencyMapSupplier.get().values());
|
||||
}
|
||||
|
||||
public static Collection<FiatCurrency> getAllSortedFiatCurrencies(Comparator comparator) {
|
||||
return (List<FiatCurrency>) getAllSortedFiatCurrencies().stream()
|
||||
public static Collection<TraditionalCurrency> getAllSortedTraditionalCurrencies(Comparator comparator) {
|
||||
return (List<TraditionalCurrency>) getAllSortedTraditionalCurrencies().stream()
|
||||
.sorted(comparator) // sorted by comparator param
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static Map<String, FiatCurrency> createFiatCurrencyMap() {
|
||||
return CountryUtil.getAllCountries().stream()
|
||||
private static Map<String, TraditionalCurrency> createTraditionalCurrencyMap() {
|
||||
List<TraditionalCurrency> currencies = CountryUtil.getAllCountries().stream()
|
||||
.map(country -> getCurrencyByCountryCode(country.code))
|
||||
.sorted(TradeCurrency::compareTo)
|
||||
.collect(Collectors.toList());
|
||||
currencies.add(new TraditionalCurrency(Currency.getInstance("XAG"))); // add silver
|
||||
currencies.add(new TraditionalCurrency(Currency.getInstance("XAU"))); // add gold
|
||||
return currencies.stream().sorted(TradeCurrency::compareTo)
|
||||
.distinct()
|
||||
.collect(Collectors.toMap(TradeCurrency::getCode, Function.identity(), (x, y) -> x, LinkedHashMap::new));
|
||||
}
|
||||
|
||||
public static List<FiatCurrency> getMainFiatCurrencies() {
|
||||
public static List<TraditionalCurrency> getMainTraditionalCurrencies() {
|
||||
TradeCurrency defaultTradeCurrency = getDefaultTradeCurrency();
|
||||
List<FiatCurrency> list = new ArrayList<>();
|
||||
// Top traded currencies
|
||||
list.add(new FiatCurrency("USD"));
|
||||
list.add(new FiatCurrency("EUR"));
|
||||
list.add(new FiatCurrency("GBP"));
|
||||
list.add(new FiatCurrency("CAD"));
|
||||
list.add(new FiatCurrency("AUD"));
|
||||
list.add(new FiatCurrency("RUB"));
|
||||
list.add(new FiatCurrency("INR"));
|
||||
list.add(new FiatCurrency("NGN"));
|
||||
List<TraditionalCurrency> list = new ArrayList<>();
|
||||
list.add(new TraditionalCurrency("USD"));
|
||||
list.add(new TraditionalCurrency("EUR"));
|
||||
list.add(new TraditionalCurrency("GBP"));
|
||||
list.add(new TraditionalCurrency("CAD"));
|
||||
list.add(new TraditionalCurrency("AUD"));
|
||||
list.add(new TraditionalCurrency("RUB"));
|
||||
list.add(new TraditionalCurrency("INR"));
|
||||
list.add(new TraditionalCurrency("NGN"));
|
||||
list.add(new TraditionalCurrency("XAG"));
|
||||
list.add(new TraditionalCurrency("XAU"));
|
||||
|
||||
list.sort(TradeCurrency::compareTo);
|
||||
|
||||
FiatCurrency defaultFiatCurrency =
|
||||
defaultTradeCurrency instanceof FiatCurrency ? (FiatCurrency) defaultTradeCurrency : null;
|
||||
if (defaultFiatCurrency != null && list.contains(defaultFiatCurrency)) {
|
||||
TraditionalCurrency defaultTraditionalCurrency =
|
||||
defaultTradeCurrency instanceof TraditionalCurrency ? (TraditionalCurrency) defaultTradeCurrency : null;
|
||||
if (defaultTraditionalCurrency != null && list.contains(defaultTraditionalCurrency)) {
|
||||
list.remove(defaultTradeCurrency);
|
||||
list.add(0, defaultFiatCurrency);
|
||||
list.add(0, defaultTraditionalCurrency);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -165,53 +169,59 @@ public class CurrencyUtil {
|
||||
|
||||
public static List<TradeCurrency> getMatureMarketCurrencies() {
|
||||
ArrayList<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("USD"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("CAD"),
|
||||
new FiatCurrency("AUD"),
|
||||
new FiatCurrency("BRL")
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("USD"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("CAD"),
|
||||
new TraditionalCurrency("AUD"),
|
||||
new TraditionalCurrency("BRL")
|
||||
));
|
||||
currencies.sort(Comparator.comparing(TradeCurrency::getCode));
|
||||
return currencies;
|
||||
}
|
||||
|
||||
public static boolean isFiatCurrency(String currencyCode) {
|
||||
if (currencyCode != null && isFiatCurrencyMap.containsKey(currencyCode)) {
|
||||
return isFiatCurrencyMap.get(currencyCode);
|
||||
if (!isTraditionalCurrency(currencyCode)) return false;
|
||||
if ("xag".equalsIgnoreCase(currencyCode) || "xau".equalsIgnoreCase(currencyCode)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isTraditionalCurrency(String currencyCode) {
|
||||
if (currencyCode != null && isTraditionalCurrencyMap.containsKey(currencyCode)) {
|
||||
return isTraditionalCurrencyMap.get(currencyCode);
|
||||
}
|
||||
|
||||
try {
|
||||
boolean isFiatCurrency = currencyCode != null
|
||||
boolean isTraditionalCurrency = currencyCode != null
|
||||
&& !currencyCode.isEmpty()
|
||||
&& !isCryptoCurrency(currencyCode)
|
||||
&& Currency.getInstance(currencyCode) != null;
|
||||
|
||||
if (currencyCode != null) {
|
||||
isFiatCurrencyMap.put(currencyCode, isFiatCurrency);
|
||||
isTraditionalCurrencyMap.put(currencyCode, isTraditionalCurrency);
|
||||
}
|
||||
|
||||
return isFiatCurrency;
|
||||
return isTraditionalCurrency;
|
||||
} catch (Throwable t) {
|
||||
isFiatCurrencyMap.put(currencyCode, false);
|
||||
isTraditionalCurrencyMap.put(currencyCode, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<FiatCurrency> getFiatCurrency(String currencyCode) {
|
||||
return Optional.ofNullable(fiatCurrencyMapSupplier.get().get(currencyCode));
|
||||
public static Optional<TraditionalCurrency> getTraditionalCurrency(String currencyCode) {
|
||||
return Optional.ofNullable(traditionalCurrencyMapSupplier.get().get(currencyCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* We return true if it is BTC or any of our currencies available in the assetRegistry.
|
||||
* For removed assets it would fail as they are not found but we don't want to conclude that they are fiat then.
|
||||
* As the caller might not deal with the case that a currency can be neither a cryptoCurrency nor Fiat if not found
|
||||
* we return true as well in case we have no fiat currency for the code.
|
||||
* For removed assets it would fail as they are not found but we don't want to conclude that they are traditional then.
|
||||
* As the caller might not deal with the case that a currency can be neither a cryptoCurrency nor Traditional if not found
|
||||
* we return true as well in case we have no traditional currency for the code.
|
||||
*
|
||||
* As we use a boolean result for isCryptoCurrency and isFiatCurrency we do not treat missing currencies correctly.
|
||||
* As we use a boolean result for isCryptoCurrency and isTraditionalCurrency we do not treat missing currencies correctly.
|
||||
* To throw an exception might be an option but that will require quite a lot of code change, so we don't do that
|
||||
* for the moment, but could be considered for the future. Another maybe better option is to introduce an enum which
|
||||
* contains 3 entries (CryptoCurrency, Fiat, Undefined).
|
||||
* contains 3 entries (CryptoCurrency, Traditional, Undefined).
|
||||
*/
|
||||
public static boolean isCryptoCurrency(String currencyCode) {
|
||||
if (currencyCode != null) currencyCode = currencyCode.toUpperCase();
|
||||
@ -230,14 +240,14 @@ public class CurrencyUtil {
|
||||
} else if (getCryptoCurrency(currencyCode).isPresent()) {
|
||||
// If we find the code in our assetRegistry we return true.
|
||||
// It might be that an asset was removed from the assetsRegistry, we deal with such cases below by checking if
|
||||
// it is a fiat currency
|
||||
// it is a traditional currency
|
||||
isCryptoCurrency = true;
|
||||
} else if (getFiatCurrency(currencyCode).isEmpty()) {
|
||||
// In case the code is from a removed asset we cross check if there exist a fiat currency with that code,
|
||||
// if we don't find a fiat currency we treat it as a crypto currency.
|
||||
} else if (getTraditionalCurrency(currencyCode).isEmpty()) {
|
||||
// In case the code is from a removed asset we cross check if there exist a traditional currency with that code,
|
||||
// if we don't find a traditional currency we treat it as a crypto currency.
|
||||
isCryptoCurrency = true;
|
||||
} else {
|
||||
// If we would have found a fiat currency we return false
|
||||
// If we would have found a traditional currency we return false
|
||||
isCryptoCurrency = false;
|
||||
}
|
||||
|
||||
@ -253,9 +263,9 @@ public class CurrencyUtil {
|
||||
}
|
||||
|
||||
public static Optional<TradeCurrency> getTradeCurrency(String currencyCode) {
|
||||
Optional<FiatCurrency> fiatCurrencyOptional = getFiatCurrency(currencyCode);
|
||||
if (fiatCurrencyOptional.isPresent() && isFiatCurrency(currencyCode))
|
||||
return Optional.of(fiatCurrencyOptional.get());
|
||||
Optional<TraditionalCurrency> traditionalCurrencyOptional = getTraditionalCurrency(currencyCode);
|
||||
if (traditionalCurrencyOptional.isPresent() && isTraditionalCurrency(currencyCode))
|
||||
return Optional.of(traditionalCurrencyOptional.get());
|
||||
|
||||
Optional<CryptoCurrency> cryptoCurrencyOptional = getCryptoCurrency(currencyCode);
|
||||
if (cryptoCurrencyOptional.isPresent() && isCryptoCurrency(currencyCode))
|
||||
@ -290,12 +300,12 @@ public class CurrencyUtil {
|
||||
return tradeCurrencies;
|
||||
}
|
||||
|
||||
public static FiatCurrency getCurrencyByCountryCode(String countryCode) {
|
||||
public static TraditionalCurrency getCurrencyByCountryCode(String countryCode) {
|
||||
if (countryCode.equals("XK"))
|
||||
return new FiatCurrency("EUR");
|
||||
return new TraditionalCurrency("EUR");
|
||||
|
||||
Currency currency = Currency.getInstance(new Locale(LanguageUtil.getDefaultLanguage(), countryCode));
|
||||
return new FiatCurrency(currency.getCurrencyCode());
|
||||
return new TraditionalCurrency(currency.getCurrencyCode());
|
||||
}
|
||||
|
||||
|
||||
@ -412,14 +422,14 @@ public class CurrencyUtil {
|
||||
}
|
||||
|
||||
public static String getCurrencyPair(String currencyCode) {
|
||||
if (isFiatCurrency(currencyCode))
|
||||
if (isTraditionalCurrency(currencyCode))
|
||||
return Res.getBaseCurrencyCode() + "/" + currencyCode;
|
||||
else
|
||||
return currencyCode + "/" + Res.getBaseCurrencyCode();
|
||||
}
|
||||
|
||||
public static String getCounterCurrency(String currencyCode) {
|
||||
if (isFiatCurrency(currencyCode))
|
||||
if (isTraditionalCurrency(currencyCode))
|
||||
return currencyCode;
|
||||
else
|
||||
return Res.getBaseCurrencyCode();
|
||||
@ -453,6 +463,6 @@ public class CurrencyUtil {
|
||||
}
|
||||
|
||||
public static List<TradeCurrency> getAllTransferwiseUSDCurrencies() {
|
||||
return List.of(new FiatCurrency("USD"));
|
||||
return List.of(new TraditionalCurrency("USD"));
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ public class GlobalSettings {
|
||||
GlobalSettings.useAnimations = useAnimations;
|
||||
}
|
||||
|
||||
public static void setDefaultTradeCurrency(TradeCurrency fiatCurrency) {
|
||||
GlobalSettings.defaultTradeCurrency = fiatCurrency;
|
||||
public static void setDefaultTradeCurrency(TradeCurrency tradeCurrency) {
|
||||
GlobalSettings.defaultTradeCurrency = tradeCurrency;
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,8 +45,8 @@ public abstract class TradeCurrency implements PersistablePayload, Comparable<Tr
|
||||
|
||||
public static TradeCurrency fromProto(protobuf.TradeCurrency proto) {
|
||||
switch (proto.getMessageCase()) {
|
||||
case FIAT_CURRENCY:
|
||||
return FiatCurrency.fromProto(proto);
|
||||
case TRADITIONAL_CURRENCY:
|
||||
return TraditionalCurrency.fromProto(proto);
|
||||
case CRYPTO_CURRENCY:
|
||||
return CryptoCurrency.fromProto(proto);
|
||||
default:
|
||||
|
@ -29,23 +29,23 @@ import java.util.Locale;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString
|
||||
@Getter
|
||||
public final class FiatCurrency extends TradeCurrency {
|
||||
public final class TraditionalCurrency extends TradeCurrency {
|
||||
// http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618
|
||||
private final static String PREFIX = "★ ";
|
||||
|
||||
private final Currency currency;
|
||||
|
||||
public FiatCurrency(String currencyCode) {
|
||||
public TraditionalCurrency(String currencyCode) {
|
||||
this(Currency.getInstance(currencyCode), getLocale());
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public FiatCurrency(Currency currency) {
|
||||
public TraditionalCurrency(Currency currency) {
|
||||
this(currency, getLocale());
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public FiatCurrency(Currency currency, Locale locale) {
|
||||
public TraditionalCurrency(Currency currency, Locale locale) {
|
||||
super(currency.getCurrencyCode(), currency.getDisplayName(locale));
|
||||
this.currency = currency;
|
||||
}
|
||||
@ -58,14 +58,14 @@ public final class FiatCurrency extends TradeCurrency {
|
||||
@Override
|
||||
public Message toProtoMessage() {
|
||||
protobuf.Currency.Builder currencyBuilder = protobuf.Currency.newBuilder().setCurrencyCode(currency.getCurrencyCode());
|
||||
protobuf.FiatCurrency.Builder fiatCurrencyBuilder = protobuf.FiatCurrency.newBuilder().setCurrency(currencyBuilder);
|
||||
protobuf.TraditionalCurrency.Builder traditionalCurrencyBuilder = protobuf.TraditionalCurrency.newBuilder().setCurrency(currencyBuilder);
|
||||
return getTradeCurrencyBuilder()
|
||||
.setFiatCurrency(fiatCurrencyBuilder)
|
||||
.setTraditionalCurrency(traditionalCurrencyBuilder)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static FiatCurrency fromProto(protobuf.TradeCurrency proto) {
|
||||
return new FiatCurrency(proto.getCode());
|
||||
public static TraditionalCurrency fromProto(protobuf.TradeCurrency proto) {
|
||||
return new TraditionalCurrency(proto.getCode());
|
||||
}
|
||||
|
||||
|
@ -24,61 +24,61 @@ import java.math.BigInteger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
// Cloned from ExchangeRate. Use Altcoin instead of Fiat.
|
||||
// Cloned from ExchangeRate. Use Crypto instead of Fiat.
|
||||
@Slf4j
|
||||
public class AltcoinExchangeRate {
|
||||
public class CryptoExchangeRate {
|
||||
/**
|
||||
* An exchange rate is expressed as a ratio of a {@link Coin} and a {@link Altcoin} amount.
|
||||
* An exchange rate is expressed as a ratio of a {@link Coin} and a {@link CryptoMoney} amount.
|
||||
*/
|
||||
|
||||
public final Coin coin;
|
||||
public final Altcoin altcoin;
|
||||
public final CryptoMoney crypto;
|
||||
|
||||
/**
|
||||
* Construct exchange rate. This amount of coin is worth that amount of altcoin.
|
||||
* Construct exchange rate. This amount of coin is worth that amount of crypto.
|
||||
*/
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public AltcoinExchangeRate(Coin coin, Altcoin altcoin) {
|
||||
public CryptoExchangeRate(Coin coin, CryptoMoney crypto) {
|
||||
checkArgument(coin.isPositive());
|
||||
checkArgument(altcoin.isPositive());
|
||||
checkArgument(altcoin.currencyCode != null, "currency code required");
|
||||
checkArgument(crypto.isPositive());
|
||||
checkArgument(crypto.currencyCode != null, "currency code required");
|
||||
this.coin = coin;
|
||||
this.altcoin = altcoin;
|
||||
this.crypto = crypto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct exchange rate. One coin is worth this amount of altcoin.
|
||||
* Construct exchange rate. One coin is worth this amount of crypto.
|
||||
*/
|
||||
public AltcoinExchangeRate(Altcoin altcoin) {
|
||||
this(Coin.COIN, altcoin);
|
||||
public CryptoExchangeRate(CryptoMoney crypto) {
|
||||
this(Coin.COIN, crypto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a coin amount to an altcoin amount using this exchange rate.
|
||||
* Convert a coin amount to an crypto amount using this exchange rate.
|
||||
*
|
||||
* @throws ArithmeticException if the converted altcoin amount is too high or too low.
|
||||
* @throws ArithmeticException if the converted crypto amount is too high or too low.
|
||||
*/
|
||||
public Altcoin coinToAltcoin(Coin convertCoin) {
|
||||
public CryptoMoney coinToCrypto(Coin convertCoin) {
|
||||
BigInteger converted = BigInteger.valueOf(coin.value)
|
||||
.multiply(BigInteger.valueOf(convertCoin.value))
|
||||
.divide(BigInteger.valueOf(altcoin.value));
|
||||
.divide(BigInteger.valueOf(crypto.value));
|
||||
if (converted.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0
|
||||
|| converted.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0)
|
||||
throw new ArithmeticException("Overflow");
|
||||
return Altcoin.valueOf(altcoin.currencyCode, converted.longValue());
|
||||
return CryptoMoney.valueOf(crypto.currencyCode, converted.longValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a altcoin amount to a coin amount using this exchange rate.
|
||||
* Convert a crypto amount to a coin amount using this exchange rate.
|
||||
*
|
||||
* @throws ArithmeticException if the converted coin amount is too high or too low.
|
||||
*/
|
||||
public Coin altcoinToCoin(Altcoin convertAltcoin) {
|
||||
checkArgument(convertAltcoin.currencyCode.equals(altcoin.currencyCode), "Currency mismatch: %s vs %s",
|
||||
convertAltcoin.currencyCode, altcoin.currencyCode);
|
||||
public Coin cryptoToCoin(CryptoMoney convertCrypto) {
|
||||
checkArgument(convertCrypto.currencyCode.equals(crypto.currencyCode), "Currency mismatch: %s vs %s",
|
||||
convertCrypto.currencyCode, crypto.currencyCode);
|
||||
// Use BigInteger because it's much easier to maintain full precision without overflowing.
|
||||
BigInteger converted = BigInteger.valueOf(altcoin.value)
|
||||
.multiply(BigInteger.valueOf(convertAltcoin.value))
|
||||
BigInteger converted = BigInteger.valueOf(crypto.value)
|
||||
.multiply(BigInteger.valueOf(convertCrypto.value))
|
||||
.divide(BigInteger.valueOf(coin.value));
|
||||
if (converted.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0
|
||||
|| converted.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0)
|
@ -30,12 +30,12 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
/**
|
||||
* Cloned from Fiat class and altered SMALLEST_UNIT_EXPONENT as Fiat is final.
|
||||
* <p/>
|
||||
* Represents a monetary fiat value. It was decided to not fold this into {@link org.bitcoinj.core.Coin} because of type
|
||||
* Represents a monetary crypto value. It was decided to not fold this into {@link org.bitcoinj.core.Coin} because of type
|
||||
* safety. Volume values always come with an attached currency code.
|
||||
* <p/>
|
||||
* This class is immutable.
|
||||
*/
|
||||
public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
||||
public final class CryptoMoney implements Monetary, Comparable<CryptoMoney> {
|
||||
/**
|
||||
* The absolute value of exponent of the value of a "smallest unit" in scientific notation. We picked 4 rather than
|
||||
* 2, because in financial applications it's common to use sub-cent precision.
|
||||
@ -50,13 +50,13 @@ public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
||||
public final long value;
|
||||
public final String currencyCode;
|
||||
|
||||
private Altcoin(final String currencyCode, final long value) {
|
||||
private CryptoMoney(final String currencyCode, final long value) {
|
||||
this.value = value;
|
||||
this.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
public static Altcoin valueOf(final String currencyCode, final long value) {
|
||||
return new Altcoin(currencyCode, value);
|
||||
public static CryptoMoney valueOf(final String currencyCode, final long value) {
|
||||
return new CryptoMoney(currencyCode, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,40 +85,40 @@ public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
||||
*
|
||||
* @throws IllegalArgumentException if you try to specify fractional satoshis, or a value out of range.
|
||||
*/
|
||||
public static Altcoin parseAltcoin(final String currencyCode, String input) {
|
||||
public static CryptoMoney parseCrypto(final String currencyCode, String input) {
|
||||
String cleaned = ParsingUtils.convertCharsForNumber(input);
|
||||
try {
|
||||
long val = new BigDecimal(cleaned).movePointRight(SMALLEST_UNIT_EXPONENT)
|
||||
.toBigIntegerExact().longValue();
|
||||
return Altcoin.valueOf(currencyCode, val);
|
||||
return CryptoMoney.valueOf(currencyCode, val);
|
||||
} catch (ArithmeticException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Altcoin add(final Altcoin value) {
|
||||
public CryptoMoney add(final CryptoMoney value) {
|
||||
checkArgument(value.currencyCode.equals(currencyCode));
|
||||
return new Altcoin(currencyCode, LongMath.checkedAdd(this.value, value.value));
|
||||
return new CryptoMoney(currencyCode, LongMath.checkedAdd(this.value, value.value));
|
||||
}
|
||||
|
||||
public Altcoin subtract(final Altcoin value) {
|
||||
public CryptoMoney subtract(final CryptoMoney value) {
|
||||
checkArgument(value.currencyCode.equals(currencyCode));
|
||||
return new Altcoin(currencyCode, LongMath.checkedSubtract(this.value, value.value));
|
||||
return new CryptoMoney(currencyCode, LongMath.checkedSubtract(this.value, value.value));
|
||||
}
|
||||
|
||||
public Altcoin multiply(final long factor) {
|
||||
return new Altcoin(currencyCode, LongMath.checkedMultiply(this.value, factor));
|
||||
public CryptoMoney multiply(final long factor) {
|
||||
return new CryptoMoney(currencyCode, LongMath.checkedMultiply(this.value, factor));
|
||||
}
|
||||
|
||||
public Altcoin divide(final long divisor) {
|
||||
return new Altcoin(currencyCode, this.value / divisor);
|
||||
public CryptoMoney divide(final long divisor) {
|
||||
return new CryptoMoney(currencyCode, this.value / divisor);
|
||||
}
|
||||
|
||||
public Altcoin[] divideAndRemainder(final long divisor) {
|
||||
return new Altcoin[]{new Altcoin(currencyCode, this.value / divisor), new Altcoin(currencyCode, this.value % divisor)};
|
||||
public CryptoMoney[] divideAndRemainder(final long divisor) {
|
||||
return new CryptoMoney[]{new CryptoMoney(currencyCode, this.value / divisor), new CryptoMoney(currencyCode, this.value % divisor)};
|
||||
}
|
||||
|
||||
public long divide(final Altcoin divisor) {
|
||||
public long divide(final CryptoMoney divisor) {
|
||||
checkArgument(divisor.currencyCode.equals(currencyCode));
|
||||
return this.value / divisor.value;
|
||||
}
|
||||
@ -148,7 +148,7 @@ public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
||||
* Returns true if the monetary value represented by this instance is greater than that of the given other Coin,
|
||||
* otherwise false.
|
||||
*/
|
||||
public boolean isGreaterThan(Altcoin other) {
|
||||
public boolean isGreaterThan(CryptoMoney other) {
|
||||
return compareTo(other) > 0;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
||||
* Returns true if the monetary value represented by this instance is less than that of the given other Coin,
|
||||
* otherwise false.
|
||||
*/
|
||||
public boolean isLessThan(Altcoin other) {
|
||||
public boolean isLessThan(CryptoMoney other) {
|
||||
return compareTo(other) < 0;
|
||||
}
|
||||
|
||||
@ -167,8 +167,8 @@ public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
||||
return this.value < 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
public Altcoin negate() {
|
||||
return new Altcoin(currencyCode, -this.value);
|
||||
public CryptoMoney negate() {
|
||||
return new CryptoMoney(currencyCode, -this.value);
|
||||
}
|
||||
|
||||
public String toFriendlyString() {
|
||||
@ -196,7 +196,7 @@ public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
||||
return true;
|
||||
if (o == null || o.getClass() != getClass())
|
||||
return false;
|
||||
final Altcoin other = (Altcoin) o;
|
||||
final CryptoMoney other = (CryptoMoney) o;
|
||||
return this.value == other.value && this.currencyCode.equals(other.currencyCode);
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull final Altcoin other) {
|
||||
public int compareTo(@NotNull final CryptoMoney other) {
|
||||
if (!this.currencyCode.equals(other.currencyCode))
|
||||
return this.currencyCode.compareTo(other.currencyCode);
|
||||
if (this.value != other.value)
|
@ -25,10 +25,10 @@ import org.slf4j.LoggerFactory;
|
||||
public abstract class MonetaryWrapper {
|
||||
private static final Logger log = LoggerFactory.getLogger(MonetaryWrapper.class);
|
||||
|
||||
/// Instance of Fiat or Altcoin
|
||||
/// Instance of TraditionalMoney or CryptoMoney
|
||||
protected final Monetary monetary;
|
||||
protected final MonetaryFormat fiatFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0);
|
||||
protected final MonetaryFormat altCoinFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0);
|
||||
protected final MonetaryFormat traditionalFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0);
|
||||
protected final MonetaryFormat cryptoFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0);
|
||||
|
||||
public MonetaryWrapper(Monetary monetary) {
|
||||
this.monetary = monetary;
|
||||
|
@ -21,8 +21,6 @@ import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.trade.HavenoUtils;
|
||||
import haveno.core.util.ParsingUtils;
|
||||
import org.bitcoinj.core.Monetary;
|
||||
import org.bitcoinj.utils.ExchangeRate;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -36,7 +34,7 @@ import java.math.BigInteger;
|
||||
* <br/>
|
||||
* We wrap an object implementing the {@link Monetary} interface from bitcoinj. We respect the
|
||||
* number of decimal digits of precision specified in the {@code smallestUnitExponent()}, defined in
|
||||
* those classes, like {@link Fiat} or {@link Altcoin}.
|
||||
* those classes, like {@link TraditionalMoney} or {@link CryptoMoney}.
|
||||
*/
|
||||
public class Price extends MonetaryWrapper implements Comparable<Price> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Price.class);
|
||||
@ -59,10 +57,10 @@ public class Price extends MonetaryWrapper implements Comparable<Price> {
|
||||
*/
|
||||
public static Price parse(String currencyCode, String input) {
|
||||
String cleaned = ParsingUtils.convertCharsForNumber(input);
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode))
|
||||
return new Price(Fiat.parseFiat(currencyCode, cleaned));
|
||||
if (CurrencyUtil.isTraditionalCurrency(currencyCode))
|
||||
return new Price(TraditionalMoney.parseTraditionalMoney(currencyCode, cleaned));
|
||||
else
|
||||
return new Price(Altcoin.parseAltcoin(currencyCode, cleaned));
|
||||
return new Price(CryptoMoney.parseCrypto(currencyCode, cleaned));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,34 +71,34 @@ public class Price extends MonetaryWrapper implements Comparable<Price> {
|
||||
* @return The parsed Price.
|
||||
*/
|
||||
public static Price valueOf(String currencyCode, long value) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
return new Price(Fiat.valueOf(currencyCode, value));
|
||||
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
|
||||
return new Price(TraditionalMoney.valueOf(currencyCode, value));
|
||||
} else {
|
||||
return new Price(Altcoin.valueOf(currencyCode, value));
|
||||
return new Price(CryptoMoney.valueOf(currencyCode, value));
|
||||
}
|
||||
}
|
||||
|
||||
public Volume getVolumeByAmount(BigInteger amount) {
|
||||
if (monetary instanceof Fiat)
|
||||
return new Volume(new ExchangeRate((Fiat) monetary).coinToFiat(HavenoUtils.atomicUnitsToCoin(amount)));
|
||||
else if (monetary instanceof Altcoin)
|
||||
return new Volume(new AltcoinExchangeRate((Altcoin) monetary).coinToAltcoin(HavenoUtils.atomicUnitsToCoin(amount)));
|
||||
if (monetary instanceof TraditionalMoney)
|
||||
return new Volume(new TraditionalExchangeRate((TraditionalMoney) monetary).coinToTraditionalMoney(HavenoUtils.atomicUnitsToCoin(amount)));
|
||||
else if (monetary instanceof CryptoMoney)
|
||||
return new Volume(new CryptoExchangeRate((CryptoMoney) monetary).coinToCrypto(HavenoUtils.atomicUnitsToCoin(amount)));
|
||||
else
|
||||
throw new IllegalStateException("Monetary must be either of type Fiat or Altcoin");
|
||||
throw new IllegalStateException("Monetary must be either of type TraditionalMoney or CryptoMoney");
|
||||
}
|
||||
|
||||
public BigInteger getAmountByVolume(Volume volume) {
|
||||
Monetary monetary = volume.getMonetary();
|
||||
if (monetary instanceof Fiat && this.monetary instanceof Fiat)
|
||||
return HavenoUtils.coinToAtomicUnits(new ExchangeRate((Fiat) this.monetary).fiatToCoin((Fiat) monetary));
|
||||
else if (monetary instanceof Altcoin && this.monetary instanceof Altcoin)
|
||||
return HavenoUtils.coinToAtomicUnits(new AltcoinExchangeRate((Altcoin) this.monetary).altcoinToCoin((Altcoin) monetary));
|
||||
if (monetary instanceof TraditionalMoney && this.monetary instanceof TraditionalMoney)
|
||||
return HavenoUtils.coinToAtomicUnits(new TraditionalExchangeRate((TraditionalMoney) this.monetary).traditionalMoneyToCoin((TraditionalMoney) monetary));
|
||||
else if (monetary instanceof CryptoMoney && this.monetary instanceof CryptoMoney)
|
||||
return HavenoUtils.coinToAtomicUnits(new CryptoExchangeRate((CryptoMoney) this.monetary).cryptoToCoin((CryptoMoney) monetary));
|
||||
else
|
||||
return BigInteger.valueOf(0);
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return monetary instanceof Altcoin ? ((Altcoin) monetary).getCurrencyCode() : ((Fiat) monetary).getCurrencyCode();
|
||||
return monetary instanceof CryptoMoney ? ((CryptoMoney) monetary).getCurrencyCode() : ((TraditionalMoney) monetary).getCurrencyCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -109,7 +107,7 @@ public class Price extends MonetaryWrapper implements Comparable<Price> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of whole coins or fiat units as double.
|
||||
* Get the amount of whole coins or units as double.
|
||||
*/
|
||||
public double getDoubleValue() {
|
||||
return BigDecimal.valueOf(monetary.getValue()).movePointLeft(monetary.smallestUnitExponent()).doubleValue();
|
||||
@ -125,25 +123,25 @@ public class Price extends MonetaryWrapper implements Comparable<Price> {
|
||||
}
|
||||
|
||||
public boolean isPositive() {
|
||||
return monetary instanceof Altcoin ? ((Altcoin) monetary).isPositive() : ((Fiat) monetary).isPositive();
|
||||
return monetary instanceof CryptoMoney ? ((CryptoMoney) monetary).isPositive() : ((TraditionalMoney) monetary).isPositive();
|
||||
}
|
||||
|
||||
public Price subtract(Price other) {
|
||||
if (monetary instanceof Altcoin) {
|
||||
return new Price(((Altcoin) monetary).subtract((Altcoin) other.monetary));
|
||||
if (monetary instanceof CryptoMoney) {
|
||||
return new Price(((CryptoMoney) monetary).subtract((CryptoMoney) other.monetary));
|
||||
} else {
|
||||
return new Price(((Fiat) monetary).subtract((Fiat) other.monetary));
|
||||
return new Price(((TraditionalMoney) monetary).subtract((TraditionalMoney) other.monetary));
|
||||
}
|
||||
}
|
||||
|
||||
public String toFriendlyString() {
|
||||
return monetary instanceof Altcoin ?
|
||||
((Altcoin) monetary).toFriendlyString() + "/XMR" :
|
||||
((Fiat) monetary).toFriendlyString().replace(((Fiat) monetary).currencyCode, "") + "XMR/" + ((Fiat) monetary).currencyCode;
|
||||
return monetary instanceof CryptoMoney ?
|
||||
((CryptoMoney) monetary).toFriendlyString() + "/XMR" :
|
||||
((TraditionalMoney) monetary).toFriendlyString().replace(((TraditionalMoney) monetary).currencyCode, "") + "XMR/" + ((TraditionalMoney) monetary).currencyCode;
|
||||
}
|
||||
|
||||
public String toPlainString() {
|
||||
return monetary instanceof Altcoin ? ((Altcoin) monetary).toPlainString() : ((Fiat) monetary).toPlainString();
|
||||
return monetary instanceof CryptoMoney ? ((CryptoMoney) monetary).toPlainString() : ((TraditionalMoney) monetary).toPlainString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* This file is part of Haveno.
|
||||
*
|
||||
* Haveno is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Haveno is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Haveno. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package haveno.core.monetary;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* An exchange rate is expressed as a ratio of a {@link Coin} and a traditional money amount.
|
||||
*/
|
||||
public class TraditionalExchangeRate implements Serializable {
|
||||
|
||||
public final Coin coin;
|
||||
public final TraditionalMoney traditionalMoney;
|
||||
|
||||
/** Construct exchange rate. This amount of coin is worth that amount of money. */
|
||||
public TraditionalExchangeRate(Coin coin, TraditionalMoney traditionalMoney) {
|
||||
checkArgument(coin.isPositive());
|
||||
checkArgument(traditionalMoney.isPositive());
|
||||
checkArgument(traditionalMoney.currencyCode != null, "currency code required");
|
||||
this.coin = coin;
|
||||
this.traditionalMoney = traditionalMoney;
|
||||
}
|
||||
|
||||
/** Construct exchange rate. One coin is worth this amount of traditional money. */
|
||||
public TraditionalExchangeRate(TraditionalMoney traditionalMoney) {
|
||||
this(Coin.COIN, traditionalMoney);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a coin amount to a traditional money amount using this exchange rate.
|
||||
* @throws ArithmeticException if the converted amount is too high or too low.
|
||||
*/
|
||||
public TraditionalMoney coinToTraditionalMoney(Coin convertCoin) {
|
||||
// Use BigInteger because it's much easier to maintain full precision without overflowing.
|
||||
final BigInteger converted = BigInteger.valueOf(convertCoin.value).multiply(BigInteger.valueOf(traditionalMoney.value))
|
||||
.divide(BigInteger.valueOf(coin.value));
|
||||
if (converted.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0
|
||||
|| converted.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0)
|
||||
throw new ArithmeticException("Overflow");
|
||||
return TraditionalMoney.valueOf(traditionalMoney.currencyCode, converted.longValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a traditional money amount to a coin amount using this exchange rate.
|
||||
* @throws ArithmeticException if the converted coin amount is too high or too low.
|
||||
*/
|
||||
public Coin traditionalMoneyToCoin(TraditionalMoney convertTraditionalMoney) {
|
||||
checkArgument(convertTraditionalMoney.currencyCode.equals(traditionalMoney.currencyCode), "Currency mismatch: %s vs %s",
|
||||
convertTraditionalMoney.currencyCode, traditionalMoney.currencyCode);
|
||||
// Use BigInteger because it's much easier to maintain full precision without overflowing.
|
||||
final BigInteger converted = BigInteger.valueOf(convertTraditionalMoney.value).multiply(BigInteger.valueOf(coin.value))
|
||||
.divide(BigInteger.valueOf(traditionalMoney.value));
|
||||
if (converted.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0
|
||||
|| converted.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0)
|
||||
throw new ArithmeticException("Overflow");
|
||||
try {
|
||||
return Coin.valueOf(converted.longValue());
|
||||
} catch (IllegalArgumentException x) {
|
||||
throw new ArithmeticException("Overflow: " + x.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
TraditionalExchangeRate other = (TraditionalExchangeRate) o;
|
||||
return Objects.equal(this.coin, other.coin) && Objects.equal(this.traditionalMoney, other.traditionalMoney);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(coin, traditionalMoney);
|
||||
}
|
||||
}
|
||||
|
243
core/src/main/java/haveno/core/monetary/TraditionalMoney.java
Normal file
243
core/src/main/java/haveno/core/monetary/TraditionalMoney.java
Normal file
@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Copyright 2014 Andreas Schildbach
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package haveno.core.monetary;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.Monetary;
|
||||
import org.bitcoinj.utils.MonetaryFormat;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.math.LongMath;
|
||||
import com.google.common.primitives.Longs;
|
||||
|
||||
/**
|
||||
* Represents a monetary value. It was decided to not fold this into
|
||||
* {@link Coin} because of type
|
||||
* safety. Traditional money values always come with an attached currency code.
|
||||
*
|
||||
* This class is immutable.
|
||||
*/
|
||||
public final class TraditionalMoney implements Monetary, Comparable<TraditionalMoney>, Serializable {
|
||||
|
||||
/**
|
||||
* The absolute value of exponent of the value of a "smallest unit" in
|
||||
* scientific notation. We picked 8 rather than
|
||||
* 2, because in financial applications it's common to use sub-cent precision.
|
||||
*/
|
||||
public static final int SMALLEST_UNIT_EXPONENT = 8;
|
||||
|
||||
/**
|
||||
* The number of smallest units of this monetary value.
|
||||
*/
|
||||
public final long value;
|
||||
public final String currencyCode;
|
||||
|
||||
private TraditionalMoney(final String currencyCode, final long value) {
|
||||
this.value = value;
|
||||
this.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
public static TraditionalMoney valueOf(final String currencyCode, final long value) {
|
||||
return new TraditionalMoney(currencyCode, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int smallestUnitExponent() {
|
||||
return SMALLEST_UNIT_EXPONENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of "smallest units" of this monetary value.
|
||||
*/
|
||||
@Override
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return currencyCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Parses an amount expressed in the way humans are used to.</p>
|
||||
* <p>This takes string in a format understood by {@link BigDecimal#BigDecimal(String)}, for example "0", "1", "0.10",
|
||||
* "1.23E3", "1234.5E-5".</p>
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if you try to specify more than 8 digits after the comma, or a value out of range.
|
||||
*/
|
||||
public static TraditionalMoney parseTraditionalMoney(final String currencyCode, final String str) {
|
||||
try {
|
||||
long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValueExact();
|
||||
return TraditionalMoney.valueOf(currencyCode, val);
|
||||
} catch (ArithmeticException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Parses an amount expressed in the way humans are used to. The amount is cut to 8 digits after the comma.</p>
|
||||
* <p>This takes string in a format understood by {@link BigDecimal#BigDecimal(String)}, for example "0", "1", "0.10",
|
||||
* "1.23E3", "1234.5E-5".</p>
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if you try to specify a value out of range.
|
||||
*/
|
||||
public static TraditionalMoney parseTraditionalMoneyInexact(final String currencyCode, final String str) {
|
||||
try {
|
||||
long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValue();
|
||||
return TraditionalMoney.valueOf(currencyCode, val);
|
||||
} catch (ArithmeticException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public TraditionalMoney add(final TraditionalMoney value) {
|
||||
checkArgument(value.currencyCode.equals(currencyCode));
|
||||
return new TraditionalMoney(currencyCode, LongMath.checkedAdd(this.value, value.value));
|
||||
}
|
||||
|
||||
public TraditionalMoney subtract(final TraditionalMoney value) {
|
||||
checkArgument(value.currencyCode.equals(currencyCode));
|
||||
return new TraditionalMoney(currencyCode, LongMath.checkedSubtract(this.value, value.value));
|
||||
}
|
||||
|
||||
public TraditionalMoney multiply(final long factor) {
|
||||
return new TraditionalMoney(currencyCode, LongMath.checkedMultiply(this.value, factor));
|
||||
}
|
||||
|
||||
public TraditionalMoney divide(final long divisor) {
|
||||
return new TraditionalMoney(currencyCode, this.value / divisor);
|
||||
}
|
||||
|
||||
public TraditionalMoney[] divideAndRemainder(final long divisor) {
|
||||
return new TraditionalMoney[] { new TraditionalMoney(currencyCode, this.value / divisor), new TraditionalMoney(currencyCode, this.value % divisor) };
|
||||
}
|
||||
|
||||
public long divide(final TraditionalMoney divisor) {
|
||||
checkArgument(divisor.currencyCode.equals(currencyCode));
|
||||
return this.value / divisor.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if this instance represents a monetary value greater than zero, otherwise false.
|
||||
*/
|
||||
public boolean isPositive() {
|
||||
return signum() == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if this instance represents a monetary value less than zero, otherwise false.
|
||||
*/
|
||||
public boolean isNegative() {
|
||||
return signum() == -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if this instance represents zero monetary value, otherwise false.
|
||||
*/
|
||||
public boolean isZero() {
|
||||
return signum() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the monetary value represented by this instance is greater than that of the given other TraditionalMoney,
|
||||
* otherwise false.
|
||||
*/
|
||||
public boolean isGreaterThan(TraditionalMoney other) {
|
||||
return compareTo(other) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the monetary value represented by this instance is less than that of the given other TraditionalMoney,
|
||||
* otherwise false.
|
||||
*/
|
||||
public boolean isLessThan(TraditionalMoney other) {
|
||||
return compareTo(other) < 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int signum() {
|
||||
if (this.value == 0)
|
||||
return 0;
|
||||
return this.value < 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
public TraditionalMoney negate() {
|
||||
return new TraditionalMoney(currencyCode, -this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of "smallest units" of this monetary value. It's deprecated in favour of accessing {@link #value}
|
||||
* directly.
|
||||
*/
|
||||
public long longValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
private static final MonetaryFormat FRIENDLY_FORMAT = MonetaryFormat.FIAT.postfixCode();
|
||||
|
||||
/**
|
||||
* Returns the value as a 0.12 type string. More digits after the decimal place will be used if necessary, but two
|
||||
* will always be present.
|
||||
*/
|
||||
public String toFriendlyString() {
|
||||
return FRIENDLY_FORMAT.code(0, currencyCode).format(this).toString();
|
||||
}
|
||||
|
||||
private static final MonetaryFormat PLAIN_FORMAT = MonetaryFormat.FIAT.minDecimals(0).repeatOptionalDecimals(1, 8).noCode();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the value as a plain string. The result is unformatted with no trailing zeroes. For
|
||||
* instance, a value of 150000 "smallest units" gives an output string of "0.0015".
|
||||
* </p>
|
||||
*/
|
||||
public String toPlainString() {
|
||||
return PLAIN_FORMAT.format(this).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Long.toString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
if (o == null || o.getClass() != getClass()) return false;
|
||||
final TraditionalMoney other = (TraditionalMoney) o;
|
||||
return this.value == other.value && this.currencyCode.equals(other.currencyCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(value, currencyCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final TraditionalMoney other) {
|
||||
if (!this.currencyCode.equals(other.currencyCode))
|
||||
return this.currencyCode.compareTo(other.currencyCode);
|
||||
return Longs.compare(this.value, other.value);
|
||||
}
|
||||
}
|
@ -20,7 +20,6 @@ package haveno.core.monetary;
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.util.ParsingUtils;
|
||||
import org.bitcoinj.core.Monetary;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -34,10 +33,10 @@ public class Volume extends MonetaryWrapper implements Comparable<Volume> {
|
||||
|
||||
public static Volume parse(String input, String currencyCode) {
|
||||
String cleaned = ParsingUtils.convertCharsForNumber(input);
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode))
|
||||
return new Volume(Fiat.parseFiat(currencyCode, cleaned));
|
||||
if (CurrencyUtil.isTraditionalCurrency(currencyCode))
|
||||
return new Volume(TraditionalMoney.parseTraditionalMoney(currencyCode, cleaned));
|
||||
else
|
||||
return new Volume(Altcoin.parseAltcoin(currencyCode, cleaned));
|
||||
return new Volume(CryptoMoney.parseCrypto(currencyCode, cleaned));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,11 +49,11 @@ public class Volume extends MonetaryWrapper implements Comparable<Volume> {
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return monetary instanceof Altcoin ? ((Altcoin) monetary).getCurrencyCode() : ((Fiat) monetary).getCurrencyCode();
|
||||
return monetary instanceof CryptoMoney ? ((CryptoMoney) monetary).getCurrencyCode() : ((TraditionalMoney) monetary).getCurrencyCode();
|
||||
}
|
||||
|
||||
public String toPlainString() {
|
||||
return monetary instanceof Altcoin ? ((Altcoin) monetary).toPlainString() : ((Fiat) monetary).toPlainString();
|
||||
return monetary instanceof CryptoMoney ? ((CryptoMoney) monetary).toPlainString() : ((TraditionalMoney) monetary).toPlainString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,8 +21,9 @@ import haveno.common.crypto.KeyRing;
|
||||
import haveno.common.util.MathUtils;
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.monetary.Altcoin;
|
||||
import haveno.core.monetary.CryptoMoney;
|
||||
import haveno.core.monetary.Price;
|
||||
import haveno.core.monetary.TraditionalMoney;
|
||||
import haveno.core.notifications.MobileMessage;
|
||||
import haveno.core.notifications.MobileMessageType;
|
||||
import haveno.core.notifications.MobileNotificationService;
|
||||
@ -34,7 +35,6 @@ import haveno.core.provider.price.PriceFeedService;
|
||||
import haveno.core.user.User;
|
||||
import haveno.core.util.FormattingUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -103,7 +103,7 @@ public class MarketAlerts {
|
||||
|
||||
// We combine the offer ID and the price (either as % price or as fixed price) to get also updates for edited offers
|
||||
// % price get multiplied by 10000 to have 0.12% be converted to 12. For fixed price we have precision of 8 for
|
||||
// altcoins and precision of 4 for fiat.
|
||||
// crypto and traditional.
|
||||
private String getAlertId(Offer offer) {
|
||||
double price = offer.isUseMarketBasedPrice() ? offer.getMarketPriceMarginPct() * 10000 : offer.getOfferPayload().getPrice();
|
||||
String priceString = String.valueOf((long) price);
|
||||
@ -117,7 +117,7 @@ public class MarketAlerts {
|
||||
if (marketPrice != null && offerPrice != null) {
|
||||
boolean isSellOffer = offer.getDirection() == OfferDirection.SELL;
|
||||
String shortOfferId = offer.getShortId();
|
||||
boolean isFiatCurrency = CurrencyUtil.isFiatCurrency(currencyCode);
|
||||
boolean isTraditionalCurrency = CurrencyUtil.isTraditionalCurrency(currencyCode);
|
||||
String alertId = getAlertId(offer);
|
||||
user.getMarketAlertFilters().stream()
|
||||
.filter(marketAlertFilter -> !offer.isMyOffer(keyRing))
|
||||
@ -127,16 +127,16 @@ public class MarketAlerts {
|
||||
int triggerValue = marketAlertFilter.getTriggerValue();
|
||||
boolean isTriggerForBuyOffer = marketAlertFilter.isBuyOffer();
|
||||
double marketPriceAsDouble1 = marketPrice.getPrice();
|
||||
int precision = CurrencyUtil.isCryptoCurrency(currencyCode) ?
|
||||
Altcoin.SMALLEST_UNIT_EXPONENT :
|
||||
Fiat.SMALLEST_UNIT_EXPONENT;
|
||||
int precision = CurrencyUtil.isTraditionalCurrency(currencyCode) ?
|
||||
TraditionalMoney.SMALLEST_UNIT_EXPONENT :
|
||||
CryptoMoney.SMALLEST_UNIT_EXPONENT;
|
||||
double marketPriceAsDouble = MathUtils.scaleUpByPowerOf10(marketPriceAsDouble1, precision);
|
||||
double offerPriceValue = offerPrice.getValue();
|
||||
double ratio = offerPriceValue / marketPriceAsDouble;
|
||||
ratio = 1 - ratio;
|
||||
if (isFiatCurrency && isSellOffer)
|
||||
if (isTraditionalCurrency && isSellOffer)
|
||||
ratio *= -1;
|
||||
else if (!isFiatCurrency && !isSellOffer)
|
||||
else if (!isTraditionalCurrency && !isSellOffer)
|
||||
ratio *= -1;
|
||||
|
||||
ratio = ratio * 10000;
|
||||
@ -149,7 +149,7 @@ public class MarketAlerts {
|
||||
if (isTriggerForBuyOfferAndTriggered || isTriggerForSellOfferAndTriggered) {
|
||||
String direction = isSellOffer ? Res.get("shared.sell") : Res.get("shared.buy");
|
||||
String marketDir;
|
||||
if (isFiatCurrency) {
|
||||
if (isTraditionalCurrency) {
|
||||
if (isSellOffer) {
|
||||
marketDir = ratio > 0 ?
|
||||
Res.get("account.notifications.marketAlert.message.msg.above") :
|
||||
|
@ -20,7 +20,8 @@ package haveno.core.notifications.alerts.price;
|
||||
import haveno.common.util.MathUtils;
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.monetary.Altcoin;
|
||||
import haveno.core.monetary.CryptoMoney;
|
||||
import haveno.core.monetary.TraditionalMoney;
|
||||
import haveno.core.notifications.MobileMessage;
|
||||
import haveno.core.notifications.MobileMessageType;
|
||||
import haveno.core.notifications.MobileNotificationService;
|
||||
@ -29,7 +30,6 @@ import haveno.core.provider.price.PriceFeedService;
|
||||
import haveno.core.user.User;
|
||||
import haveno.core.util.FormattingUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -58,7 +58,7 @@ public class PriceAlert {
|
||||
String currencyCode = filter.getCurrencyCode();
|
||||
MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode);
|
||||
if (marketPrice != null) {
|
||||
int exp = CurrencyUtil.isCryptoCurrency(currencyCode) ? Altcoin.SMALLEST_UNIT_EXPONENT : Fiat.SMALLEST_UNIT_EXPONENT;
|
||||
int exp = CurrencyUtil.isTraditionalCurrency(currencyCode) ? TraditionalMoney.SMALLEST_UNIT_EXPONENT : CryptoMoney.SMALLEST_UNIT_EXPONENT;
|
||||
double priceAsDouble = marketPrice.getPrice();
|
||||
long priceAsLong = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(priceAsDouble, exp));
|
||||
String currencyName = CurrencyUtil.getNameByCode(currencyCode);
|
||||
|
@ -28,8 +28,9 @@ import haveno.common.util.MathUtils;
|
||||
import haveno.common.util.Utilities;
|
||||
import haveno.core.exceptions.TradePriceOutOfToleranceException;
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.monetary.Altcoin;
|
||||
import haveno.core.monetary.CryptoMoney;
|
||||
import haveno.core.monetary.Price;
|
||||
import haveno.core.monetary.TraditionalMoney;
|
||||
import haveno.core.monetary.Volume;
|
||||
import haveno.core.offer.availability.OfferAvailabilityModel;
|
||||
import haveno.core.offer.availability.OfferAvailabilityProtocol;
|
||||
@ -46,7 +47,6 @@ import javafx.beans.property.StringProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigInteger;
|
||||
@ -182,9 +182,9 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
||||
double marketPriceAsDouble = marketPrice.getPrice();
|
||||
double targetPriceAsDouble = marketPriceAsDouble * factor;
|
||||
try {
|
||||
int precision = CurrencyUtil.isCryptoCurrency(currencyCode) ?
|
||||
Altcoin.SMALLEST_UNIT_EXPONENT :
|
||||
Fiat.SMALLEST_UNIT_EXPONENT;
|
||||
int precision = CurrencyUtil.isTraditionalCurrency(currencyCode) ?
|
||||
TraditionalMoney.SMALLEST_UNIT_EXPONENT :
|
||||
CryptoMoney.SMALLEST_UNIT_EXPONENT;
|
||||
double scaled = MathUtils.scaleUpByPowerOf10(targetPriceAsDouble, precision);
|
||||
final long roundedToLong = MathUtils.roundDoubleToLong(scaled);
|
||||
return Price.valueOf(currencyCode, roundedToLong);
|
||||
@ -528,6 +528,10 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
||||
return getCurrencyCode().equals("XMR");
|
||||
}
|
||||
|
||||
public boolean isTraditionalOffer() {
|
||||
return CurrencyUtil.isTraditionalCurrency(currencyCode);
|
||||
}
|
||||
|
||||
public boolean isFiatOffer() {
|
||||
return CurrencyUtil.isFiatCurrency(currencyCode);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ public class OfferFilterService {
|
||||
return insufficientCounterpartyTradeLimitCache.get(offerId);
|
||||
}
|
||||
|
||||
boolean result = offer.isFiatOffer() &&
|
||||
boolean result = offer.isTraditionalOffer() &&
|
||||
!accountAgeWitnessService.verifyPeersTradeAmount(offer, offer.getAmount(),
|
||||
errorMessage -> {
|
||||
});
|
||||
@ -215,7 +215,7 @@ public class OfferFilterService {
|
||||
accountOptional.isPresent() ? accountOptional.get().getAccountName() : "null",
|
||||
Coin.valueOf(myTradeLimit).toFriendlyString(),
|
||||
Coin.valueOf(offerMinAmount).toFriendlyString());
|
||||
boolean result = offer.isFiatOffer() &&
|
||||
boolean result = offer.isTraditionalOffer() &&
|
||||
accountOptional.isPresent() &&
|
||||
myTradeLimit < offerMinAmount;
|
||||
myInsufficientTradeLimitCache.put(offerId, result);
|
||||
|
@ -18,9 +18,9 @@
|
||||
package haveno.core.offer;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import haveno.common.util.MathUtils;
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.monetary.CryptoMoney;
|
||||
import haveno.core.monetary.Price;
|
||||
import haveno.core.monetary.Volume;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -64,9 +64,9 @@ public class OfferForJson {
|
||||
public long primaryMarketMinVolume;
|
||||
|
||||
@JsonIgnore
|
||||
transient private final MonetaryFormat fiatFormat = new MonetaryFormat().shift(0).minDecimals(4).repeatOptionalDecimals(0, 0);
|
||||
transient private final MonetaryFormat traditionalFormat = new MonetaryFormat().shift(0).minDecimals(4).repeatOptionalDecimals(0, 0);
|
||||
@JsonIgnore
|
||||
transient private final MonetaryFormat altcoinFormat = new MonetaryFormat().shift(0).minDecimals(8).repeatOptionalDecimals(0, 0);
|
||||
transient private final MonetaryFormat cryptoFormat = new MonetaryFormat().shift(0).minDecimals(CryptoMoney.SMALLEST_UNIT_EXPONENT).repeatOptionalDecimals(0, 0);
|
||||
@JsonIgnore
|
||||
transient private final MonetaryFormat coinFormat = MonetaryFormat.BTC;
|
||||
|
||||
@ -99,43 +99,34 @@ public class OfferForJson {
|
||||
private void setDisplayStrings() {
|
||||
try {
|
||||
final Price price = getPrice();
|
||||
|
||||
if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
|
||||
primaryMarketDirection = direction == OfferDirection.BUY ? OfferDirection.SELL : OfferDirection.BUY;
|
||||
currencyPair = currencyCode + "/" + Res.getBaseCurrencyCode();
|
||||
} else {
|
||||
primaryMarketDirection = direction;
|
||||
currencyPair = Res.getBaseCurrencyCode() + "/" + currencyCode;
|
||||
}
|
||||
|
||||
// int precision = 8;
|
||||
//decimalFormat.setMaximumFractionDigits(precision);
|
||||
|
||||
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
|
||||
priceDisplayString = traditionalFormat.noCode().format(price.getMonetary()).toString();
|
||||
primaryMarketMinAmountDisplayString = HavenoUtils.formatXmr(getMinAmount()).toString();
|
||||
primaryMarketAmountDisplayString = HavenoUtils.formatXmr(getAmount()).toString();
|
||||
primaryMarketMinVolumeDisplayString = traditionalFormat.noCode().format(getMinVolume().getMonetary()).toString();
|
||||
primaryMarketVolumeDisplayString = traditionalFormat.noCode().format(getVolume().getMonetary()).toString();
|
||||
} else {
|
||||
// amount and volume is inverted for json
|
||||
priceDisplayString = altcoinFormat.noCode().format(price.getMonetary()).toString();
|
||||
primaryMarketMinAmountDisplayString = altcoinFormat.noCode().format(getMinVolume().getMonetary()).toString();
|
||||
primaryMarketAmountDisplayString = altcoinFormat.noCode().format(getVolume().getMonetary()).toString();
|
||||
priceDisplayString = cryptoFormat.noCode().format(price.getMonetary()).toString();
|
||||
primaryMarketMinAmountDisplayString = cryptoFormat.noCode().format(getMinVolume().getMonetary()).toString();
|
||||
primaryMarketAmountDisplayString = cryptoFormat.noCode().format(getVolume().getMonetary()).toString();
|
||||
primaryMarketMinVolumeDisplayString = HavenoUtils.formatXmr(getMinAmount()).toString();
|
||||
primaryMarketVolumeDisplayString = HavenoUtils.formatXmr(getAmount()).toString();
|
||||
|
||||
}
|
||||
primaryMarketPrice = price.getValue();
|
||||
primaryMarketMinAmount = getMinVolume().getValue();
|
||||
primaryMarketAmount = getVolume().getValue();
|
||||
primaryMarketMinVolume = getMinAmount().longValueExact();
|
||||
primaryMarketVolume = getAmount().longValueExact();
|
||||
} else {
|
||||
primaryMarketDirection = direction;
|
||||
currencyPair = Res.getBaseCurrencyCode() + "/" + currencyCode;
|
||||
|
||||
priceDisplayString = fiatFormat.noCode().format(price.getMonetary()).toString();
|
||||
primaryMarketMinAmountDisplayString = HavenoUtils.formatXmr(getMinAmount()).toString();
|
||||
primaryMarketAmountDisplayString = HavenoUtils.formatXmr(getAmount()).toString();
|
||||
primaryMarketMinVolumeDisplayString = fiatFormat.noCode().format(getMinVolume().getMonetary()).toString();
|
||||
primaryMarketVolumeDisplayString = fiatFormat.noCode().format(getVolume().getMonetary()).toString();
|
||||
|
||||
// we use precision 4 for fiat based price but on the markets api we use precision 8 so we scale up by 10000
|
||||
primaryMarketPrice = (long) MathUtils.scaleUpByPowerOf10(price.getValue(), 4);
|
||||
primaryMarketMinVolume = (long) MathUtils.scaleUpByPowerOf10(getMinVolume().getValue(), 4);
|
||||
primaryMarketVolume = (long) MathUtils.scaleUpByPowerOf10(getVolume().getValue(), 4);
|
||||
|
||||
primaryMarketMinAmount = getMinAmount().longValueExact();
|
||||
primaryMarketAmount = getAmount().longValueExact();
|
||||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
log.error("Error at setDisplayStrings: " + t.getMessage());
|
||||
|
@ -56,8 +56,8 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
||||
|
||||
protected final String id;
|
||||
protected final long date;
|
||||
// For fiat offer the baseCurrencyCode is BTC and the counterCurrencyCode is the fiat currency
|
||||
// For altcoin offers it is the opposite. baseCurrencyCode is the altcoin and the counterCurrencyCode is BTC.
|
||||
// For traditional offer the baseCurrencyCode is XMR and the counterCurrencyCode is the traditional currency
|
||||
// For crypto offers it is the opposite. baseCurrencyCode is the crypto and the counterCurrencyCode is XMR.
|
||||
protected final String baseCurrencyCode;
|
||||
protected final String counterCurrencyCode;
|
||||
// price if fixed price is used (usePercentageBasedPrice = false), otherwise 0
|
||||
@ -89,7 +89,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
||||
protected List<String> reserveTxKeyImages;
|
||||
|
||||
// Keys for extra map
|
||||
// Only set for fiat offers
|
||||
// Only set for traditional offers
|
||||
public static final String ACCOUNT_AGE_WITNESS_HASH = "accountAgeWitnessHash";
|
||||
public static final String REFERRAL_ID = "referralId";
|
||||
// Only used in payment method F2F
|
||||
@ -255,7 +255,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
||||
|
||||
// In the offer we support base and counter currency
|
||||
// Fiat offers have base currency XMR and counterCurrency Fiat
|
||||
// Altcoins have base currency Altcoin and counterCurrency XMR
|
||||
// Cryptos have base currency Crypto and counterCurrency XMR
|
||||
// The rest of the app does not support yet that concept of base currency and counter currencies
|
||||
// so we map here for convenience
|
||||
public String getCurrencyCode() {
|
||||
|
@ -26,6 +26,7 @@ import haveno.core.filter.FilterManager;
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.monetary.Price;
|
||||
import haveno.core.monetary.TraditionalMoney;
|
||||
import haveno.core.monetary.Volume;
|
||||
import haveno.core.payment.CashByMailAccount;
|
||||
import haveno.core.payment.F2FAccount;
|
||||
@ -42,7 +43,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionInput;
|
||||
import org.bitcoinj.core.TransactionOutput;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -169,7 +169,7 @@ public class OfferUtil {
|
||||
CoinFormatter formatter) {
|
||||
String userCurrencyCode = preferences.getPreferredTradeCurrency().getCode();
|
||||
if (CurrencyUtil.isCryptoCurrency(userCurrencyCode)) {
|
||||
// In case the user has selected a altcoin as preferredTradeCurrency
|
||||
// In case the user has selected a crypto as preferredTradeCurrency
|
||||
// we derive the fiat currency from the user country
|
||||
String countryCode = preferences.getUserCountry().code;
|
||||
userCurrencyCode = CurrencyUtil.getCurrencyByCountryCode(countryCode).getCode();
|
||||
@ -184,7 +184,7 @@ public class OfferUtil {
|
||||
String currencyCode,
|
||||
OfferDirection direction) {
|
||||
Map<String, String> extraDataMap = new HashMap<>();
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
|
||||
String myWitnessHashAsHex = accountAgeWitnessService
|
||||
.getMyWitnessHashAsHex(paymentAccount.getPaymentAccountPayload());
|
||||
extraDataMap.put(ACCOUNT_AGE_WITNESS_HASH, myWitnessHashAsHex);
|
||||
@ -236,7 +236,7 @@ public class OfferUtil {
|
||||
private Optional<Volume> getFeeInUserFiatCurrency(BigInteger makerFee, String userCurrencyCode, CoinFormatter formatter) {
|
||||
MarketPrice marketPrice = priceFeedService.getMarketPrice(userCurrencyCode);
|
||||
if (marketPrice != null && makerFee != null) {
|
||||
long marketPriceAsLong = roundDoubleToLong(scaleUpByPowerOf10(marketPrice.getPrice(), Fiat.SMALLEST_UNIT_EXPONENT));
|
||||
long marketPriceAsLong = roundDoubleToLong(scaleUpByPowerOf10(marketPrice.getPrice(), TraditionalMoney.SMALLEST_UNIT_EXPONENT));
|
||||
Price userCurrencyPrice = Price.valueOf(userCurrencyCode, marketPriceAsLong);
|
||||
return Optional.of(userCurrencyPrice.getVolumeByAmount(makerFee));
|
||||
} else {
|
||||
@ -244,11 +244,11 @@ public class OfferUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFiatOffer(Offer offer) {
|
||||
public static boolean isTraditionalOffer(Offer offer) {
|
||||
return offer.getBaseCurrencyCode().equals("XMR");
|
||||
}
|
||||
|
||||
public static boolean isAltcoinOffer(Offer offer) {
|
||||
public static boolean isCryptoOffer(Offer offer) {
|
||||
return offer.getCounterCurrencyCode().equals("XMR");
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,9 @@ package haveno.core.offer;
|
||||
|
||||
import haveno.common.util.MathUtils;
|
||||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.monetary.Altcoin;
|
||||
import haveno.core.monetary.CryptoMoney;
|
||||
import haveno.core.monetary.Price;
|
||||
import haveno.core.monetary.TraditionalMoney;
|
||||
import haveno.core.provider.mempool.MempoolService;
|
||||
import haveno.core.provider.price.MarketPrice;
|
||||
import haveno.core.provider.price.PriceFeedService;
|
||||
@ -28,7 +29,6 @@ import haveno.network.p2p.BootstrapListener;
|
||||
import haveno.network.p2p.P2PService;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -110,10 +110,10 @@ public class TriggerPriceService {
|
||||
}
|
||||
|
||||
String currencyCode = openOffer.getOffer().getCurrencyCode();
|
||||
boolean cryptoCurrency = CurrencyUtil.isCryptoCurrency(currencyCode);
|
||||
int smallestUnitExponent = cryptoCurrency ?
|
||||
Altcoin.SMALLEST_UNIT_EXPONENT :
|
||||
Fiat.SMALLEST_UNIT_EXPONENT;
|
||||
boolean traditionalCurrency = CurrencyUtil.isTraditionalCurrency(currencyCode);
|
||||
int smallestUnitExponent = traditionalCurrency ?
|
||||
TraditionalMoney.SMALLEST_UNIT_EXPONENT :
|
||||
CryptoMoney.SMALLEST_UNIT_EXPONENT;
|
||||
long marketPriceAsLong = roundDoubleToLong(
|
||||
scaleUpByPowerOf10(marketPrice.getPrice(), smallestUnitExponent));
|
||||
long triggerPrice = openOffer.getTriggerPrice();
|
||||
@ -123,6 +123,7 @@ public class TriggerPriceService {
|
||||
|
||||
OfferDirection direction = openOffer.getOffer().getDirection();
|
||||
boolean isSellOffer = direction == OfferDirection.SELL;
|
||||
boolean cryptoCurrency = CurrencyUtil.isCryptoCurrency(currencyCode);
|
||||
boolean condition = isSellOffer && !cryptoCurrency || !isSellOffer && cryptoCurrency;
|
||||
return condition ?
|
||||
marketPriceAsLong < triggerPrice :
|
||||
@ -132,9 +133,9 @@ public class TriggerPriceService {
|
||||
private void checkPriceThreshold(MarketPrice marketPrice, OpenOffer openOffer) {
|
||||
if (wasTriggered(marketPrice, openOffer)) {
|
||||
String currencyCode = openOffer.getOffer().getCurrencyCode();
|
||||
int smallestUnitExponent = CurrencyUtil.isCryptoCurrency(currencyCode) ?
|
||||
Altcoin.SMALLEST_UNIT_EXPONENT :
|
||||
Fiat.SMALLEST_UNIT_EXPONENT;
|
||||
int smallestUnitExponent = CurrencyUtil.isTraditionalCurrency(currencyCode) ?
|
||||
TraditionalMoney.SMALLEST_UNIT_EXPONENT :
|
||||
CryptoMoney.SMALLEST_UNIT_EXPONENT;
|
||||
long triggerPrice = openOffer.getTriggerPrice();
|
||||
|
||||
log.info("Market price exceeded the trigger price of the open offer.\n" +
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.AchTransferAccountPayload;
|
||||
import haveno.core.payment.payload.BankAccountPayload;
|
||||
@ -32,7 +32,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class AchTransferAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
public AchTransferAccount() {
|
||||
super(PaymentMethod.ACH_TRANSFER);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.AdvancedCashAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -32,13 +32,13 @@ import java.util.List;
|
||||
public final class AdvancedCashAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("BRL"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("KZT"),
|
||||
new FiatCurrency("RUB"),
|
||||
new FiatCurrency("UAH"),
|
||||
new FiatCurrency("USD"));
|
||||
new TraditionalCurrency("BRL"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("KZT"),
|
||||
new TraditionalCurrency("RUB"),
|
||||
new TraditionalCurrency("UAH"),
|
||||
new TraditionalCurrency("USD"));
|
||||
|
||||
public AdvancedCashAccount() {
|
||||
super(PaymentMethod.ADVANCED_CASH);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.AliPayAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class AliPayAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("CNY"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("CNY"));
|
||||
|
||||
public AliPayAccount() {
|
||||
super(PaymentMethod.ALI_PAY);
|
||||
|
@ -20,7 +20,7 @@ package haveno.core.payment;
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.Country;
|
||||
import haveno.core.locale.CountryUtil;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.AmazonGiftCardAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -33,17 +33,17 @@ import java.util.List;
|
||||
public final class AmazonGiftCardAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("AUD"),
|
||||
new FiatCurrency("CAD"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("INR"),
|
||||
new FiatCurrency("JPY"),
|
||||
new FiatCurrency("SAR"),
|
||||
new FiatCurrency("SEK"),
|
||||
new FiatCurrency("SGD"),
|
||||
new FiatCurrency("TRY"),
|
||||
new FiatCurrency("USD")
|
||||
new TraditionalCurrency("AUD"),
|
||||
new TraditionalCurrency("CAD"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("INR"),
|
||||
new TraditionalCurrency("JPY"),
|
||||
new TraditionalCurrency("SAR"),
|
||||
new TraditionalCurrency("SEK"),
|
||||
new TraditionalCurrency("SGD"),
|
||||
new TraditionalCurrency("TRY"),
|
||||
new TraditionalCurrency("USD")
|
||||
);
|
||||
|
||||
@Nullable
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.AustraliaPayidAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -29,7 +29,7 @@ import java.util.List;
|
||||
|
||||
public final class AustraliaPayidAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("AUD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("AUD"));
|
||||
|
||||
public AustraliaPayidAccount() {
|
||||
super(PaymentMethod.AUSTRALIA_PAYID);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.BizumAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class BizumAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("EUR"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("EUR"));
|
||||
|
||||
public BizumAccount() {
|
||||
super(PaymentMethod.BIZUM);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.CapitualAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -32,10 +32,10 @@ import java.util.List;
|
||||
public final class CapitualAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("BRL"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("USD")
|
||||
new TraditionalCurrency("BRL"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("USD")
|
||||
);
|
||||
|
||||
public CapitualAccount() {
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.CashAppAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -34,7 +34,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class CashAppAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
public CashAppAccount() {
|
||||
super(PaymentMethod.CASH_APP);
|
||||
|
@ -29,7 +29,7 @@ import java.util.List;
|
||||
|
||||
public final class CashByMailAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
|
||||
|
||||
public CashByMailAccount() {
|
||||
super(PaymentMethod.CASH_BY_MAIL);
|
||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||
|
||||
public final class CashDepositAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
|
||||
|
||||
public CashDepositAccount() {
|
||||
super(PaymentMethod.CASH_DEPOSIT);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.CelPayAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -33,11 +33,11 @@ public final class CelPayAccount extends PaymentAccount {
|
||||
|
||||
// https://github.com/bisq-network/growth/issues/231
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("AUD"),
|
||||
new FiatCurrency("CAD"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("HKD"),
|
||||
new FiatCurrency("USD")
|
||||
new TraditionalCurrency("AUD"),
|
||||
new TraditionalCurrency("CAD"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("HKD"),
|
||||
new TraditionalCurrency("USD")
|
||||
);
|
||||
|
||||
public CelPayAccount() {
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.ChaseQuickPayAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -34,7 +34,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class ChaseQuickPayAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
public ChaseQuickPayAccount() {
|
||||
super(PaymentMethod.CHASE_QUICK_PAY);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.BankAccountPayload;
|
||||
import haveno.core.payment.payload.DomesticWireTransferAccountPayload;
|
||||
@ -32,7 +32,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class DomesticWireTransferAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
public DomesticWireTransferAccount() {
|
||||
super(PaymentMethod.DOMESTIC_WIRE_TRANSFER);
|
||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class F2FAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.FasterPaymentsAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -39,7 +39,7 @@ public final class FasterPaymentsAccount extends PaymentAccount {
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("GBP"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("GBP"));
|
||||
|
||||
public FasterPaymentsAccount() {
|
||||
super(PaymentMethod.FASTER_PAYMENTS);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.HalCashAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class HalCashAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("EUR"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("EUR"));
|
||||
|
||||
public HalCashAccount() {
|
||||
super(PaymentMethod.HAL_CASH);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
import lombok.NonNull;
|
||||
@ -27,7 +27,7 @@ import java.util.List;
|
||||
|
||||
abstract public class IfscBasedAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("INR"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("INR"));
|
||||
|
||||
protected IfscBasedAccount(PaymentMethod paymentMethod) {
|
||||
super(paymentMethod);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.ImpsAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class ImpsAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("INR"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("INR"));
|
||||
|
||||
public ImpsAccount() {
|
||||
super(PaymentMethod.IMPS);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.InteracETransferAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class InteracETransferAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("CAD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("CAD"));
|
||||
|
||||
public InteracETransferAccount() {
|
||||
super(PaymentMethod.INTERAC_E_TRANSFER);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.JapanBankAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -29,7 +29,7 @@ import java.util.List;
|
||||
|
||||
public final class JapanBankAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("JPY"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("JPY"));
|
||||
|
||||
public JapanBankAccount() {
|
||||
super(PaymentMethod.JAPAN_BANK);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.MoneseAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -33,9 +33,9 @@ public final class MoneseAccount extends PaymentAccount {
|
||||
|
||||
// https://github.com/bisq-network/growth/issues/227
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("RON")
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("RON")
|
||||
);
|
||||
|
||||
public MoneseAccount() {
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.MoneyBeamAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -32,7 +32,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class MoneyBeamAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("EUR"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("EUR"));
|
||||
|
||||
public MoneyBeamAccount() {
|
||||
super(PaymentMethod.MONEY_BEAM);
|
||||
|
@ -20,7 +20,7 @@ package haveno.core.payment;
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.Country;
|
||||
import haveno.core.locale.CountryUtil;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.MoneyGramAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -48,54 +48,54 @@ public final class MoneyGramAccount extends PaymentAccount {
|
||||
);
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("AED"),
|
||||
new FiatCurrency("ARS"),
|
||||
new FiatCurrency("AUD"),
|
||||
new FiatCurrency("BND"),
|
||||
new FiatCurrency("CAD"),
|
||||
new FiatCurrency("CHF"),
|
||||
new FiatCurrency("CZK"),
|
||||
new FiatCurrency("DKK"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("FJD"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("HKD"),
|
||||
new FiatCurrency("HUF"),
|
||||
new FiatCurrency("IDR"),
|
||||
new FiatCurrency("ILS"),
|
||||
new FiatCurrency("INR"),
|
||||
new FiatCurrency("JPY"),
|
||||
new FiatCurrency("KRW"),
|
||||
new FiatCurrency("KWD"),
|
||||
new FiatCurrency("LKR"),
|
||||
new FiatCurrency("MAD"),
|
||||
new FiatCurrency("MGA"),
|
||||
new FiatCurrency("MXN"),
|
||||
new FiatCurrency("MYR"),
|
||||
new FiatCurrency("NOK"),
|
||||
new FiatCurrency("NZD"),
|
||||
new FiatCurrency("OMR"),
|
||||
new FiatCurrency("PEN"),
|
||||
new FiatCurrency("PGK"),
|
||||
new FiatCurrency("PHP"),
|
||||
new FiatCurrency("PKR"),
|
||||
new FiatCurrency("PLN"),
|
||||
new FiatCurrency("SAR"),
|
||||
new FiatCurrency("SBD"),
|
||||
new FiatCurrency("SCR"),
|
||||
new FiatCurrency("SEK"),
|
||||
new FiatCurrency("SGD"),
|
||||
new FiatCurrency("THB"),
|
||||
new FiatCurrency("TOP"),
|
||||
new FiatCurrency("TRY"),
|
||||
new FiatCurrency("TWD"),
|
||||
new FiatCurrency("USD"),
|
||||
new FiatCurrency("VND"),
|
||||
new FiatCurrency("VUV"),
|
||||
new FiatCurrency("WST"),
|
||||
new FiatCurrency("XOF"),
|
||||
new FiatCurrency("XPF"),
|
||||
new FiatCurrency("ZAR")
|
||||
new TraditionalCurrency("AED"),
|
||||
new TraditionalCurrency("ARS"),
|
||||
new TraditionalCurrency("AUD"),
|
||||
new TraditionalCurrency("BND"),
|
||||
new TraditionalCurrency("CAD"),
|
||||
new TraditionalCurrency("CHF"),
|
||||
new TraditionalCurrency("CZK"),
|
||||
new TraditionalCurrency("DKK"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("FJD"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("HKD"),
|
||||
new TraditionalCurrency("HUF"),
|
||||
new TraditionalCurrency("IDR"),
|
||||
new TraditionalCurrency("ILS"),
|
||||
new TraditionalCurrency("INR"),
|
||||
new TraditionalCurrency("JPY"),
|
||||
new TraditionalCurrency("KRW"),
|
||||
new TraditionalCurrency("KWD"),
|
||||
new TraditionalCurrency("LKR"),
|
||||
new TraditionalCurrency("MAD"),
|
||||
new TraditionalCurrency("MGA"),
|
||||
new TraditionalCurrency("MXN"),
|
||||
new TraditionalCurrency("MYR"),
|
||||
new TraditionalCurrency("NOK"),
|
||||
new TraditionalCurrency("NZD"),
|
||||
new TraditionalCurrency("OMR"),
|
||||
new TraditionalCurrency("PEN"),
|
||||
new TraditionalCurrency("PGK"),
|
||||
new TraditionalCurrency("PHP"),
|
||||
new TraditionalCurrency("PKR"),
|
||||
new TraditionalCurrency("PLN"),
|
||||
new TraditionalCurrency("SAR"),
|
||||
new TraditionalCurrency("SBD"),
|
||||
new TraditionalCurrency("SCR"),
|
||||
new TraditionalCurrency("SEK"),
|
||||
new TraditionalCurrency("SGD"),
|
||||
new TraditionalCurrency("THB"),
|
||||
new TraditionalCurrency("TOP"),
|
||||
new TraditionalCurrency("TRY"),
|
||||
new TraditionalCurrency("TWD"),
|
||||
new TraditionalCurrency("USD"),
|
||||
new TraditionalCurrency("VND"),
|
||||
new TraditionalCurrency("VUV"),
|
||||
new TraditionalCurrency("WST"),
|
||||
new TraditionalCurrency("XOF"),
|
||||
new TraditionalCurrency("XPF"),
|
||||
new TraditionalCurrency("ZAR")
|
||||
);
|
||||
|
||||
public MoneyGramAccount() {
|
||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class NationalBankAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
|
||||
|
||||
public NationalBankAccount() {
|
||||
super(PaymentMethod.NATIONAL_BANK);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.NequiAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class NequiAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("COP"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("COP"));
|
||||
|
||||
public NequiAccount() {
|
||||
super(PaymentMethod.NEQUI);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.OKPayAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -34,29 +34,29 @@ import java.util.List;
|
||||
public final class OKPayAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("AED"),
|
||||
new FiatCurrency("ARS"),
|
||||
new FiatCurrency("AUD"),
|
||||
new FiatCurrency("BRL"),
|
||||
new FiatCurrency("CAD"),
|
||||
new FiatCurrency("CHF"),
|
||||
new FiatCurrency("CNY"),
|
||||
new FiatCurrency("DKK"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("HKD"),
|
||||
new FiatCurrency("ILS"),
|
||||
new FiatCurrency("INR"),
|
||||
new FiatCurrency("JPY"),
|
||||
new FiatCurrency("KES"),
|
||||
new FiatCurrency("MXN"),
|
||||
new FiatCurrency("NOK"),
|
||||
new FiatCurrency("NZD"),
|
||||
new FiatCurrency("PHP"),
|
||||
new FiatCurrency("PLN"),
|
||||
new FiatCurrency("SEK"),
|
||||
new FiatCurrency("SGD"),
|
||||
new FiatCurrency("USD")
|
||||
new TraditionalCurrency("AED"),
|
||||
new TraditionalCurrency("ARS"),
|
||||
new TraditionalCurrency("AUD"),
|
||||
new TraditionalCurrency("BRL"),
|
||||
new TraditionalCurrency("CAD"),
|
||||
new TraditionalCurrency("CHF"),
|
||||
new TraditionalCurrency("CNY"),
|
||||
new TraditionalCurrency("DKK"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("HKD"),
|
||||
new TraditionalCurrency("ILS"),
|
||||
new TraditionalCurrency("INR"),
|
||||
new TraditionalCurrency("JPY"),
|
||||
new TraditionalCurrency("KES"),
|
||||
new TraditionalCurrency("MXN"),
|
||||
new TraditionalCurrency("NOK"),
|
||||
new TraditionalCurrency("NZD"),
|
||||
new TraditionalCurrency("PHP"),
|
||||
new TraditionalCurrency("PLN"),
|
||||
new TraditionalCurrency("SEK"),
|
||||
new TraditionalCurrency("SGD"),
|
||||
new TraditionalCurrency("USD")
|
||||
);
|
||||
|
||||
public OKPayAccount() {
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaxumAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -40,24 +40,24 @@ public final class PaxumAccount extends PaymentAccount {
|
||||
|
||||
// https://github.com/bisq-network/growth/issues/235
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("AUD"),
|
||||
new FiatCurrency("CAD"),
|
||||
new FiatCurrency("CHF"),
|
||||
new FiatCurrency("CZK"),
|
||||
new FiatCurrency("DKK"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("HUF"),
|
||||
new FiatCurrency("IDR"),
|
||||
new FiatCurrency("INR"),
|
||||
new FiatCurrency("NOK"),
|
||||
new FiatCurrency("NZD"),
|
||||
new FiatCurrency("PLN"),
|
||||
new FiatCurrency("RON"),
|
||||
new FiatCurrency("SEK"),
|
||||
new FiatCurrency("THB"),
|
||||
new FiatCurrency("USD"),
|
||||
new FiatCurrency("ZAR")
|
||||
new TraditionalCurrency("AUD"),
|
||||
new TraditionalCurrency("CAD"),
|
||||
new TraditionalCurrency("CHF"),
|
||||
new TraditionalCurrency("CZK"),
|
||||
new TraditionalCurrency("DKK"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("HUF"),
|
||||
new TraditionalCurrency("IDR"),
|
||||
new TraditionalCurrency("INR"),
|
||||
new TraditionalCurrency("NOK"),
|
||||
new TraditionalCurrency("NZD"),
|
||||
new TraditionalCurrency("PLN"),
|
||||
new TraditionalCurrency("RON"),
|
||||
new TraditionalCurrency("SEK"),
|
||||
new TraditionalCurrency("THB"),
|
||||
new TraditionalCurrency("USD"),
|
||||
new TraditionalCurrency("ZAR")
|
||||
);
|
||||
|
||||
public PaxumAccount() {
|
||||
|
@ -24,7 +24,7 @@ import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import haveno.core.locale.Country;
|
||||
import haveno.core.locale.CountryUtil;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
@ -435,7 +435,7 @@ class PaymentAccountTypeAdapter extends TypeAdapter<PaymentAccount> {
|
||||
|
||||
if (account.isCountryBasedPaymentAccount()) {
|
||||
((CountryBasedPaymentAccount) account).setCountry(country.get());
|
||||
FiatCurrency fiatCurrency = getCurrencyByCountryCode(checkNotNull(countryCode));
|
||||
TraditionalCurrency fiatCurrency = getCurrencyByCountryCode(checkNotNull(countryCode));
|
||||
account.setSingleTradeCurrency(fiatCurrency);
|
||||
} else if (account.hasPaymentMethodWithId(MONEY_GRAM_ID)) {
|
||||
((MoneyGramAccount) account).setCountry(country.get());
|
||||
|
@ -295,7 +295,7 @@ public class PaymentAccountUtil {
|
||||
|
||||
@Nullable
|
||||
public static String getCountryCode(PaymentAccount paymentAccount) {
|
||||
// That is optional and set to null if not supported (AltCoins,...)
|
||||
// That is optional and set to null if not supported (Cryptos,...)
|
||||
if (paymentAccount instanceof CountryBasedPaymentAccount) {
|
||||
Country country = (((CountryBasedPaymentAccount) paymentAccount)).getCountry();
|
||||
return country != null ? country.code : null;
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -33,38 +33,38 @@ public final class PayseraAccount extends PaymentAccount {
|
||||
|
||||
// https://github.com/bisq-network/growth/issues/233
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("AUD"),
|
||||
new FiatCurrency("BGN"),
|
||||
new FiatCurrency("BYN"),
|
||||
new FiatCurrency("CAD"),
|
||||
new FiatCurrency("CHF"),
|
||||
new FiatCurrency("CNY"),
|
||||
new FiatCurrency("CZK"),
|
||||
new FiatCurrency("DKK"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("GEL"),
|
||||
new FiatCurrency("HKD"),
|
||||
new FiatCurrency("HRK"),
|
||||
new FiatCurrency("HUF"),
|
||||
new FiatCurrency("ILS"),
|
||||
new FiatCurrency("INR"),
|
||||
new FiatCurrency("JPY"),
|
||||
new FiatCurrency("KZT"),
|
||||
new FiatCurrency("MXN"),
|
||||
new FiatCurrency("NOK"),
|
||||
new FiatCurrency("NZD"),
|
||||
new FiatCurrency("PHP"),
|
||||
new FiatCurrency("PLN"),
|
||||
new FiatCurrency("RON"),
|
||||
new FiatCurrency("RSD"),
|
||||
new FiatCurrency("RUB"),
|
||||
new FiatCurrency("SEK"),
|
||||
new FiatCurrency("SGD"),
|
||||
new FiatCurrency("THB"),
|
||||
new FiatCurrency("TRY"),
|
||||
new FiatCurrency("USD"),
|
||||
new FiatCurrency("ZAR")
|
||||
new TraditionalCurrency("AUD"),
|
||||
new TraditionalCurrency("BGN"),
|
||||
new TraditionalCurrency("BYN"),
|
||||
new TraditionalCurrency("CAD"),
|
||||
new TraditionalCurrency("CHF"),
|
||||
new TraditionalCurrency("CNY"),
|
||||
new TraditionalCurrency("CZK"),
|
||||
new TraditionalCurrency("DKK"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("GEL"),
|
||||
new TraditionalCurrency("HKD"),
|
||||
new TraditionalCurrency("HRK"),
|
||||
new TraditionalCurrency("HUF"),
|
||||
new TraditionalCurrency("ILS"),
|
||||
new TraditionalCurrency("INR"),
|
||||
new TraditionalCurrency("JPY"),
|
||||
new TraditionalCurrency("KZT"),
|
||||
new TraditionalCurrency("MXN"),
|
||||
new TraditionalCurrency("NOK"),
|
||||
new TraditionalCurrency("NZD"),
|
||||
new TraditionalCurrency("PHP"),
|
||||
new TraditionalCurrency("PLN"),
|
||||
new TraditionalCurrency("RON"),
|
||||
new TraditionalCurrency("RSD"),
|
||||
new TraditionalCurrency("RUB"),
|
||||
new TraditionalCurrency("SEK"),
|
||||
new TraditionalCurrency("SGD"),
|
||||
new TraditionalCurrency("THB"),
|
||||
new TraditionalCurrency("TRY"),
|
||||
new TraditionalCurrency("USD"),
|
||||
new TraditionalCurrency("ZAR")
|
||||
);
|
||||
|
||||
public PayseraAccount() {
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class PerfectMoneyAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
public PerfectMoneyAccount() {
|
||||
super(PaymentMethod.PERFECT_MONEY);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class PixAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("BRL"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("BRL"));
|
||||
|
||||
public PixAccount() {
|
||||
super(PaymentMethod.PIX);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -32,7 +32,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class PopmoneyAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
public PopmoneyAccount() {
|
||||
super(PaymentMethod.POPMONEY);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class PromptPayAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("THB"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("THB"));
|
||||
|
||||
public PromptPayAccount() {
|
||||
super(PaymentMethod.PROMPT_PAY);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -40,37 +40,37 @@ public final class RevolutAccount extends PaymentAccount {
|
||||
|
||||
// https://www.revolut.com/help/getting-started/exchanging-currencies/what-fiat-currencies-are-supported-for-holding-and-exchange
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("AED"),
|
||||
new FiatCurrency("AUD"),
|
||||
new FiatCurrency("BGN"),
|
||||
new FiatCurrency("CAD"),
|
||||
new FiatCurrency("CHF"),
|
||||
new FiatCurrency("CZK"),
|
||||
new FiatCurrency("DKK"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("HKD"),
|
||||
new FiatCurrency("HRK"),
|
||||
new FiatCurrency("HUF"),
|
||||
new FiatCurrency("ILS"),
|
||||
new FiatCurrency("ISK"),
|
||||
new FiatCurrency("JPY"),
|
||||
new FiatCurrency("MAD"),
|
||||
new FiatCurrency("MXN"),
|
||||
new FiatCurrency("NOK"),
|
||||
new FiatCurrency("NZD"),
|
||||
new FiatCurrency("PLN"),
|
||||
new FiatCurrency("QAR"),
|
||||
new FiatCurrency("RON"),
|
||||
new FiatCurrency("RSD"),
|
||||
new FiatCurrency("RUB"),
|
||||
new FiatCurrency("SAR"),
|
||||
new FiatCurrency("SEK"),
|
||||
new FiatCurrency("SGD"),
|
||||
new FiatCurrency("THB"),
|
||||
new FiatCurrency("TRY"),
|
||||
new FiatCurrency("USD"),
|
||||
new FiatCurrency("ZAR")
|
||||
new TraditionalCurrency("AED"),
|
||||
new TraditionalCurrency("AUD"),
|
||||
new TraditionalCurrency("BGN"),
|
||||
new TraditionalCurrency("CAD"),
|
||||
new TraditionalCurrency("CHF"),
|
||||
new TraditionalCurrency("CZK"),
|
||||
new TraditionalCurrency("DKK"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("HKD"),
|
||||
new TraditionalCurrency("HRK"),
|
||||
new TraditionalCurrency("HUF"),
|
||||
new TraditionalCurrency("ILS"),
|
||||
new TraditionalCurrency("ISK"),
|
||||
new TraditionalCurrency("JPY"),
|
||||
new TraditionalCurrency("MAD"),
|
||||
new TraditionalCurrency("MXN"),
|
||||
new TraditionalCurrency("NOK"),
|
||||
new TraditionalCurrency("NZD"),
|
||||
new TraditionalCurrency("PLN"),
|
||||
new TraditionalCurrency("QAR"),
|
||||
new TraditionalCurrency("RON"),
|
||||
new TraditionalCurrency("RSD"),
|
||||
new TraditionalCurrency("RUB"),
|
||||
new TraditionalCurrency("SAR"),
|
||||
new TraditionalCurrency("SEK"),
|
||||
new TraditionalCurrency("SGD"),
|
||||
new TraditionalCurrency("THB"),
|
||||
new TraditionalCurrency("TRY"),
|
||||
new TraditionalCurrency("USD"),
|
||||
new TraditionalCurrency("ZAR")
|
||||
);
|
||||
|
||||
public RevolutAccount() {
|
||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class SameBankAccount extends CountryBasedPaymentAccount implements BankNameRestrictedBankAccount, SameCountryRestrictedBankAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
|
||||
|
||||
public SameBankAccount() {
|
||||
super(PaymentMethod.SAME_BANK);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class SatispayAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("EUR"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("EUR"));
|
||||
|
||||
public SatispayAccount() {
|
||||
super(PaymentMethod.SATISPAY);
|
||||
|
@ -21,7 +21,7 @@ import haveno.core.api.model.PaymentAccountForm;
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.Country;
|
||||
import haveno.core.locale.CountryUtil;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -46,7 +46,7 @@ public final class SepaAccount extends CountryBasedPaymentAccount implements Ban
|
||||
PaymentAccountFormField.FieldId.SALT
|
||||
);
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("EUR"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("EUR"));
|
||||
|
||||
public SepaAccount() {
|
||||
super(PaymentMethod.SEPA);
|
||||
|
@ -21,7 +21,7 @@ import haveno.core.api.model.PaymentAccountForm;
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.Country;
|
||||
import haveno.core.locale.CountryUtil;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -36,7 +36,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class SepaInstantAccount extends CountryBasedPaymentAccount implements BankAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("EUR"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("EUR"));
|
||||
|
||||
public SepaInstantAccount() {
|
||||
super(PaymentMethod.SEPA_INSTANT);
|
||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class SpecificBanksAccount extends CountryBasedPaymentAccount implements BankNameRestrictedBankAccount, SameCountryRestrictedBankAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
|
||||
|
||||
public SpecificBanksAccount() {
|
||||
super(PaymentMethod.SPECIFIC_BANKS);
|
||||
|
@ -20,7 +20,7 @@ package haveno.core.payment;
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.Country;
|
||||
import haveno.core.locale.CountryUtil;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -34,7 +34,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class StrikeAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
public static final List<Country> SUPPORTED_COUNTRIES = CountryUtil.getCountries(List.of("US"));
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
|
@ -28,13 +28,13 @@ import lombok.NonNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static haveno.core.locale.CurrencyUtil.getAllSortedFiatCurrencies;
|
||||
import static haveno.core.locale.CurrencyUtil.getAllSortedTraditionalCurrencies;
|
||||
import static java.util.Comparator.comparing;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class SwiftAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = new ArrayList<>(getAllSortedFiatCurrencies(comparing(TradeCurrency::getCode)));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = new ArrayList<>(getAllSortedTraditionalCurrencies(comparing(TradeCurrency::getCode)));
|
||||
|
||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class SwishAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("SEK"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("SEK"));
|
||||
|
||||
public SwishAccount() {
|
||||
super(PaymentMethod.SWISH);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class TikkieAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("EUR"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("EUR"));
|
||||
|
||||
public TikkieAccount() {
|
||||
super(PaymentMethod.TIKKIE);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -40,48 +40,48 @@ public final class TransferwiseAccount extends PaymentAccount {
|
||||
|
||||
// https://github.com/bisq-network/proposals/issues/243
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("AED"),
|
||||
new FiatCurrency("ARS"),
|
||||
new FiatCurrency("AUD"),
|
||||
new FiatCurrency("BGN"),
|
||||
new FiatCurrency("CAD"),
|
||||
new FiatCurrency("CHF"),
|
||||
new FiatCurrency("CLP"),
|
||||
new FiatCurrency("CZK"),
|
||||
new FiatCurrency("DKK"),
|
||||
new FiatCurrency("EGP"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("GEL"),
|
||||
new FiatCurrency("HKD"),
|
||||
new FiatCurrency("HRK"),
|
||||
new FiatCurrency("HUF"),
|
||||
new FiatCurrency("IDR"),
|
||||
new FiatCurrency("ILS"),
|
||||
new FiatCurrency("JPY"),
|
||||
new FiatCurrency("KES"),
|
||||
new FiatCurrency("KRW"),
|
||||
new FiatCurrency("MAD"),
|
||||
new FiatCurrency("MXN"),
|
||||
new FiatCurrency("MYR"),
|
||||
new FiatCurrency("NOK"),
|
||||
new FiatCurrency("NPR"),
|
||||
new FiatCurrency("NZD"),
|
||||
new FiatCurrency("PEN"),
|
||||
new FiatCurrency("PHP"),
|
||||
new FiatCurrency("PKR"),
|
||||
new FiatCurrency("PLN"),
|
||||
new FiatCurrency("RON"),
|
||||
new FiatCurrency("RUB"),
|
||||
new FiatCurrency("SEK"),
|
||||
new FiatCurrency("SGD"),
|
||||
new FiatCurrency("THB"),
|
||||
new FiatCurrency("TRY"),
|
||||
new FiatCurrency("UGX"),
|
||||
new FiatCurrency("VND"),
|
||||
new FiatCurrency("XOF"),
|
||||
new FiatCurrency("ZAR"),
|
||||
new FiatCurrency("ZMW")
|
||||
new TraditionalCurrency("AED"),
|
||||
new TraditionalCurrency("ARS"),
|
||||
new TraditionalCurrency("AUD"),
|
||||
new TraditionalCurrency("BGN"),
|
||||
new TraditionalCurrency("CAD"),
|
||||
new TraditionalCurrency("CHF"),
|
||||
new TraditionalCurrency("CLP"),
|
||||
new TraditionalCurrency("CZK"),
|
||||
new TraditionalCurrency("DKK"),
|
||||
new TraditionalCurrency("EGP"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("GEL"),
|
||||
new TraditionalCurrency("HKD"),
|
||||
new TraditionalCurrency("HRK"),
|
||||
new TraditionalCurrency("HUF"),
|
||||
new TraditionalCurrency("IDR"),
|
||||
new TraditionalCurrency("ILS"),
|
||||
new TraditionalCurrency("JPY"),
|
||||
new TraditionalCurrency("KES"),
|
||||
new TraditionalCurrency("KRW"),
|
||||
new TraditionalCurrency("MAD"),
|
||||
new TraditionalCurrency("MXN"),
|
||||
new TraditionalCurrency("MYR"),
|
||||
new TraditionalCurrency("NOK"),
|
||||
new TraditionalCurrency("NPR"),
|
||||
new TraditionalCurrency("NZD"),
|
||||
new TraditionalCurrency("PEN"),
|
||||
new TraditionalCurrency("PHP"),
|
||||
new TraditionalCurrency("PKR"),
|
||||
new TraditionalCurrency("PLN"),
|
||||
new TraditionalCurrency("RON"),
|
||||
new TraditionalCurrency("RUB"),
|
||||
new TraditionalCurrency("SEK"),
|
||||
new TraditionalCurrency("SGD"),
|
||||
new TraditionalCurrency("THB"),
|
||||
new TraditionalCurrency("TRY"),
|
||||
new TraditionalCurrency("UGX"),
|
||||
new TraditionalCurrency("VND"),
|
||||
new TraditionalCurrency("XOF"),
|
||||
new TraditionalCurrency("ZAR"),
|
||||
new TraditionalCurrency("ZMW")
|
||||
);
|
||||
|
||||
public TransferwiseAccount() {
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class TransferwiseUsdAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
public TransferwiseUsdAccount() {
|
||||
super(PaymentMethod.TRANSFERWISE_USD);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class USPostalMoneyOrderAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
public USPostalMoneyOrderAccount() {
|
||||
super(PaymentMethod.US_POSTAL_MONEY_ORDER);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -42,29 +42,29 @@ public final class UpholdAccount extends PaymentAccount {
|
||||
|
||||
// https://support.uphold.com/hc/en-us/articles/202473803-Supported-currencies
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("AED"),
|
||||
new FiatCurrency("ARS"),
|
||||
new FiatCurrency("AUD"),
|
||||
new FiatCurrency("BRL"),
|
||||
new FiatCurrency("CAD"),
|
||||
new FiatCurrency("CHF"),
|
||||
new FiatCurrency("CNY"),
|
||||
new FiatCurrency("DKK"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("GBP"),
|
||||
new FiatCurrency("HKD"),
|
||||
new FiatCurrency("ILS"),
|
||||
new FiatCurrency("INR"),
|
||||
new FiatCurrency("JPY"),
|
||||
new FiatCurrency("KES"),
|
||||
new FiatCurrency("MXN"),
|
||||
new FiatCurrency("NOK"),
|
||||
new FiatCurrency("NZD"),
|
||||
new FiatCurrency("PHP"),
|
||||
new FiatCurrency("PLN"),
|
||||
new FiatCurrency("SEK"),
|
||||
new FiatCurrency("SGD"),
|
||||
new FiatCurrency("USD")
|
||||
new TraditionalCurrency("AED"),
|
||||
new TraditionalCurrency("ARS"),
|
||||
new TraditionalCurrency("AUD"),
|
||||
new TraditionalCurrency("BRL"),
|
||||
new TraditionalCurrency("CAD"),
|
||||
new TraditionalCurrency("CHF"),
|
||||
new TraditionalCurrency("CNY"),
|
||||
new TraditionalCurrency("DKK"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("GBP"),
|
||||
new TraditionalCurrency("HKD"),
|
||||
new TraditionalCurrency("ILS"),
|
||||
new TraditionalCurrency("INR"),
|
||||
new TraditionalCurrency("JPY"),
|
||||
new TraditionalCurrency("KES"),
|
||||
new TraditionalCurrency("MXN"),
|
||||
new TraditionalCurrency("NOK"),
|
||||
new TraditionalCurrency("NZD"),
|
||||
new TraditionalCurrency("PHP"),
|
||||
new TraditionalCurrency("PLN"),
|
||||
new TraditionalCurrency("SEK"),
|
||||
new TraditionalCurrency("SGD"),
|
||||
new TraditionalCurrency("USD")
|
||||
);
|
||||
|
||||
public UpholdAccount() {
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -34,7 +34,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class VenmoAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("USD"));
|
||||
|
||||
public VenmoAccount() {
|
||||
super(PaymentMethod.VENMO);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -33,11 +33,11 @@ public final class VerseAccount extends PaymentAccount {
|
||||
|
||||
// https://github.com/bisq-network/growth/issues/223
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||
new FiatCurrency("DKK"),
|
||||
new FiatCurrency("EUR"),
|
||||
new FiatCurrency("HUF"),
|
||||
new FiatCurrency("PLN"),
|
||||
new FiatCurrency("SEK")
|
||||
new TraditionalCurrency("DKK"),
|
||||
new TraditionalCurrency("EUR"),
|
||||
new TraditionalCurrency("HUF"),
|
||||
new TraditionalCurrency("PLN"),
|
||||
new TraditionalCurrency("SEK")
|
||||
);
|
||||
|
||||
public VerseAccount() {
|
||||
|
@ -18,7 +18,7 @@
|
||||
package haveno.core.payment;
|
||||
|
||||
import haveno.core.api.model.PaymentAccountFormField;
|
||||
import haveno.core.locale.FiatCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.payment.payload.PaymentMethod;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class WeChatPayAccount extends PaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new FiatCurrency("CNY"));
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(new TraditionalCurrency("CNY"));
|
||||
|
||||
public WeChatPayAccount() {
|
||||
super(PaymentMethod.WECHAT_PAY);
|
||||
|
@ -29,7 +29,7 @@ import java.util.List;
|
||||
|
||||
public final class WesternUnionAccount extends CountryBasedPaymentAccount {
|
||||
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
|
||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
|
||||
|
||||
public WesternUnionAccount() {
|
||||
super(PaymentMethod.WESTERN_UNION);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user