mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-10-01 01:35:48 -04:00
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
|
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."
|
printdate "Create Alice's XMR Trading Payment Account."
|
||||||
# Note: Having problems passing a double quoted --account-name param to function.
|
# 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.apitest.method.MethodTest;
|
||||||
import haveno.cli.GrpcClient;
|
import haveno.cli.GrpcClient;
|
||||||
import haveno.core.api.model.PaymentAccountForm;
|
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.Res;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.PaymentAccount;
|
import haveno.core.payment.PaymentAccount;
|
||||||
@ -168,11 +168,11 @@ public class AbstractPaymentAccountTest extends MethodTest {
|
|||||||
assertEquals(expectedCurrencyCode, paymentAccount.getSingleTradeCurrency().getCode());
|
assertEquals(expectedCurrencyCode, paymentAccount.getSingleTradeCurrency().getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void verifyAccountTradeCurrencies(Collection<FiatCurrency> expectedFiatCurrencies,
|
protected final void verifyAccountTradeCurrencies(Collection<TraditionalCurrency> expectedTraditionalCurrencies,
|
||||||
PaymentAccount paymentAccount) {
|
PaymentAccount paymentAccount) {
|
||||||
assertNotNull(paymentAccount.getTradeCurrencies());
|
assertNotNull(paymentAccount.getTradeCurrencies());
|
||||||
List<TradeCurrency> expectedTradeCurrencies = new ArrayList<>() {{
|
List<TradeCurrency> expectedTradeCurrencies = new ArrayList<>() {{
|
||||||
addAll(expectedFiatCurrencies);
|
addAll(expectedTraditionalCurrencies);
|
||||||
}};
|
}};
|
||||||
assertArrayEquals(expectedTradeCurrencies.toArray(), paymentAccount.getTradeCurrencies().toArray());
|
assertArrayEquals(expectedTradeCurrencies.toArray(), paymentAccount.getTradeCurrencies().toArray());
|
||||||
}
|
}
|
||||||
@ -206,8 +206,8 @@ public class AbstractPaymentAccountTest extends MethodTest {
|
|||||||
return jsonString;
|
return jsonString;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final String getCommaDelimitedFiatCurrencyCodes(Collection<FiatCurrency> fiatCurrencies) {
|
protected final String getCommaDelimitedTraditionalCurrencyCodes(Collection<TraditionalCurrency> traditionalCurrencies) {
|
||||||
return fiatCurrencies.stream()
|
return traditionalCurrencies.stream()
|
||||||
.sorted(Comparator.comparing(TradeCurrency::getCode))
|
.sorted(Comparator.comparing(TradeCurrency::getCode))
|
||||||
.map(c -> c.getCurrency().getCurrencyCode())
|
.map(c -> c.getCurrency().getCurrencyCode())
|
||||||
.collect(Collectors.joining(","));
|
.collect(Collectors.joining(","));
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.apitest.method.payment;
|
package haveno.apitest.method.payment;
|
||||||
|
|
||||||
import haveno.cli.table.builder.TableBuilder;
|
import haveno.cli.table.builder.TableBuilder;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.AdvancedCashAccount;
|
import haveno.core.payment.AdvancedCashAccount;
|
||||||
import haveno.core.payment.AliPayAccount;
|
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.ApiTestConfig.USD;
|
||||||
import static haveno.apitest.config.HavenoAppConfig.alicedaemon;
|
import static haveno.apitest.config.HavenoAppConfig.alicedaemon;
|
||||||
import static haveno.cli.table.builder.TableType.PAYMENT_ACCOUNT_TBL;
|
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.locale.CurrencyUtil.getTradeCurrency;
|
||||||
import static haveno.core.payment.payload.PaymentMethod.ADVANCED_CASH_ID;
|
import static haveno.core.payment.payload.PaymentMethod.ADVANCED_CASH_ID;
|
||||||
import static haveno.core.payment.payload.PaymentMethod.ALI_PAY_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);
|
PROPERTY_NAME_BANK_SWIFT_CODE);
|
||||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PAYMENT_METHOD_ID, SWIFT_ID);
|
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");
|
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NAME, "IT Swift Acct w/ DE Intermediary");
|
||||||
Collection<FiatCurrency> swiftCurrenciesSortedByCode = getAllSortedFiatCurrencies(comparing(TradeCurrency::getCode));
|
Collection<TraditionalCurrency> swiftCurrenciesSortedByCode = getAllSortedTraditionalCurrencies(comparing(TradeCurrency::getCode));
|
||||||
String allFiatCodes = getCommaDelimitedFiatCurrencyCodes(swiftCurrenciesSortedByCode);
|
String allTraditionalCodes = getCommaDelimitedTraditionalCurrencyCodes(swiftCurrenciesSortedByCode);
|
||||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, allFiatCodes);
|
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_SELECTED_TRADE_CURRENCY, EUR);
|
||||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_BANK_SWIFT_CODE, "PASCITMMFIR");
|
COMPLETED_FORM_MAP.put(PROPERTY_NAME_BANK_SWIFT_CODE, "PASCITMMFIR");
|
||||||
COMPLETED_FORM_MAP.put(PROPERTY_NAME_BANK_COUNTRY_CODE, "IT");
|
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 trade = makeTrade.apply(randomOffer);
|
||||||
|
|
||||||
var makerIsBuyer = trade.getOffer().getDirection().equalsIgnoreCase(BUY);
|
var makerIsBuyer = trade.getOffer().getDirection().equalsIgnoreCase(BUY);
|
||||||
Function<TradeInfo, TradeInfo> completeFiatTransaction = makerIsBuyer
|
Function<TradeInfo, TradeInfo> completeTraditionalTransaction = makerIsBuyer
|
||||||
? sendPaymentSentMessage.andThen(waitForPaymentReceivedConfirmation)
|
? sendPaymentSentMessage.andThen(waitForPaymentReceivedConfirmation)
|
||||||
: waitForPaymentSentMessage.andThen(sendPaymentReceivedMessage);
|
: waitForPaymentSentMessage.andThen(sendPaymentReceivedMessage);
|
||||||
completeFiatTransaction.apply(trade);
|
completeTraditionalTransaction.apply(trade);
|
||||||
|
|
||||||
currentProtocolStep = DONE;
|
currentProtocolStep = DONE;
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ public class TakerBotProtocol extends BotProtocol {
|
|||||||
var trade = takeTrade.apply(findOffer.get());
|
var trade = takeTrade.apply(findOffer.get());
|
||||||
|
|
||||||
var takerIsSeller = trade.getOffer().getDirection().equalsIgnoreCase(BUY);
|
var takerIsSeller = trade.getOffer().getDirection().equalsIgnoreCase(BUY);
|
||||||
Function<TradeInfo, TradeInfo> completeFiatTransaction = takerIsSeller
|
Function<TradeInfo, TradeInfo> completeTraditionalTransaction = takerIsSeller
|
||||||
? waitForPaymentSentMessage.andThen(sendPaymentReceivedMessage)
|
? waitForPaymentSentMessage.andThen(sendPaymentReceivedMessage)
|
||||||
: sendPaymentSentMessage.andThen(waitForPaymentReceivedConfirmation);
|
: sendPaymentSentMessage.andThen(waitForPaymentReceivedConfirmation);
|
||||||
completeFiatTransaction.apply(trade);
|
completeTraditionalTransaction.apply(trade);
|
||||||
|
|
||||||
currentProtocolStep = DONE;
|
currentProtocolStep = DONE;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class AddressValidationResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static AddressValidationResult invalidAddress(String cause) {
|
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) {
|
public static AddressValidationResult invalidAddress(String cause, String i18nKey) {
|
||||||
@ -68,6 +68,6 @@ public class AddressValidationResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static AddressValidationResult invalidStructure() {
|
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)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.TYPE)
|
@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
|
* @return translation key
|
||||||
*/
|
*/
|
||||||
String value();
|
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})$";
|
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() {
|
public LiquidBitcoinAddressValidator() {
|
||||||
super(REGEX, "validation.altcoin.liquidBitcoin.invalidAddress");
|
super(REGEX, "validation.crypto.liquidBitcoin.invalidAddress");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
package haveno.asset.coins;
|
package haveno.asset.coins;
|
||||||
|
|
||||||
import haveno.asset.AltCoinAccountDisclaimer;
|
import haveno.asset.CryptoAccountDisclaimer;
|
||||||
import haveno.asset.Coin;
|
import haveno.asset.Coin;
|
||||||
import haveno.asset.CryptoNoteAddressValidator;
|
import haveno.asset.CryptoNoteAddressValidator;
|
||||||
|
|
||||||
@AltCoinAccountDisclaimer("account.altcoin.popup.xmr.msg")
|
@CryptoAccountDisclaimer("account.crypto.popup.xmr.msg")
|
||||||
public class Monero extends Coin {
|
public class Monero extends Coin {
|
||||||
|
|
||||||
public Monero() {
|
public Monero() {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
* Haveno's family of abstractions representing different ("crypto")
|
* Haveno's family of abstractions representing different ("crypto")
|
||||||
* {@link haveno.asset.Asset} types such as {@link haveno.asset.Coin},
|
* {@link haveno.asset.Asset} types such as {@link haveno.asset.Coin},
|
||||||
* {@link haveno.asset.Token} and {@link haveno.asset.Erc20Token}, as well as concrete
|
* {@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.coins.Litecoin} and {@link haveno.asset.coins.Ether} and tokens like
|
||||||
* {@link haveno.asset.tokens.DaiStablecoin}.
|
* {@link haveno.asset.tokens.DaiStablecoin}.
|
||||||
* <p>
|
* <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
|
# 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.
|
# 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.crypto.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.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.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.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.altcoin.popup.validation.NMC=NMC address must start with 'N' or 'M' and must be 34 characters long.
|
account.crypto.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.crypto.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.crypto.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.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_NAME = "Name";
|
||||||
static final String COL_HEADER_PAYMENT_METHOD = "Payment Method";
|
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 = "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_AMOUNT = padStart("Amount(%-3s)", 12, ' ');
|
||||||
static final String COL_HEADER_TRADE_BUYER_COST = padEnd("Buyer Cost(%-3s)", 15, ' ');
|
static final String COL_HEADER_TRADE_BUYER_COST = padEnd("Buyer Cost(%-3s)", 15, ' ');
|
||||||
static final String COL_HEADER_TRADE_DEPOSIT_CONFIRMED = "Deposit Confirmed";
|
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)")
|
final OptionSpec<String> currencyCodeOpt = parser.accepts(OPT_CURRENCY_CODE, "crypto currency code (xmr)")
|
||||||
.withRequiredArg();
|
.withRequiredArg();
|
||||||
|
|
||||||
final OptionSpec<String> addressOpt = parser.accepts(OPT_ADDRESS, "altcoin address")
|
final OptionSpec<String> addressOpt = parser.accepts(OPT_ADDRESS, "crypto address")
|
||||||
.withRequiredArg();
|
.withRequiredArg();
|
||||||
|
|
||||||
final OptionSpec<Boolean> tradeInstantOpt = parser.accepts(OPT_TRADE_INSTANT, "create trade instant account")
|
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 {
|
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 TableType tableType;
|
||||||
protected final List<?> protos;
|
protected final List<?> protos;
|
||||||
|
@ -91,7 +91,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
|||||||
@Nullable
|
@Nullable
|
||||||
protected final Column<Boolean> colIsPaymentReceivedMessageSent;
|
protected final Column<Boolean> colIsPaymentReceivedMessageSent;
|
||||||
@Nullable
|
@Nullable
|
||||||
protected final Column<String> colAltcoinReceiveAddressColumn;
|
protected final Column<String> colCryptoReceiveAddressColumn;
|
||||||
|
|
||||||
AbstractTradeListBuilder(TableType tableType, List<?> protos) {
|
AbstractTradeListBuilder(TableType tableType, List<?> protos) {
|
||||||
super(tableType, protos);
|
super(tableType, protos);
|
||||||
@ -127,7 +127,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
|||||||
this.colIsPaymentSentMessageSent = colSupplier.paymentSentMessageSentColumn.get();
|
this.colIsPaymentSentMessageSent = colSupplier.paymentSentMessageSentColumn.get();
|
||||||
this.colIsPaymentReceivedMessageSent = colSupplier.paymentReceivedMessageSentColumn.get();
|
this.colIsPaymentReceivedMessageSent = colSupplier.paymentReceivedMessageSentColumn.get();
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
this.colAltcoinReceiveAddressColumn = colSupplier.altcoinReceiveAddressColumn.get();
|
this.colCryptoReceiveAddressColumn = colSupplier.cryptoReceiveAddressColumn.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void validate() {
|
protected void validate() {
|
||||||
@ -142,7 +142,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
|||||||
// Helper Functions
|
// Helper Functions
|
||||||
|
|
||||||
private final Supplier<Boolean> isTradeDetailTblBuilder = () -> tableType.equals(TRADE_DETAIL_TBL);
|
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> isMyOffer = (t) -> t.getOffer().getIsMyOffer();
|
||||||
protected final Predicate<TradeInfo> isTaker = (t) -> t.getRole().toLowerCase().contains("taker");
|
protected final Predicate<TradeInfo> isTaker = (t) -> t.getRole().toLowerCase().contains("taker");
|
||||||
protected final Predicate<TradeInfo> isSellOffer = (t) -> t.getOffer().getDirection().equals(SELL.name());
|
protected final Predicate<TradeInfo> isSellOffer = (t) -> t.getOffer().getDirection().equals(SELL.name());
|
||||||
@ -152,23 +152,23 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
|||||||
|
|
||||||
// Column Value Functions
|
// 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
|
// Converting them to longs ("sats") requires shifting the decimal points
|
||||||
// to left: 2 for BSQ, 8 for other altcoins.
|
// to left: 2 for BSQ, 8 for other cryptos.
|
||||||
protected final Function<TradeInfo, Long> toAltcoinTradeVolumeAsLong = (t) -> new BigDecimal(t.getTradeVolume()).movePointRight(8).longValue();
|
protected final Function<TradeInfo, Long> toCryptoTradeVolumeAsLong = (t) -> new BigDecimal(t.getTradeVolume()).movePointRight(8).longValue();
|
||||||
|
|
||||||
protected final Function<TradeInfo, String> toTradeVolumeAsString = (t) ->
|
protected final Function<TradeInfo, String> toTradeVolumeAsString = (t) ->
|
||||||
isFiatTrade.test(t)
|
isTraditionalTrade.test(t)
|
||||||
? t.getTradeVolume()
|
? t.getTradeVolume()
|
||||||
: formatSatoshis(t.getAmount());
|
: formatSatoshis(t.getAmount());
|
||||||
|
|
||||||
protected final Function<TradeInfo, Long> toTradeVolumeAsLong = (t) ->
|
protected final Function<TradeInfo, Long> toTradeVolumeAsLong = (t) ->
|
||||||
isFiatTrade.test(t)
|
isTraditionalTrade.test(t)
|
||||||
? Long.parseLong(t.getTradeVolume())
|
? Long.parseLong(t.getTradeVolume())
|
||||||
: toAltcoinTradeVolumeAsLong.apply(t);
|
: toCryptoTradeVolumeAsLong.apply(t);
|
||||||
|
|
||||||
protected final Function<TradeInfo, Long> toTradeAmount = (t) ->
|
protected final Function<TradeInfo, Long> toTradeAmount = (t) ->
|
||||||
isFiatTrade.test(t)
|
isTraditionalTrade.test(t)
|
||||||
? t.getAmount()
|
? t.getAmount()
|
||||||
: toTradeVolumeAsLong.apply(t);
|
: toTradeVolumeAsLong.apply(t);
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
|||||||
+ t.getOffer().getCounterCurrencyCode();
|
+ t.getOffer().getCounterCurrencyCode();
|
||||||
|
|
||||||
protected final Function<TradeInfo, String> toPaymentCurrencyCode = (t) ->
|
protected final Function<TradeInfo, String> toPaymentCurrencyCode = (t) ->
|
||||||
isFiatTrade.test(t)
|
isTraditionalTrade.test(t)
|
||||||
? t.getOffer().getCounterCurrencyCode()
|
? t.getOffer().getCounterCurrencyCode()
|
||||||
: t.getOffer().getBaseCurrencyCode();
|
: t.getOffer().getBaseCurrencyCode();
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected final Function<TradeInfo, String> toOfferType = (t) -> {
|
protected final Function<TradeInfo, String> toOfferType = (t) -> {
|
||||||
if (isFiatTrade.test(t)) {
|
if (isTraditionalTrade.test(t)) {
|
||||||
return t.getOffer().getDirection() + " " + t.getOffer().getBaseCurrencyCode();
|
return t.getOffer().getDirection() + " " + t.getOffer().getBaseCurrencyCode();
|
||||||
} else {
|
} else {
|
||||||
if (t.getOffer().getDirection().equals("BUY")) {
|
if (t.getOffer().getDirection().equals("BUY")) {
|
||||||
@ -213,8 +213,8 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected final Predicate<TradeInfo> showAltCoinBuyerAddress = (t) -> {
|
protected final Predicate<TradeInfo> showCryptoBuyerAddress = (t) -> {
|
||||||
if (isFiatTrade.test(t)) {
|
if (isTraditionalTrade.test(t)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
ContractInfo contract = t.getContract();
|
ContractInfo contract = t.getContract();
|
||||||
@ -227,8 +227,8 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected final Function<TradeInfo, String> toAltcoinReceiveAddress = (t) -> {
|
protected final Function<TradeInfo, String> toCryptoReceiveAddress = (t) -> {
|
||||||
if (showAltCoinBuyerAddress.test(t)) {
|
if (showCryptoBuyerAddress.test(t)) {
|
||||||
ContractInfo contract = t.getContract();
|
ContractInfo contract = t.getContract();
|
||||||
boolean isBuyerMakerAndSellerTaker = contract.getIsBuyerMakerAndSellerTaker();
|
boolean isBuyerMakerAndSellerTaker = contract.getIsBuyerMakerAndSellerTaker();
|
||||||
return isBuyerMakerAndSellerTaker // (is BTC buyer / maker)
|
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_AMOUNT_RANGE;
|
||||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_CREATION_DATE;
|
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;
|
||||||
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_DIRECTION;
|
||||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_ENABLED;
|
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_ENABLED;
|
||||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_PAYMENT_METHOD;
|
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_PAYMENT_METHOD;
|
||||||
@ -56,7 +56,7 @@ import static protobuf.OfferDirection.SELL;
|
|||||||
*/
|
*/
|
||||||
class OfferTableBuilder extends AbstractTableBuilder {
|
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> colOfferId = new StringColumn(COL_HEADER_UUID, LEFT);
|
||||||
private final Column<String> colDirection = new StringColumn(COL_HEADER_DIRECTION, LEFT);
|
private final Column<String> colDirection = new StringColumn(COL_HEADER_DIRECTION, LEFT);
|
||||||
private final Column<Long> colAmount = new SatoshiColumn("Temp Amount", NONE);
|
private final Column<Long> colAmount = new SatoshiColumn("Temp Amount", NONE);
|
||||||
@ -71,20 +71,20 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
|||||||
@Override
|
@Override
|
||||||
public Table build() {
|
public Table build() {
|
||||||
List<OfferInfo> offers = protos.stream().map(p -> (OfferInfo) p).collect(Collectors.toList());
|
List<OfferInfo> offers = protos.stream().map(p -> (OfferInfo) p).collect(Collectors.toList());
|
||||||
return isShowingFiatOffers.get()
|
return isShowingTraditionalOffers.get()
|
||||||
? buildFiatOfferTable(offers)
|
? buildTraditionalOfferTable(offers)
|
||||||
: buildCryptoCurrencyOfferTable(offers);
|
: buildCryptoCurrencyOfferTable(offers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
public Table buildFiatOfferTable(List<OfferInfo> offers) {
|
public Table buildTraditionalOfferTable(List<OfferInfo> offers) {
|
||||||
@Nullable
|
@Nullable
|
||||||
Column<String> colEnabled = enabledColumn.get(); // Not boolean: "YES", "NO", or "PENDING"
|
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> colTraditionalPrice = new StringColumn(format(COL_HEADER_DETAILED_PRICE, traditionalTradeCurrency.get()), RIGHT);
|
||||||
Column<String> colVolume = new StringColumn(format("Temp Volume (%s)", fiatTradeCurrency.get()), NONE);
|
Column<String> colVolume = new StringColumn(format("Temp Volume (%s)", traditionalTradeCurrency.get()), NONE);
|
||||||
Column<String> colMinVolume = new StringColumn(format("Temp Min Volume (%s)", fiatTradeCurrency.get()), NONE);
|
Column<String> colMinVolume = new StringColumn(format("Temp Min Volume (%s)", traditionalTradeCurrency.get()), NONE);
|
||||||
@Nullable
|
@Nullable
|
||||||
Column<String> colTriggerPrice = fiatTriggerPriceColumn.get();
|
Column<String> colTriggerPrice = traditionalTriggerPriceColumn.get();
|
||||||
|
|
||||||
// Populate columns with offer info.
|
// Populate columns with offer info.
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
|||||||
colEnabled.addRow(toEnabled.apply(o));
|
colEnabled.addRow(toEnabled.apply(o));
|
||||||
|
|
||||||
colDirection.addRow(o.getDirection());
|
colDirection.addRow(o.getDirection());
|
||||||
colFiatPrice.addRow(o.getPrice());
|
colTraditionalPrice.addRow(o.getPrice());
|
||||||
colMinAmount.addRow(o.getMinAmount());
|
colMinAmount.addRow(o.getMinAmount());
|
||||||
colAmount.addRow(o.getAmount());
|
colAmount.addRow(o.getAmount());
|
||||||
colVolume.addRow(o.getVolume());
|
colVolume.addRow(o.getVolume());
|
||||||
@ -109,7 +109,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
|||||||
|
|
||||||
ZippedStringColumns amountRange = zippedAmountRangeColumns.get();
|
ZippedStringColumns amountRange = zippedAmountRangeColumns.get();
|
||||||
ZippedStringColumns volumeRange =
|
ZippedStringColumns volumeRange =
|
||||||
new ZippedStringColumns(format(COL_HEADER_VOLUME_RANGE, fiatTradeCurrency.get()),
|
new ZippedStringColumns(format(COL_HEADER_VOLUME_RANGE, traditionalTradeCurrency.get()),
|
||||||
RIGHT,
|
RIGHT,
|
||||||
" - ",
|
" - ",
|
||||||
colMinVolume.asStringColumn(),
|
colMinVolume.asStringColumn(),
|
||||||
@ -120,7 +120,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
|||||||
if (isShowingMyOffers.get()) {
|
if (isShowingMyOffers.get()) {
|
||||||
return new Table(colEnabled.asStringColumn(),
|
return new Table(colEnabled.asStringColumn(),
|
||||||
colDirection,
|
colDirection,
|
||||||
colFiatPrice.justify(),
|
colTraditionalPrice.justify(),
|
||||||
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
|
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||||
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
|
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||||
colTriggerPrice.justify(),
|
colTriggerPrice.justify(),
|
||||||
@ -129,7 +129,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
|||||||
colOfferId);
|
colOfferId);
|
||||||
} else {
|
} else {
|
||||||
return new Table(colDirection,
|
return new Table(colDirection,
|
||||||
colFiatPrice.justify(),
|
colTraditionalPrice.justify(),
|
||||||
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
|
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||||
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
|
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||||
colPaymentMethod,
|
colPaymentMethod,
|
||||||
@ -142,11 +142,11 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
|||||||
public Table buildCryptoCurrencyOfferTable(List<OfferInfo> offers) {
|
public Table buildCryptoCurrencyOfferTable(List<OfferInfo> offers) {
|
||||||
@Nullable
|
@Nullable
|
||||||
Column<String> colEnabled = enabledColumn.get(); // Not boolean: YES, NO, or PENDING
|
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> colBtcPrice = new StringColumn(format(COL_HEADER_DETAILED_PRICE_OF_CRYPTO, cryptoTradeCurrency.get()), RIGHT);
|
||||||
Column<String> colVolume = new StringColumn(format("Temp Volume (%s)", altcoinTradeCurrency.get()), NONE);
|
Column<String> colVolume = new StringColumn(format("Temp Volume (%s)", cryptoTradeCurrency.get()), NONE);
|
||||||
Column<String> colMinVolume = new StringColumn(format("Temp Min Volume (%s)", altcoinTradeCurrency.get()), NONE);
|
Column<String> colMinVolume = new StringColumn(format("Temp Min Volume (%s)", cryptoTradeCurrency.get()), NONE);
|
||||||
@Nullable
|
@Nullable
|
||||||
Column<String> colTriggerPrice = altcoinTriggerPriceColumn.get();
|
Column<String> colTriggerPrice = cryptoTriggerPriceColumn.get();
|
||||||
|
|
||||||
// Populate columns with offer info.
|
// Populate columns with offer info.
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
|||||||
|
|
||||||
ZippedStringColumns amountRange = zippedAmountRangeColumns.get();
|
ZippedStringColumns amountRange = zippedAmountRangeColumns.get();
|
||||||
ZippedStringColumns volumeRange =
|
ZippedStringColumns volumeRange =
|
||||||
new ZippedStringColumns(format(COL_HEADER_VOLUME_RANGE, altcoinTradeCurrency.get()),
|
new ZippedStringColumns(format(COL_HEADER_VOLUME_RANGE, cryptoTradeCurrency.get()),
|
||||||
RIGHT,
|
RIGHT,
|
||||||
" - ",
|
" - ",
|
||||||
colMinVolume.asStringColumn(),
|
colMinVolume.asStringColumn(),
|
||||||
@ -214,11 +214,11 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
|||||||
private final Function<String, String> toBlankOrNonZeroValue = (s) -> s.trim().equals("0") ? "" : s;
|
private final Function<String, String> toBlankOrNonZeroValue = (s) -> s.trim().equals("0") ? "" : s;
|
||||||
private final Supplier<OfferInfo> firstOfferInList = () -> (OfferInfo) protos.get(0);
|
private final Supplier<OfferInfo> firstOfferInList = () -> (OfferInfo) protos.get(0);
|
||||||
private final Supplier<Boolean> isShowingMyOffers = () -> firstOfferInList.get().getIsMyOffer();
|
private final Supplier<Boolean> isShowingMyOffers = () -> firstOfferInList.get().getIsMyOffer();
|
||||||
private final Supplier<Boolean> isShowingFiatOffers = () -> isFiatOffer.test(firstOfferInList.get());
|
private final Supplier<Boolean> isShowingTraditionalOffers = () -> isTraditionalOffer.test(firstOfferInList.get());
|
||||||
private final Supplier<String> fiatTradeCurrency = () -> firstOfferInList.get().getCounterCurrencyCode();
|
private final Supplier<String> traditionalTradeCurrency = () -> firstOfferInList.get().getCounterCurrencyCode();
|
||||||
private final Supplier<String> altcoinTradeCurrency = () -> firstOfferInList.get().getBaseCurrencyCode();
|
private final Supplier<String> cryptoTradeCurrency = () -> firstOfferInList.get().getBaseCurrencyCode();
|
||||||
private final Supplier<Boolean> isShowingBsqOffers = () ->
|
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.
|
@Nullable // Not a boolean column: YES, NO, or PENDING.
|
||||||
private final Supplier<StringColumn> enabledColumn = () ->
|
private final Supplier<StringColumn> enabledColumn = () ->
|
||||||
@ -226,14 +226,14 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
|||||||
? new StringColumn(COL_HEADER_ENABLED, LEFT)
|
? new StringColumn(COL_HEADER_ENABLED, LEFT)
|
||||||
: null;
|
: null;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Supplier<StringColumn> fiatTriggerPriceColumn = () ->
|
private final Supplier<StringColumn> traditionalTriggerPriceColumn = () ->
|
||||||
isShowingMyOffers.get()
|
isShowingMyOffers.get()
|
||||||
? new StringColumn(format(COL_HEADER_TRIGGER_PRICE, fiatTradeCurrency.get()), RIGHT)
|
? new StringColumn(format(COL_HEADER_TRIGGER_PRICE, traditionalTradeCurrency.get()), RIGHT)
|
||||||
: null;
|
: null;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Supplier<StringColumn> altcoinTriggerPriceColumn = () ->
|
private final Supplier<StringColumn> cryptoTriggerPriceColumn = () ->
|
||||||
isShowingMyOffers.get() && !isShowingBsqOffers.get()
|
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;
|
: null;
|
||||||
|
|
||||||
private final Function<OfferInfo, String> toEnabled = (o) -> {
|
private final Function<OfferInfo, String> toEnabled = (o) -> {
|
||||||
@ -244,7 +244,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
|||||||
d.equalsIgnoreCase(BUY.name()) ? SELL.name() : BUY.name();
|
d.equalsIgnoreCase(BUY.name()) ? SELL.name() : BUY.name();
|
||||||
|
|
||||||
private final Function<OfferInfo, String> directionFormat = (o) -> {
|
private final Function<OfferInfo, String> directionFormat = (o) -> {
|
||||||
if (isFiatOffer.test(o)) {
|
if (isTraditionalOffer.test(o)) {
|
||||||
return o.getBaseCurrencyCode();
|
return o.getBaseCurrencyCode();
|
||||||
} else {
|
} else {
|
||||||
// Return "Sell BSQ (Buy BTC)", or "Buy BSQ (Sell BTC)".
|
// 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_DATE_TIME = "Date/Time (UTC)";
|
||||||
static final String COL_HEADER_DETAILED_AMOUNT = "Amount(%-3s)";
|
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 = "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_DIRECTION = "Buy/Sell";
|
||||||
static final String COL_HEADER_ENABLED = "Enabled";
|
static final String COL_HEADER_ENABLED = "Enabled";
|
||||||
static final String COL_HEADER_MARKET = "Market";
|
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_PAYMENT_METHOD = "Payment Method";
|
||||||
static final String COL_HEADER_PRICE = "Price";
|
static final String COL_HEADER_PRICE = "Price";
|
||||||
static final String COL_HEADER_STATUS = "Status";
|
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_BUYER_COST = "Buyer Cost(%-3s)";
|
||||||
static final String COL_HEADER_TRADE_DEPOSIT_CONFIRMED = "Deposit Confirmed";
|
static final String COL_HEADER_TRADE_DEPOSIT_CONFIRMED = "Deposit Confirmed";
|
||||||
static final String COL_HEADER_TRADE_DEPOSIT_PUBLISHED = "Deposit Published";
|
static final String COL_HEADER_TRADE_DEPOSIT_PUBLISHED = "Deposit Published";
|
||||||
|
@ -66,8 +66,8 @@ class TradeDetailTableBuilder extends AbstractTradeListBuilder {
|
|||||||
colIsPaymentReceivedMessageSent.addRow(trade.getIsPaymentReceived());
|
colIsPaymentReceivedMessageSent.addRow(trade.getIsPaymentReceived());
|
||||||
colIsPayoutPublished.addRow(trade.getIsPayoutPublished());
|
colIsPayoutPublished.addRow(trade.getIsPayoutPublished());
|
||||||
colIsCompleted.addRow(trade.getIsCompleted());
|
colIsCompleted.addRow(trade.getIsCompleted());
|
||||||
if (colAltcoinReceiveAddressColumn != null)
|
if (colCryptoReceiveAddressColumn != null)
|
||||||
colAltcoinReceiveAddressColumn.addRow(toAltcoinReceiveAddress.apply(trade));
|
colCryptoReceiveAddressColumn.addRow(toCryptoReceiveAddress.apply(trade));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Column<?>> defineColumnList(TradeInfo trade) {
|
private List<Column<?>> defineColumnList(TradeInfo trade) {
|
||||||
@ -90,8 +90,8 @@ class TradeDetailTableBuilder extends AbstractTradeListBuilder {
|
|||||||
add(colIsCompleted.asStringColumn());
|
add(colIsCompleted.asStringColumn());
|
||||||
}};
|
}};
|
||||||
|
|
||||||
if (colAltcoinReceiveAddressColumn != null)
|
if (colCryptoReceiveAddressColumn != null)
|
||||||
columns.add(colAltcoinReceiveAddressColumn);
|
columns.add(colCryptoReceiveAddressColumn);
|
||||||
|
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package haveno.cli.table.builder;
|
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.BooleanColumn;
|
||||||
import haveno.cli.table.column.BtcColumn;
|
import haveno.cli.table.column.BtcColumn;
|
||||||
import haveno.cli.table.column.Column;
|
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_DATE_TIME;
|
||||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_DETAILED_AMOUNT;
|
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;
|
||||||
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_DEVIATION;
|
||||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_MARKET;
|
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_OFFER_TYPE;
|
||||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_PAYMENT_METHOD;
|
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_PRICE;
|
||||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_STATUS;
|
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_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_CONFIRMED;
|
||||||
import static haveno.cli.table.builder.TableBuilderConstants.COL_HEADER_TRADE_DEPOSIT_PUBLISHED;
|
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.FAILED_TRADES_TBL;
|
||||||
import static haveno.cli.table.builder.TableType.OPEN_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.builder.TableType.TRADE_DETAIL_TBL;
|
||||||
import static haveno.cli.table.column.AltcoinVolumeColumn.DISPLAY_MODE.ALTCOIN_VOLUME;
|
import static haveno.cli.table.column.CryptoVolumeColumn.DISPLAY_MODE.CRYPTO_VOLUME;
|
||||||
import static haveno.cli.table.column.AltcoinVolumeColumn.DISPLAY_MODE.BSQ_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.LEFT;
|
||||||
import static haveno.cli.table.column.Column.JUSTIFICATION.RIGHT;
|
import static haveno.cli.table.column.Column.JUSTIFICATION.RIGHT;
|
||||||
import static java.lang.String.format;
|
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> isClosedTradeTblBuilder = () -> getTableType().equals(CLOSED_TRADES_TBL);
|
||||||
private final Supplier<Boolean> isFailedTradeTblBuilder = () -> getTableType().equals(FAILED_TRADES_TBL);
|
private final Supplier<Boolean> isFailedTradeTblBuilder = () -> getTableType().equals(FAILED_TRADES_TBL);
|
||||||
private final Supplier<TradeInfo> firstRow = () -> getTrades().get(0);
|
private final Supplier<TradeInfo> firstRow = () -> getTrades().get(0);
|
||||||
private final Predicate<OfferInfo> isFiatOffer = (o) -> o.getBaseCurrencyCode().equals("BTC");
|
private final Predicate<OfferInfo> isTraditionalOffer = (o) -> o.getBaseCurrencyCode().equals("XMR");
|
||||||
private final Predicate<TradeInfo> isFiatTrade = (t) -> isFiatOffer.test(t.getOffer());
|
private final Predicate<TradeInfo> isTraditionalTrade = (t) -> isTraditionalOffer.test(t.getOffer());
|
||||||
private final Predicate<TradeInfo> isTaker = (t) -> t.getRole().toLowerCase().contains("taker");
|
private final Predicate<TradeInfo> isTaker = (t) -> t.getRole().toLowerCase().contains("taker");
|
||||||
|
|
||||||
final Supplier<StringColumn> tradeIdColumn = () -> isTradeDetailTblBuilder.get()
|
final Supplier<StringColumn> tradeIdColumn = () -> isTradeDetailTblBuilder.get()
|
||||||
@ -114,9 +114,9 @@ class TradeTableColumnSupplier {
|
|||||||
: new StringColumn(COL_HEADER_MARKET);
|
: new StringColumn(COL_HEADER_MARKET);
|
||||||
|
|
||||||
private final Function<TradeInfo, Column<String>> toDetailedPriceColumn = (t) -> {
|
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, 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);
|
return new StringColumn(colHeader, RIGHT);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,13 +135,13 @@ class TradeTableColumnSupplier {
|
|||||||
private final Function<TradeInfo, Column<Long>> toDetailedAmountColumn = (t) -> {
|
private final Function<TradeInfo, Column<Long>> toDetailedAmountColumn = (t) -> {
|
||||||
String headerCurrencyCode = t.getOffer().getBaseCurrencyCode();
|
String headerCurrencyCode = t.getOffer().getBaseCurrencyCode();
|
||||||
String colHeader = format(COL_HEADER_DETAILED_AMOUNT, headerCurrencyCode);
|
String colHeader = format(COL_HEADER_DETAILED_AMOUNT, headerCurrencyCode);
|
||||||
AltcoinVolumeColumn.DISPLAY_MODE displayMode = headerCurrencyCode.equals("BSQ") ? BSQ_VOLUME : ALTCOIN_VOLUME;
|
CryptoVolumeColumn.DISPLAY_MODE displayMode = headerCurrencyCode.equals("BSQ") ? BSQ_VOLUME : CRYPTO_VOLUME;
|
||||||
return isFiatTrade.test(t)
|
return isTraditionalTrade.test(t)
|
||||||
? new SatoshiColumn(colHeader)
|
? 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.
|
// in the displayed string representation is done in the Column implementation.
|
||||||
final Supplier<Column<Long>> amountColumn = () -> isTradeDetailTblBuilder.get()
|
final Supplier<Column<Long>> amountColumn = () -> isTradeDetailTblBuilder.get()
|
||||||
? toDetailedAmountColumn.apply(firstRow.get())
|
? toDetailedAmountColumn.apply(firstRow.get())
|
||||||
@ -222,7 +222,7 @@ class TradeTableColumnSupplier {
|
|||||||
};
|
};
|
||||||
|
|
||||||
final Function<TradeInfo, String> toPaymentCurrencyCode = (t) ->
|
final Function<TradeInfo, String> toPaymentCurrencyCode = (t) ->
|
||||||
isFiatTrade.test(t)
|
isTraditionalTrade.test(t)
|
||||||
? t.getOffer().getCounterCurrencyCode()
|
? t.getOffer().getCounterCurrencyCode()
|
||||||
: t.getOffer().getBaseCurrencyCode();
|
: t.getOffer().getBaseCurrencyCode();
|
||||||
|
|
||||||
@ -257,8 +257,8 @@ class TradeTableColumnSupplier {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final Predicate<TradeInfo> showAltCoinBuyerAddress = (t) -> {
|
final Predicate<TradeInfo> showCryptoBuyerAddress = (t) -> {
|
||||||
if (isFiatTrade.test(t)) {
|
if (isTraditionalTrade.test(t)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
ContractInfo contract = t.getContract();
|
ContractInfo contract = t.getContract();
|
||||||
@ -272,12 +272,12 @@ class TradeTableColumnSupplier {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
final Supplier<Column<String>> altcoinReceiveAddressColumn = () -> {
|
final Supplier<Column<String>> cryptoReceiveAddressColumn = () -> {
|
||||||
if (isTradeDetailTblBuilder.get()) {
|
if (isTradeDetailTblBuilder.get()) {
|
||||||
TradeInfo t = firstRow.get();
|
TradeInfo t = firstRow.get();
|
||||||
if (showAltCoinBuyerAddress.test(t)) {
|
if (showCryptoBuyerAddress.test(t)) {
|
||||||
String headerCurrencyCode = toPaymentCurrencyCode.apply(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);
|
return new StringColumn(colHeader);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -24,23 +24,23 @@ import java.util.stream.IntStream;
|
|||||||
import static haveno.cli.table.column.Column.JUSTIFICATION.RIGHT;
|
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 {
|
public enum DISPLAY_MODE {
|
||||||
ALTCOIN_VOLUME,
|
CRYPTO_VOLUME,
|
||||||
BSQ_VOLUME,
|
BSQ_VOLUME,
|
||||||
}
|
}
|
||||||
|
|
||||||
private final DISPLAY_MODE displayMode;
|
private final DISPLAY_MODE displayMode;
|
||||||
|
|
||||||
// The default AltcoinVolumeColumn JUSTIFICATION is RIGHT.
|
// The default CryptoVolumeColumn JUSTIFICATION is RIGHT.
|
||||||
public AltcoinVolumeColumn(String name, DISPLAY_MODE displayMode) {
|
public CryptoVolumeColumn(String name, DISPLAY_MODE displayMode) {
|
||||||
this(name, RIGHT, displayMode);
|
this(name, RIGHT, displayMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltcoinVolumeColumn(String name,
|
public CryptoVolumeColumn(String name,
|
||||||
JUSTIFICATION justification,
|
JUSTIFICATION justification,
|
||||||
DISPLAY_MODE displayMode) {
|
DISPLAY_MODE displayMode) {
|
||||||
super(name, justification);
|
super(name, justification);
|
||||||
@ -65,7 +65,7 @@ public class AltcoinVolumeColumn extends LongColumn {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringColumn asStringColumn() {
|
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.
|
// not know how much padding each string needed until now.
|
||||||
IntStream.range(0, stringColumn.getRows().size()).forEach(rowIndex -> {
|
IntStream.range(0, stringColumn.getRows().size()).forEach(rowIndex -> {
|
||||||
String unjustified = stringColumn.getRow(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) -> {
|
private final BiFunction<Long, DISPLAY_MODE, String> toFormattedString = (value, displayMode) -> {
|
||||||
switch (displayMode) {
|
switch (displayMode) {
|
||||||
case ALTCOIN_VOLUME:
|
case CRYPTO_VOLUME:
|
||||||
return value > 0 ? new BigDecimal(value).movePointLeft(8).toString() : "";
|
return value > 0 ? new BigDecimal(value).movePointLeft(8).toString() : "";
|
||||||
case BSQ_VOLUME:
|
case BSQ_VOLUME:
|
||||||
return value > 0 ? new BigDecimal(value).movePointLeft(2).toString() : "";
|
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)
|
.map(Object::toString)
|
||||||
.collect(Collectors.toList());
|
.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();
|
String random = Double.valueOf(ThreadLocalRandom.current().nextDouble(min, max)).toString();
|
||||||
BigDecimal bd = new BigDecimal(random).setScale(8, HALF_UP);
|
BigDecimal bd = new BigDecimal(random).setScale(8, HALF_UP);
|
||||||
return bd.toPlainString();
|
return bd.toPlainString();
|
||||||
@ -114,7 +114,7 @@ public abstract class AbstractCliTest {
|
|||||||
log.info("NEW Console OUT:\n{}", tbl);
|
log.info("NEW Console OUT:\n{}", tbl);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<OfferInfo> getMyAltcoinOffers(String currencyCode) {
|
protected List<OfferInfo> getMyCryptoOffers(String currencyCode) {
|
||||||
String[] args = getMyOffersCommand("buy", currencyCode);
|
String[] args = getMyOffersCommand("buy", currencyCode);
|
||||||
out.print(">>>>> haveno-cli ");
|
out.print(">>>>> haveno-cli ");
|
||||||
stream(args).forEach(a -> out.print(a + " "));
|
stream(args).forEach(a -> out.print(a + " "));
|
||||||
|
@ -28,16 +28,16 @@ public class EditXmrOffersSmokeTest extends AbstractCliTest {
|
|||||||
|
|
||||||
test.doOfferPriceEdits();
|
test.doOfferPriceEdits();
|
||||||
|
|
||||||
List<OfferInfo> offers = test.getMyAltcoinOffers("xmr");
|
List<OfferInfo> offers = test.getMyCryptoOffers("xmr");
|
||||||
test.disableOffers(offers);
|
test.disableOffers(offers);
|
||||||
|
|
||||||
test.sleep(6);
|
test.sleep(6);
|
||||||
|
|
||||||
offers = test.getMyAltcoinOffers("xmr");
|
offers = test.getMyCryptoOffers("xmr");
|
||||||
test.enableOffers(offers);
|
test.enableOffers(offers);
|
||||||
|
|
||||||
// A final look after last edit.
|
// A final look after last edit.
|
||||||
test.getMyAltcoinOffers("xmr");
|
test.getMyCryptoOffers("xmr");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doOfferPriceEdits() {
|
private void doOfferPriceEdits() {
|
||||||
@ -48,7 +48,7 @@ public class EditXmrOffersSmokeTest extends AbstractCliTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void editPriceMargin() {
|
private void editPriceMargin() {
|
||||||
var offers = getMyAltcoinOffers("xmr");
|
var offers = getMyCryptoOffers("xmr");
|
||||||
out.println("Edit XMR offers' price margin");
|
out.println("Edit XMR offers' price margin");
|
||||||
var margins = randomMarginBasedPrices.apply(-301, 300);
|
var margins = randomMarginBasedPrices.apply(-301, 300);
|
||||||
for (int i = 0; i < offers.size(); i++) {
|
for (int i = 0; i < offers.size(); i++) {
|
||||||
@ -59,7 +59,7 @@ public class EditXmrOffersSmokeTest extends AbstractCliTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void editTriggerPrice() {
|
private void editTriggerPrice() {
|
||||||
var offers = getMyAltcoinOffers("xmr");
|
var offers = getMyCryptoOffers("xmr");
|
||||||
out.println("Edit XMR offers' trigger price");
|
out.println("Edit XMR offers' trigger price");
|
||||||
for (int i = 0; i < offers.size(); i++) {
|
for (int i = 0; i < offers.size(); i++) {
|
||||||
var offer = offers.get(i);
|
var offer = offers.get(i);
|
||||||
@ -74,7 +74,7 @@ public class EditXmrOffersSmokeTest extends AbstractCliTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void editPriceMarginAndTriggerPrice() {
|
private void editPriceMarginAndTriggerPrice() {
|
||||||
var offers = getMyAltcoinOffers("xmr");
|
var offers = getMyCryptoOffers("xmr");
|
||||||
out.println("Edit XMR offers' price margin and trigger price");
|
out.println("Edit XMR offers' price margin and trigger price");
|
||||||
for (int i = 0; i < offers.size(); i++) {
|
for (int i = 0; i < offers.size(); i++) {
|
||||||
var offer = offers.get(i);
|
var offer = offers.get(i);
|
||||||
@ -89,10 +89,10 @@ public class EditXmrOffersSmokeTest extends AbstractCliTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void editFixedPrice() {
|
private void editFixedPrice() {
|
||||||
var offers = getMyAltcoinOffers("xmr");
|
var offers = getMyCryptoOffers("xmr");
|
||||||
out.println("Edit XMR offers' fixed price");
|
out.println("Edit XMR offers' fixed price");
|
||||||
for (int i = 0; i < offers.size(); i++) {
|
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());
|
editOfferFixedPrice(offers.get(i), randomFixedPrice, new Random().nextBoolean());
|
||||||
sleep(5);
|
sleep(5);
|
||||||
}
|
}
|
||||||
|
@ -210,16 +210,16 @@ public class AccountAgeWitnessService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onBootStrapped() {
|
private void onBootStrapped() {
|
||||||
republishAllFiatAccounts();
|
republishAllTraditionalAccounts();
|
||||||
signAndPublishSameNameAccounts();
|
signAndPublishSameNameAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// At startup we re-publish the witness data of all fiat accounts to ensure we got our data well distributed.
|
// At startup we re-publish the witness data of all traditional accounts to ensure we got our data well distributed.
|
||||||
private void republishAllFiatAccounts() {
|
private void republishAllTraditionalAccounts() {
|
||||||
if (user.getPaymentAccounts() != null)
|
if (user.getPaymentAccounts() != null)
|
||||||
user.getPaymentAccounts().stream()
|
user.getPaymentAccounts().stream()
|
||||||
.filter(account -> account.getPaymentMethod().isFiat())
|
.filter(account -> account.getPaymentMethod().isTraditional())
|
||||||
.forEach(account -> {
|
.forEach(account -> {
|
||||||
AccountAgeWitness myWitness = getMyWitness(account.getPaymentAccountPayload());
|
AccountAgeWitness myWitness = getMyWitness(account.getPaymentAccountPayload());
|
||||||
// We only publish if the date of our witness is inside the date tolerance.
|
// 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.crypto.KeyRing;
|
||||||
import haveno.common.handlers.ErrorMessageHandler;
|
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.Price;
|
||||||
|
import haveno.core.monetary.TraditionalMoney;
|
||||||
import haveno.core.offer.CreateOfferService;
|
import haveno.core.offer.CreateOfferService;
|
||||||
import haveno.core.offer.Offer;
|
import haveno.core.offer.Offer;
|
||||||
import haveno.core.offer.OfferBookService;
|
import haveno.core.offer.OfferBookService;
|
||||||
@ -35,7 +37,6 @@ import haveno.core.user.User;
|
|||||||
import haveno.core.util.PriceUtil;
|
import haveno.core.util.PriceUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bitcoinj.core.Transaction;
|
import org.bitcoinj.core.Transaction;
|
||||||
import org.bitcoinj.utils.Fiat;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
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.exactMultiply;
|
||||||
import static haveno.common.util.MathUtils.roundDoubleToLong;
|
import static haveno.common.util.MathUtils.roundDoubleToLong;
|
||||||
import static haveno.common.util.MathUtils.scaleUpByPowerOf10;
|
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.offer.OfferDirection.BUY;
|
||||||
import static haveno.core.payment.PaymentAccountUtil.isPaymentAccountValidForOffer;
|
import static haveno.core.payment.PaymentAccountUtil.isPaymentAccountValidForOffer;
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.format;
|
||||||
@ -285,7 +285,7 @@ public class CoreOffersService {
|
|||||||
if ("".equals(direction)) direction = null;
|
if ("".equals(direction)) direction = null;
|
||||||
if ("".equals(currencyCode)) currencyCode = null;
|
if ("".equals(currencyCode)) currencyCode = null;
|
||||||
var offerOfWantedDirection = direction == null || offer.getDirection().name().equalsIgnoreCase(direction);
|
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);
|
var offerInWantedCurrency = currencyCode == null || counterAssetCode.equalsIgnoreCase(currencyCode);
|
||||||
return offerOfWantedDirection && offerInWantedCurrency;
|
return offerOfWantedDirection && offerInWantedCurrency;
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class CoreOffersService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private long priceStringToLong(String priceAsString, String currencyCode) {
|
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 priceAsDouble = new BigDecimal(priceAsString).doubleValue();
|
||||||
double scaled = scaleUpByPowerOf10(priceAsDouble, precision);
|
double scaled = scaleUpByPowerOf10(priceAsDouble, precision);
|
||||||
return roundDoubleToLong(scaled);
|
return roundDoubleToLong(scaled);
|
||||||
|
@ -153,7 +153,7 @@ class CorePaymentAccountsService {
|
|||||||
|
|
||||||
List<PaymentMethod> getCryptoCurrencyPaymentMethods() {
|
List<PaymentMethod> getCryptoCurrencyPaymentMethods() {
|
||||||
return PaymentMethod.getPaymentMethods().stream()
|
return PaymentMethod.getPaymentMethods().stream()
|
||||||
.filter(PaymentMethod::isAltcoin)
|
.filter(PaymentMethod::isCrypto)
|
||||||
.sorted(Comparator.comparing(PaymentMethod::getId))
|
.sorted(Comparator.comparing(PaymentMethod::getId))
|
||||||
.collect(Collectors.toList());
|
.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 {
|
public double getMarketPrice(String currencyCode) throws ExecutionException, InterruptedException, TimeoutException, IllegalArgumentException {
|
||||||
var marketPrice = priceFeedService.requestAllPrices().get(currencyCode);
|
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 {
|
public List<MarketPriceInfo> getMarketPrices() throws ExecutionException, InterruptedException, TimeoutException {
|
||||||
return priceFeedService.requestAllPrices().values().stream()
|
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.
|
// 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()));
|
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
|
// Trading xmr-traditional is considered as buying/selling XMR, but trading xmr-crypto is
|
||||||
// considered as buying/selling Altcoin. Because of this, when viewing a btc-altcoin pair,
|
// 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
|
// the buy column is actually the sell column and vice versa. To maintain the expected
|
||||||
// ordering, we have to reverse the price comparator.
|
// ordering, we have to reverse the price comparator.
|
||||||
boolean isCrypto = CurrencyUtil.isCryptoCurrency(currencyCode);
|
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
|
* e.g. 1 XMR = X USD
|
||||||
* but 1 DOGE = X XMR
|
* but 1 DOGE = X XMR
|
||||||
* Here we convert all to:
|
* Here we convert all to:
|
||||||
* 1 XMR = X (FIAT or CRYPTO)
|
* 1 XMR = X (FIAT or CRYPTO)
|
||||||
*/
|
*/
|
||||||
private double mapPriceFeedServicePrice(double price, String currencyCode) {
|
private double mapPriceFeedServicePrice(double price, String currencyCode) {
|
||||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
return price == 0 ? 0 : 1 / price;
|
return price == 0 ? 0 : 1 / price;
|
||||||
|
@ -62,8 +62,8 @@ public class OfferInfo implements Payload {
|
|||||||
private final String paymentAccountId;
|
private final String paymentAccountId;
|
||||||
private final String paymentMethodId;
|
private final String paymentMethodId;
|
||||||
private final String paymentMethodShortName;
|
private final String paymentMethodShortName;
|
||||||
// For fiat offer the baseCurrencyCode is BTC and the counterCurrencyCode is the fiat currency
|
// For traditional offer the baseCurrencyCode is XMR and the counterCurrencyCode is the traditional currency
|
||||||
// For altcoin offers it is the opposite. baseCurrencyCode is the altcoin and the counterCurrencyCode is BTC.
|
// For crypto offers it is the opposite. baseCurrencyCode is the crypto and the counterCurrencyCode is XMR.
|
||||||
private final String baseCurrencyCode;
|
private final String baseCurrencyCode;
|
||||||
private final String counterCurrencyCode;
|
private final String counterCurrencyCode;
|
||||||
private final long date;
|
private final long date;
|
||||||
|
@ -17,18 +17,19 @@
|
|||||||
|
|
||||||
package haveno.core.locale;
|
package haveno.core.locale;
|
||||||
|
|
||||||
|
import haveno.core.monetary.TraditionalMoney;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
public class CurrencyTuple {
|
public class CurrencyTuple {
|
||||||
public final String code;
|
public final String code;
|
||||||
public final String name;
|
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) {
|
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
|
// 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) {
|
public CurrencyTuple(String code, String name, int precision) {
|
||||||
|
@ -56,16 +56,16 @@ public class CurrencyUtil {
|
|||||||
|
|
||||||
private static String baseCurrencyCode = "XMR";
|
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 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%
|
// 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
|
// 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 Map<String, Boolean> isCryptoCurrencyMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private static final Supplier<Map<String, FiatCurrency>> fiatCurrencyMapSupplier = Suppliers.memoize(
|
private static final Supplier<Map<String, TraditionalCurrency>> traditionalCurrencyMapSupplier = Suppliers.memoize(
|
||||||
CurrencyUtil::createFiatCurrencyMap);
|
CurrencyUtil::createTraditionalCurrencyMap);
|
||||||
private static final Supplier<Map<String, CryptoCurrency>> cryptoCurrencyMapSupplier = Suppliers.memoize(
|
private static final Supplier<Map<String, CryptoCurrency>> cryptoCurrencyMapSupplier = Suppliers.memoize(
|
||||||
CurrencyUtil::createCryptoCurrencyMap);
|
CurrencyUtil::createCryptoCurrencyMap);
|
||||||
|
|
||||||
@ -73,48 +73,52 @@ public class CurrencyUtil {
|
|||||||
CurrencyUtil.baseCurrencyCode = baseCurrencyCode;
|
CurrencyUtil.baseCurrencyCode = baseCurrencyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<FiatCurrency> getAllSortedFiatCurrencies() {
|
public static Collection<TraditionalCurrency> getAllSortedTraditionalCurrencies() {
|
||||||
return fiatCurrencyMapSupplier.get().values(); // sorted by currency name
|
return traditionalCurrencyMapSupplier.get().values(); // sorted by currency name
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<TradeCurrency> getAllFiatCurrencies() {
|
public static List<TradeCurrency> getAllTraditionalCurrencies() {
|
||||||
return new ArrayList<>(fiatCurrencyMapSupplier.get().values());
|
return new ArrayList<>(traditionalCurrencyMapSupplier.get().values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<FiatCurrency> getAllSortedFiatCurrencies(Comparator comparator) {
|
public static Collection<TraditionalCurrency> getAllSortedTraditionalCurrencies(Comparator comparator) {
|
||||||
return (List<FiatCurrency>) getAllSortedFiatCurrencies().stream()
|
return (List<TraditionalCurrency>) getAllSortedTraditionalCurrencies().stream()
|
||||||
.sorted(comparator) // sorted by comparator param
|
.sorted(comparator) // sorted by comparator param
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, FiatCurrency> createFiatCurrencyMap() {
|
private static Map<String, TraditionalCurrency> createTraditionalCurrencyMap() {
|
||||||
return CountryUtil.getAllCountries().stream()
|
List<TraditionalCurrency> currencies = CountryUtil.getAllCountries().stream()
|
||||||
.map(country -> getCurrencyByCountryCode(country.code))
|
.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()
|
.distinct()
|
||||||
.collect(Collectors.toMap(TradeCurrency::getCode, Function.identity(), (x, y) -> x, LinkedHashMap::new));
|
.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();
|
TradeCurrency defaultTradeCurrency = getDefaultTradeCurrency();
|
||||||
List<FiatCurrency> list = new ArrayList<>();
|
List<TraditionalCurrency> list = new ArrayList<>();
|
||||||
// Top traded currencies
|
list.add(new TraditionalCurrency("USD"));
|
||||||
list.add(new FiatCurrency("USD"));
|
list.add(new TraditionalCurrency("EUR"));
|
||||||
list.add(new FiatCurrency("EUR"));
|
list.add(new TraditionalCurrency("GBP"));
|
||||||
list.add(new FiatCurrency("GBP"));
|
list.add(new TraditionalCurrency("CAD"));
|
||||||
list.add(new FiatCurrency("CAD"));
|
list.add(new TraditionalCurrency("AUD"));
|
||||||
list.add(new FiatCurrency("AUD"));
|
list.add(new TraditionalCurrency("RUB"));
|
||||||
list.add(new FiatCurrency("RUB"));
|
list.add(new TraditionalCurrency("INR"));
|
||||||
list.add(new FiatCurrency("INR"));
|
list.add(new TraditionalCurrency("NGN"));
|
||||||
list.add(new FiatCurrency("NGN"));
|
list.add(new TraditionalCurrency("XAG"));
|
||||||
|
list.add(new TraditionalCurrency("XAU"));
|
||||||
|
|
||||||
list.sort(TradeCurrency::compareTo);
|
list.sort(TradeCurrency::compareTo);
|
||||||
|
|
||||||
FiatCurrency defaultFiatCurrency =
|
TraditionalCurrency defaultTraditionalCurrency =
|
||||||
defaultTradeCurrency instanceof FiatCurrency ? (FiatCurrency) defaultTradeCurrency : null;
|
defaultTradeCurrency instanceof TraditionalCurrency ? (TraditionalCurrency) defaultTradeCurrency : null;
|
||||||
if (defaultFiatCurrency != null && list.contains(defaultFiatCurrency)) {
|
if (defaultTraditionalCurrency != null && list.contains(defaultTraditionalCurrency)) {
|
||||||
list.remove(defaultTradeCurrency);
|
list.remove(defaultTradeCurrency);
|
||||||
list.add(0, defaultFiatCurrency);
|
list.add(0, defaultTraditionalCurrency);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -165,53 +169,59 @@ public class CurrencyUtil {
|
|||||||
|
|
||||||
public static List<TradeCurrency> getMatureMarketCurrencies() {
|
public static List<TradeCurrency> getMatureMarketCurrencies() {
|
||||||
ArrayList<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
|
ArrayList<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("USD"),
|
new TraditionalCurrency("USD"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("CAD"),
|
new TraditionalCurrency("CAD"),
|
||||||
new FiatCurrency("AUD"),
|
new TraditionalCurrency("AUD"),
|
||||||
new FiatCurrency("BRL")
|
new TraditionalCurrency("BRL")
|
||||||
));
|
));
|
||||||
currencies.sort(Comparator.comparing(TradeCurrency::getCode));
|
currencies.sort(Comparator.comparing(TradeCurrency::getCode));
|
||||||
return currencies;
|
return currencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFiatCurrency(String currencyCode) {
|
public static boolean isFiatCurrency(String currencyCode) {
|
||||||
if (currencyCode != null && isFiatCurrencyMap.containsKey(currencyCode)) {
|
if (!isTraditionalCurrency(currencyCode)) return false;
|
||||||
return isFiatCurrencyMap.get(currencyCode);
|
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 {
|
try {
|
||||||
boolean isFiatCurrency = currencyCode != null
|
boolean isTraditionalCurrency = currencyCode != null
|
||||||
&& !currencyCode.isEmpty()
|
&& !currencyCode.isEmpty()
|
||||||
&& !isCryptoCurrency(currencyCode)
|
&& !isCryptoCurrency(currencyCode)
|
||||||
&& Currency.getInstance(currencyCode) != null;
|
&& Currency.getInstance(currencyCode) != null;
|
||||||
|
|
||||||
if (currencyCode != null) {
|
if (currencyCode != null) {
|
||||||
isFiatCurrencyMap.put(currencyCode, isFiatCurrency);
|
isTraditionalCurrencyMap.put(currencyCode, isTraditionalCurrency);
|
||||||
}
|
}
|
||||||
|
|
||||||
return isFiatCurrency;
|
return isTraditionalCurrency;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
isFiatCurrencyMap.put(currencyCode, false);
|
isTraditionalCurrencyMap.put(currencyCode, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<FiatCurrency> getFiatCurrency(String currencyCode) {
|
public static Optional<TraditionalCurrency> getTraditionalCurrency(String currencyCode) {
|
||||||
return Optional.ofNullable(fiatCurrencyMapSupplier.get().get(currencyCode));
|
return Optional.ofNullable(traditionalCurrencyMapSupplier.get().get(currencyCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We return true if it is BTC or any of our currencies available in the assetRegistry.
|
* 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.
|
* 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 Fiat if not found
|
* 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 fiat currency for the code.
|
* 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
|
* 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
|
* 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) {
|
public static boolean isCryptoCurrency(String currencyCode) {
|
||||||
if (currencyCode != null) currencyCode = currencyCode.toUpperCase();
|
if (currencyCode != null) currencyCode = currencyCode.toUpperCase();
|
||||||
@ -230,14 +240,14 @@ public class CurrencyUtil {
|
|||||||
} else if (getCryptoCurrency(currencyCode).isPresent()) {
|
} else if (getCryptoCurrency(currencyCode).isPresent()) {
|
||||||
// If we find the code in our assetRegistry we return true.
|
// 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 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;
|
isCryptoCurrency = true;
|
||||||
} else if (getFiatCurrency(currencyCode).isEmpty()) {
|
} else if (getTraditionalCurrency(currencyCode).isEmpty()) {
|
||||||
// In case the code is from a removed asset we cross check if there exist a fiat currency with that code,
|
// 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 fiat currency we treat it as a crypto currency.
|
// if we don't find a traditional currency we treat it as a crypto currency.
|
||||||
isCryptoCurrency = true;
|
isCryptoCurrency = true;
|
||||||
} else {
|
} 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;
|
isCryptoCurrency = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,9 +263,9 @@ public class CurrencyUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<TradeCurrency> getTradeCurrency(String currencyCode) {
|
public static Optional<TradeCurrency> getTradeCurrency(String currencyCode) {
|
||||||
Optional<FiatCurrency> fiatCurrencyOptional = getFiatCurrency(currencyCode);
|
Optional<TraditionalCurrency> traditionalCurrencyOptional = getTraditionalCurrency(currencyCode);
|
||||||
if (fiatCurrencyOptional.isPresent() && isFiatCurrency(currencyCode))
|
if (traditionalCurrencyOptional.isPresent() && isTraditionalCurrency(currencyCode))
|
||||||
return Optional.of(fiatCurrencyOptional.get());
|
return Optional.of(traditionalCurrencyOptional.get());
|
||||||
|
|
||||||
Optional<CryptoCurrency> cryptoCurrencyOptional = getCryptoCurrency(currencyCode);
|
Optional<CryptoCurrency> cryptoCurrencyOptional = getCryptoCurrency(currencyCode);
|
||||||
if (cryptoCurrencyOptional.isPresent() && isCryptoCurrency(currencyCode))
|
if (cryptoCurrencyOptional.isPresent() && isCryptoCurrency(currencyCode))
|
||||||
@ -290,12 +300,12 @@ public class CurrencyUtil {
|
|||||||
return tradeCurrencies;
|
return tradeCurrencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FiatCurrency getCurrencyByCountryCode(String countryCode) {
|
public static TraditionalCurrency getCurrencyByCountryCode(String countryCode) {
|
||||||
if (countryCode.equals("XK"))
|
if (countryCode.equals("XK"))
|
||||||
return new FiatCurrency("EUR");
|
return new TraditionalCurrency("EUR");
|
||||||
|
|
||||||
Currency currency = Currency.getInstance(new Locale(LanguageUtil.getDefaultLanguage(), countryCode));
|
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) {
|
public static String getCurrencyPair(String currencyCode) {
|
||||||
if (isFiatCurrency(currencyCode))
|
if (isTraditionalCurrency(currencyCode))
|
||||||
return Res.getBaseCurrencyCode() + "/" + currencyCode;
|
return Res.getBaseCurrencyCode() + "/" + currencyCode;
|
||||||
else
|
else
|
||||||
return currencyCode + "/" + Res.getBaseCurrencyCode();
|
return currencyCode + "/" + Res.getBaseCurrencyCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCounterCurrency(String currencyCode) {
|
public static String getCounterCurrency(String currencyCode) {
|
||||||
if (isFiatCurrency(currencyCode))
|
if (isTraditionalCurrency(currencyCode))
|
||||||
return currencyCode;
|
return currencyCode;
|
||||||
else
|
else
|
||||||
return Res.getBaseCurrencyCode();
|
return Res.getBaseCurrencyCode();
|
||||||
@ -453,6 +463,6 @@ public class CurrencyUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<TradeCurrency> getAllTransferwiseUSDCurrencies() {
|
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;
|
GlobalSettings.useAnimations = useAnimations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDefaultTradeCurrency(TradeCurrency fiatCurrency) {
|
public static void setDefaultTradeCurrency(TradeCurrency tradeCurrency) {
|
||||||
GlobalSettings.defaultTradeCurrency = fiatCurrency;
|
GlobalSettings.defaultTradeCurrency = tradeCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ public abstract class TradeCurrency implements PersistablePayload, Comparable<Tr
|
|||||||
|
|
||||||
public static TradeCurrency fromProto(protobuf.TradeCurrency proto) {
|
public static TradeCurrency fromProto(protobuf.TradeCurrency proto) {
|
||||||
switch (proto.getMessageCase()) {
|
switch (proto.getMessageCase()) {
|
||||||
case FIAT_CURRENCY:
|
case TRADITIONAL_CURRENCY:
|
||||||
return FiatCurrency.fromProto(proto);
|
return TraditionalCurrency.fromProto(proto);
|
||||||
case CRYPTO_CURRENCY:
|
case CRYPTO_CURRENCY:
|
||||||
return CryptoCurrency.fromProto(proto);
|
return CryptoCurrency.fromProto(proto);
|
||||||
default:
|
default:
|
||||||
|
@ -29,23 +29,23 @@ import java.util.Locale;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString
|
@ToString
|
||||||
@Getter
|
@Getter
|
||||||
public final class FiatCurrency extends TradeCurrency {
|
public final class TraditionalCurrency extends TradeCurrency {
|
||||||
// http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618
|
// http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618
|
||||||
private final static String PREFIX = "★ ";
|
private final static String PREFIX = "★ ";
|
||||||
|
|
||||||
private final Currency currency;
|
private final Currency currency;
|
||||||
|
|
||||||
public FiatCurrency(String currencyCode) {
|
public TraditionalCurrency(String currencyCode) {
|
||||||
this(Currency.getInstance(currencyCode), getLocale());
|
this(Currency.getInstance(currencyCode), getLocale());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public FiatCurrency(Currency currency) {
|
public TraditionalCurrency(Currency currency) {
|
||||||
this(currency, getLocale());
|
this(currency, getLocale());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public FiatCurrency(Currency currency, Locale locale) {
|
public TraditionalCurrency(Currency currency, Locale locale) {
|
||||||
super(currency.getCurrencyCode(), currency.getDisplayName(locale));
|
super(currency.getCurrencyCode(), currency.getDisplayName(locale));
|
||||||
this.currency = currency;
|
this.currency = currency;
|
||||||
}
|
}
|
||||||
@ -58,14 +58,14 @@ public final class FiatCurrency extends TradeCurrency {
|
|||||||
@Override
|
@Override
|
||||||
public Message toProtoMessage() {
|
public Message toProtoMessage() {
|
||||||
protobuf.Currency.Builder currencyBuilder = protobuf.Currency.newBuilder().setCurrencyCode(currency.getCurrencyCode());
|
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()
|
return getTradeCurrencyBuilder()
|
||||||
.setFiatCurrency(fiatCurrencyBuilder)
|
.setTraditionalCurrency(traditionalCurrencyBuilder)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FiatCurrency fromProto(protobuf.TradeCurrency proto) {
|
public static TraditionalCurrency fromProto(protobuf.TradeCurrency proto) {
|
||||||
return new FiatCurrency(proto.getCode());
|
return new TraditionalCurrency(proto.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -24,61 +24,61 @@ import java.math.BigInteger;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
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
|
@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 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")
|
@SuppressWarnings("SameParameterValue")
|
||||||
public AltcoinExchangeRate(Coin coin, Altcoin altcoin) {
|
public CryptoExchangeRate(Coin coin, CryptoMoney crypto) {
|
||||||
checkArgument(coin.isPositive());
|
checkArgument(coin.isPositive());
|
||||||
checkArgument(altcoin.isPositive());
|
checkArgument(crypto.isPositive());
|
||||||
checkArgument(altcoin.currencyCode != null, "currency code required");
|
checkArgument(crypto.currencyCode != null, "currency code required");
|
||||||
this.coin = coin;
|
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) {
|
public CryptoExchangeRate(CryptoMoney crypto) {
|
||||||
this(Coin.COIN, altcoin);
|
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)
|
BigInteger converted = BigInteger.valueOf(coin.value)
|
||||||
.multiply(BigInteger.valueOf(convertCoin.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
|
if (converted.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0
|
||||||
|| converted.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0)
|
|| converted.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0)
|
||||||
throw new ArithmeticException("Overflow");
|
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.
|
* @throws ArithmeticException if the converted coin amount is too high or too low.
|
||||||
*/
|
*/
|
||||||
public Coin altcoinToCoin(Altcoin convertAltcoin) {
|
public Coin cryptoToCoin(CryptoMoney convertCrypto) {
|
||||||
checkArgument(convertAltcoin.currencyCode.equals(altcoin.currencyCode), "Currency mismatch: %s vs %s",
|
checkArgument(convertCrypto.currencyCode.equals(crypto.currencyCode), "Currency mismatch: %s vs %s",
|
||||||
convertAltcoin.currencyCode, altcoin.currencyCode);
|
convertCrypto.currencyCode, crypto.currencyCode);
|
||||||
// Use BigInteger because it's much easier to maintain full precision without overflowing.
|
// Use BigInteger because it's much easier to maintain full precision without overflowing.
|
||||||
BigInteger converted = BigInteger.valueOf(altcoin.value)
|
BigInteger converted = BigInteger.valueOf(crypto.value)
|
||||||
.multiply(BigInteger.valueOf(convertAltcoin.value))
|
.multiply(BigInteger.valueOf(convertCrypto.value))
|
||||||
.divide(BigInteger.valueOf(coin.value));
|
.divide(BigInteger.valueOf(coin.value));
|
||||||
if (converted.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0
|
if (converted.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0
|
||||||
|| converted.compareTo(BigInteger.valueOf(Long.MIN_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.
|
* Cloned from Fiat class and altered SMALLEST_UNIT_EXPONENT as Fiat is final.
|
||||||
* <p/>
|
* <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.
|
* safety. Volume values always come with an attached currency code.
|
||||||
* <p/>
|
* <p/>
|
||||||
* This class is immutable.
|
* 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
|
* 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.
|
* 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 long value;
|
||||||
public final String currencyCode;
|
public final String currencyCode;
|
||||||
|
|
||||||
private Altcoin(final String currencyCode, final long value) {
|
private CryptoMoney(final String currencyCode, final long value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.currencyCode = currencyCode;
|
this.currencyCode = currencyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Altcoin valueOf(final String currencyCode, final long value) {
|
public static CryptoMoney valueOf(final String currencyCode, final long value) {
|
||||||
return new Altcoin(currencyCode, value);
|
return new CryptoMoney(currencyCode, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.
|
* @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);
|
String cleaned = ParsingUtils.convertCharsForNumber(input);
|
||||||
try {
|
try {
|
||||||
long val = new BigDecimal(cleaned).movePointRight(SMALLEST_UNIT_EXPONENT)
|
long val = new BigDecimal(cleaned).movePointRight(SMALLEST_UNIT_EXPONENT)
|
||||||
.toBigIntegerExact().longValue();
|
.toBigIntegerExact().longValue();
|
||||||
return Altcoin.valueOf(currencyCode, val);
|
return CryptoMoney.valueOf(currencyCode, val);
|
||||||
} catch (ArithmeticException e) {
|
} catch (ArithmeticException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Altcoin add(final Altcoin value) {
|
public CryptoMoney add(final CryptoMoney value) {
|
||||||
checkArgument(value.currencyCode.equals(currencyCode));
|
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));
|
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) {
|
public CryptoMoney multiply(final long factor) {
|
||||||
return new Altcoin(currencyCode, LongMath.checkedMultiply(this.value, factor));
|
return new CryptoMoney(currencyCode, LongMath.checkedMultiply(this.value, factor));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Altcoin divide(final long divisor) {
|
public CryptoMoney divide(final long divisor) {
|
||||||
return new Altcoin(currencyCode, this.value / divisor);
|
return new CryptoMoney(currencyCode, this.value / divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Altcoin[] divideAndRemainder(final long divisor) {
|
public CryptoMoney[] divideAndRemainder(final long divisor) {
|
||||||
return new Altcoin[]{new Altcoin(currencyCode, this.value / divisor), new Altcoin(currencyCode, this.value % 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));
|
checkArgument(divisor.currencyCode.equals(currencyCode));
|
||||||
return this.value / divisor.value;
|
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,
|
* Returns true if the monetary value represented by this instance is greater than that of the given other Coin,
|
||||||
* otherwise false.
|
* otherwise false.
|
||||||
*/
|
*/
|
||||||
public boolean isGreaterThan(Altcoin other) {
|
public boolean isGreaterThan(CryptoMoney other) {
|
||||||
return compareTo(other) > 0;
|
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,
|
* Returns true if the monetary value represented by this instance is less than that of the given other Coin,
|
||||||
* otherwise false.
|
* otherwise false.
|
||||||
*/
|
*/
|
||||||
public boolean isLessThan(Altcoin other) {
|
public boolean isLessThan(CryptoMoney other) {
|
||||||
return compareTo(other) < 0;
|
return compareTo(other) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,8 +167,8 @@ public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
|||||||
return this.value < 0 ? -1 : 1;
|
return this.value < 0 ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Altcoin negate() {
|
public CryptoMoney negate() {
|
||||||
return new Altcoin(currencyCode, -this.value);
|
return new CryptoMoney(currencyCode, -this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFriendlyString() {
|
public String toFriendlyString() {
|
||||||
@ -196,7 +196,7 @@ public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
|||||||
return true;
|
return true;
|
||||||
if (o == null || o.getClass() != getClass())
|
if (o == null || o.getClass() != getClass())
|
||||||
return false;
|
return false;
|
||||||
final Altcoin other = (Altcoin) o;
|
final CryptoMoney other = (CryptoMoney) o;
|
||||||
return this.value == other.value && this.currencyCode.equals(other.currencyCode);
|
return this.value == other.value && this.currencyCode.equals(other.currencyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ public final class Altcoin implements Monetary, Comparable<Altcoin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(@NotNull final Altcoin other) {
|
public int compareTo(@NotNull final CryptoMoney other) {
|
||||||
if (!this.currencyCode.equals(other.currencyCode))
|
if (!this.currencyCode.equals(other.currencyCode))
|
||||||
return this.currencyCode.compareTo(other.currencyCode);
|
return this.currencyCode.compareTo(other.currencyCode);
|
||||||
if (this.value != other.value)
|
if (this.value != other.value)
|
@ -25,10 +25,10 @@ import org.slf4j.LoggerFactory;
|
|||||||
public abstract class MonetaryWrapper {
|
public abstract class MonetaryWrapper {
|
||||||
private static final Logger log = LoggerFactory.getLogger(MonetaryWrapper.class);
|
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 Monetary monetary;
|
||||||
protected final MonetaryFormat fiatFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0);
|
protected final MonetaryFormat traditionalFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0);
|
||||||
protected final MonetaryFormat altCoinFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0);
|
protected final MonetaryFormat cryptoFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0);
|
||||||
|
|
||||||
public MonetaryWrapper(Monetary monetary) {
|
public MonetaryWrapper(Monetary monetary) {
|
||||||
this.monetary = monetary;
|
this.monetary = monetary;
|
||||||
|
@ -21,8 +21,6 @@ import haveno.core.locale.CurrencyUtil;
|
|||||||
import haveno.core.trade.HavenoUtils;
|
import haveno.core.trade.HavenoUtils;
|
||||||
import haveno.core.util.ParsingUtils;
|
import haveno.core.util.ParsingUtils;
|
||||||
import org.bitcoinj.core.Monetary;
|
import org.bitcoinj.core.Monetary;
|
||||||
import org.bitcoinj.utils.ExchangeRate;
|
|
||||||
import org.bitcoinj.utils.Fiat;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -36,7 +34,7 @@ import java.math.BigInteger;
|
|||||||
* <br/>
|
* <br/>
|
||||||
* We wrap an object implementing the {@link Monetary} interface from bitcoinj. We respect the
|
* 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
|
* 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> {
|
public class Price extends MonetaryWrapper implements Comparable<Price> {
|
||||||
private static final Logger log = LoggerFactory.getLogger(Price.class);
|
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) {
|
public static Price parse(String currencyCode, String input) {
|
||||||
String cleaned = ParsingUtils.convertCharsForNumber(input);
|
String cleaned = ParsingUtils.convertCharsForNumber(input);
|
||||||
if (CurrencyUtil.isFiatCurrency(currencyCode))
|
if (CurrencyUtil.isTraditionalCurrency(currencyCode))
|
||||||
return new Price(Fiat.parseFiat(currencyCode, cleaned));
|
return new Price(TraditionalMoney.parseTraditionalMoney(currencyCode, cleaned));
|
||||||
else
|
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.
|
* @return The parsed Price.
|
||||||
*/
|
*/
|
||||||
public static Price valueOf(String currencyCode, long value) {
|
public static Price valueOf(String currencyCode, long value) {
|
||||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
|
||||||
return new Price(Fiat.valueOf(currencyCode, value));
|
return new Price(TraditionalMoney.valueOf(currencyCode, value));
|
||||||
} else {
|
} else {
|
||||||
return new Price(Altcoin.valueOf(currencyCode, value));
|
return new Price(CryptoMoney.valueOf(currencyCode, value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Volume getVolumeByAmount(BigInteger amount) {
|
public Volume getVolumeByAmount(BigInteger amount) {
|
||||||
if (monetary instanceof Fiat)
|
if (monetary instanceof TraditionalMoney)
|
||||||
return new Volume(new ExchangeRate((Fiat) monetary).coinToFiat(HavenoUtils.atomicUnitsToCoin(amount)));
|
return new Volume(new TraditionalExchangeRate((TraditionalMoney) monetary).coinToTraditionalMoney(HavenoUtils.atomicUnitsToCoin(amount)));
|
||||||
else if (monetary instanceof Altcoin)
|
else if (monetary instanceof CryptoMoney)
|
||||||
return new Volume(new AltcoinExchangeRate((Altcoin) monetary).coinToAltcoin(HavenoUtils.atomicUnitsToCoin(amount)));
|
return new Volume(new CryptoExchangeRate((CryptoMoney) monetary).coinToCrypto(HavenoUtils.atomicUnitsToCoin(amount)));
|
||||||
else
|
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) {
|
public BigInteger getAmountByVolume(Volume volume) {
|
||||||
Monetary monetary = volume.getMonetary();
|
Monetary monetary = volume.getMonetary();
|
||||||
if (monetary instanceof Fiat && this.monetary instanceof Fiat)
|
if (monetary instanceof TraditionalMoney && this.monetary instanceof TraditionalMoney)
|
||||||
return HavenoUtils.coinToAtomicUnits(new ExchangeRate((Fiat) this.monetary).fiatToCoin((Fiat) monetary));
|
return HavenoUtils.coinToAtomicUnits(new TraditionalExchangeRate((TraditionalMoney) this.monetary).traditionalMoneyToCoin((TraditionalMoney) monetary));
|
||||||
else if (monetary instanceof Altcoin && this.monetary instanceof Altcoin)
|
else if (monetary instanceof CryptoMoney && this.monetary instanceof CryptoMoney)
|
||||||
return HavenoUtils.coinToAtomicUnits(new AltcoinExchangeRate((Altcoin) this.monetary).altcoinToCoin((Altcoin) monetary));
|
return HavenoUtils.coinToAtomicUnits(new CryptoExchangeRate((CryptoMoney) this.monetary).cryptoToCoin((CryptoMoney) monetary));
|
||||||
else
|
else
|
||||||
return BigInteger.valueOf(0);
|
return BigInteger.valueOf(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCurrencyCode() {
|
public String getCurrencyCode() {
|
||||||
return monetary instanceof Altcoin ? ((Altcoin) monetary).getCurrencyCode() : ((Fiat) monetary).getCurrencyCode();
|
return monetary instanceof CryptoMoney ? ((CryptoMoney) monetary).getCurrencyCode() : ((TraditionalMoney) monetary).getCurrencyCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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() {
|
public double getDoubleValue() {
|
||||||
return BigDecimal.valueOf(monetary.getValue()).movePointLeft(monetary.smallestUnitExponent()).doubleValue();
|
return BigDecimal.valueOf(monetary.getValue()).movePointLeft(monetary.smallestUnitExponent()).doubleValue();
|
||||||
@ -125,25 +123,25 @@ public class Price extends MonetaryWrapper implements Comparable<Price> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPositive() {
|
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) {
|
public Price subtract(Price other) {
|
||||||
if (monetary instanceof Altcoin) {
|
if (monetary instanceof CryptoMoney) {
|
||||||
return new Price(((Altcoin) monetary).subtract((Altcoin) other.monetary));
|
return new Price(((CryptoMoney) monetary).subtract((CryptoMoney) other.monetary));
|
||||||
} else {
|
} else {
|
||||||
return new Price(((Fiat) monetary).subtract((Fiat) other.monetary));
|
return new Price(((TraditionalMoney) monetary).subtract((TraditionalMoney) other.monetary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFriendlyString() {
|
public String toFriendlyString() {
|
||||||
return monetary instanceof Altcoin ?
|
return monetary instanceof CryptoMoney ?
|
||||||
((Altcoin) monetary).toFriendlyString() + "/XMR" :
|
((CryptoMoney) monetary).toFriendlyString() + "/XMR" :
|
||||||
((Fiat) monetary).toFriendlyString().replace(((Fiat) monetary).currencyCode, "") + "XMR/" + ((Fiat) monetary).currencyCode;
|
((TraditionalMoney) monetary).toFriendlyString().replace(((TraditionalMoney) monetary).currencyCode, "") + "XMR/" + ((TraditionalMoney) monetary).currencyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toPlainString() {
|
public String toPlainString() {
|
||||||
return monetary instanceof Altcoin ? ((Altcoin) monetary).toPlainString() : ((Fiat) monetary).toPlainString();
|
return monetary instanceof CryptoMoney ? ((CryptoMoney) monetary).toPlainString() : ((TraditionalMoney) monetary).toPlainString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.locale.CurrencyUtil;
|
||||||
import haveno.core.util.ParsingUtils;
|
import haveno.core.util.ParsingUtils;
|
||||||
import org.bitcoinj.core.Monetary;
|
import org.bitcoinj.core.Monetary;
|
||||||
import org.bitcoinj.utils.Fiat;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -34,10 +33,10 @@ public class Volume extends MonetaryWrapper implements Comparable<Volume> {
|
|||||||
|
|
||||||
public static Volume parse(String input, String currencyCode) {
|
public static Volume parse(String input, String currencyCode) {
|
||||||
String cleaned = ParsingUtils.convertCharsForNumber(input);
|
String cleaned = ParsingUtils.convertCharsForNumber(input);
|
||||||
if (CurrencyUtil.isFiatCurrency(currencyCode))
|
if (CurrencyUtil.isTraditionalCurrency(currencyCode))
|
||||||
return new Volume(Fiat.parseFiat(currencyCode, cleaned));
|
return new Volume(TraditionalMoney.parseTraditionalMoney(currencyCode, cleaned));
|
||||||
else
|
else
|
||||||
return new Volume(Altcoin.parseAltcoin(currencyCode, cleaned));
|
return new Volume(CryptoMoney.parseCrypto(currencyCode, cleaned));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,11 +49,11 @@ public class Volume extends MonetaryWrapper implements Comparable<Volume> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getCurrencyCode() {
|
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() {
|
public String toPlainString() {
|
||||||
return monetary instanceof Altcoin ? ((Altcoin) monetary).toPlainString() : ((Fiat) monetary).toPlainString();
|
return monetary instanceof CryptoMoney ? ((CryptoMoney) monetary).toPlainString() : ((TraditionalMoney) monetary).toPlainString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,8 +21,9 @@ import haveno.common.crypto.KeyRing;
|
|||||||
import haveno.common.util.MathUtils;
|
import haveno.common.util.MathUtils;
|
||||||
import haveno.core.locale.CurrencyUtil;
|
import haveno.core.locale.CurrencyUtil;
|
||||||
import haveno.core.locale.Res;
|
import haveno.core.locale.Res;
|
||||||
import haveno.core.monetary.Altcoin;
|
import haveno.core.monetary.CryptoMoney;
|
||||||
import haveno.core.monetary.Price;
|
import haveno.core.monetary.Price;
|
||||||
|
import haveno.core.monetary.TraditionalMoney;
|
||||||
import haveno.core.notifications.MobileMessage;
|
import haveno.core.notifications.MobileMessage;
|
||||||
import haveno.core.notifications.MobileMessageType;
|
import haveno.core.notifications.MobileMessageType;
|
||||||
import haveno.core.notifications.MobileNotificationService;
|
import haveno.core.notifications.MobileNotificationService;
|
||||||
@ -34,7 +35,6 @@ import haveno.core.provider.price.PriceFeedService;
|
|||||||
import haveno.core.user.User;
|
import haveno.core.user.User;
|
||||||
import haveno.core.util.FormattingUtils;
|
import haveno.core.util.FormattingUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bitcoinj.utils.Fiat;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
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
|
// 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
|
// % 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) {
|
private String getAlertId(Offer offer) {
|
||||||
double price = offer.isUseMarketBasedPrice() ? offer.getMarketPriceMarginPct() * 10000 : offer.getOfferPayload().getPrice();
|
double price = offer.isUseMarketBasedPrice() ? offer.getMarketPriceMarginPct() * 10000 : offer.getOfferPayload().getPrice();
|
||||||
String priceString = String.valueOf((long) price);
|
String priceString = String.valueOf((long) price);
|
||||||
@ -117,7 +117,7 @@ public class MarketAlerts {
|
|||||||
if (marketPrice != null && offerPrice != null) {
|
if (marketPrice != null && offerPrice != null) {
|
||||||
boolean isSellOffer = offer.getDirection() == OfferDirection.SELL;
|
boolean isSellOffer = offer.getDirection() == OfferDirection.SELL;
|
||||||
String shortOfferId = offer.getShortId();
|
String shortOfferId = offer.getShortId();
|
||||||
boolean isFiatCurrency = CurrencyUtil.isFiatCurrency(currencyCode);
|
boolean isTraditionalCurrency = CurrencyUtil.isTraditionalCurrency(currencyCode);
|
||||||
String alertId = getAlertId(offer);
|
String alertId = getAlertId(offer);
|
||||||
user.getMarketAlertFilters().stream()
|
user.getMarketAlertFilters().stream()
|
||||||
.filter(marketAlertFilter -> !offer.isMyOffer(keyRing))
|
.filter(marketAlertFilter -> !offer.isMyOffer(keyRing))
|
||||||
@ -127,16 +127,16 @@ public class MarketAlerts {
|
|||||||
int triggerValue = marketAlertFilter.getTriggerValue();
|
int triggerValue = marketAlertFilter.getTriggerValue();
|
||||||
boolean isTriggerForBuyOffer = marketAlertFilter.isBuyOffer();
|
boolean isTriggerForBuyOffer = marketAlertFilter.isBuyOffer();
|
||||||
double marketPriceAsDouble1 = marketPrice.getPrice();
|
double marketPriceAsDouble1 = marketPrice.getPrice();
|
||||||
int precision = CurrencyUtil.isCryptoCurrency(currencyCode) ?
|
int precision = CurrencyUtil.isTraditionalCurrency(currencyCode) ?
|
||||||
Altcoin.SMALLEST_UNIT_EXPONENT :
|
TraditionalMoney.SMALLEST_UNIT_EXPONENT :
|
||||||
Fiat.SMALLEST_UNIT_EXPONENT;
|
CryptoMoney.SMALLEST_UNIT_EXPONENT;
|
||||||
double marketPriceAsDouble = MathUtils.scaleUpByPowerOf10(marketPriceAsDouble1, precision);
|
double marketPriceAsDouble = MathUtils.scaleUpByPowerOf10(marketPriceAsDouble1, precision);
|
||||||
double offerPriceValue = offerPrice.getValue();
|
double offerPriceValue = offerPrice.getValue();
|
||||||
double ratio = offerPriceValue / marketPriceAsDouble;
|
double ratio = offerPriceValue / marketPriceAsDouble;
|
||||||
ratio = 1 - ratio;
|
ratio = 1 - ratio;
|
||||||
if (isFiatCurrency && isSellOffer)
|
if (isTraditionalCurrency && isSellOffer)
|
||||||
ratio *= -1;
|
ratio *= -1;
|
||||||
else if (!isFiatCurrency && !isSellOffer)
|
else if (!isTraditionalCurrency && !isSellOffer)
|
||||||
ratio *= -1;
|
ratio *= -1;
|
||||||
|
|
||||||
ratio = ratio * 10000;
|
ratio = ratio * 10000;
|
||||||
@ -149,7 +149,7 @@ public class MarketAlerts {
|
|||||||
if (isTriggerForBuyOfferAndTriggered || isTriggerForSellOfferAndTriggered) {
|
if (isTriggerForBuyOfferAndTriggered || isTriggerForSellOfferAndTriggered) {
|
||||||
String direction = isSellOffer ? Res.get("shared.sell") : Res.get("shared.buy");
|
String direction = isSellOffer ? Res.get("shared.sell") : Res.get("shared.buy");
|
||||||
String marketDir;
|
String marketDir;
|
||||||
if (isFiatCurrency) {
|
if (isTraditionalCurrency) {
|
||||||
if (isSellOffer) {
|
if (isSellOffer) {
|
||||||
marketDir = ratio > 0 ?
|
marketDir = ratio > 0 ?
|
||||||
Res.get("account.notifications.marketAlert.message.msg.above") :
|
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.common.util.MathUtils;
|
||||||
import haveno.core.locale.CurrencyUtil;
|
import haveno.core.locale.CurrencyUtil;
|
||||||
import haveno.core.locale.Res;
|
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.MobileMessage;
|
||||||
import haveno.core.notifications.MobileMessageType;
|
import haveno.core.notifications.MobileMessageType;
|
||||||
import haveno.core.notifications.MobileNotificationService;
|
import haveno.core.notifications.MobileNotificationService;
|
||||||
@ -29,7 +30,6 @@ import haveno.core.provider.price.PriceFeedService;
|
|||||||
import haveno.core.user.User;
|
import haveno.core.user.User;
|
||||||
import haveno.core.util.FormattingUtils;
|
import haveno.core.util.FormattingUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bitcoinj.utils.Fiat;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@ -58,7 +58,7 @@ public class PriceAlert {
|
|||||||
String currencyCode = filter.getCurrencyCode();
|
String currencyCode = filter.getCurrencyCode();
|
||||||
MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode);
|
MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode);
|
||||||
if (marketPrice != null) {
|
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();
|
double priceAsDouble = marketPrice.getPrice();
|
||||||
long priceAsLong = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(priceAsDouble, exp));
|
long priceAsLong = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(priceAsDouble, exp));
|
||||||
String currencyName = CurrencyUtil.getNameByCode(currencyCode);
|
String currencyName = CurrencyUtil.getNameByCode(currencyCode);
|
||||||
|
@ -28,8 +28,9 @@ import haveno.common.util.MathUtils;
|
|||||||
import haveno.common.util.Utilities;
|
import haveno.common.util.Utilities;
|
||||||
import haveno.core.exceptions.TradePriceOutOfToleranceException;
|
import haveno.core.exceptions.TradePriceOutOfToleranceException;
|
||||||
import haveno.core.locale.CurrencyUtil;
|
import haveno.core.locale.CurrencyUtil;
|
||||||
import haveno.core.monetary.Altcoin;
|
import haveno.core.monetary.CryptoMoney;
|
||||||
import haveno.core.monetary.Price;
|
import haveno.core.monetary.Price;
|
||||||
|
import haveno.core.monetary.TraditionalMoney;
|
||||||
import haveno.core.monetary.Volume;
|
import haveno.core.monetary.Volume;
|
||||||
import haveno.core.offer.availability.OfferAvailabilityModel;
|
import haveno.core.offer.availability.OfferAvailabilityModel;
|
||||||
import haveno.core.offer.availability.OfferAvailabilityProtocol;
|
import haveno.core.offer.availability.OfferAvailabilityProtocol;
|
||||||
@ -46,7 +47,6 @@ import javafx.beans.property.StringProperty;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bitcoinj.utils.Fiat;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -182,9 +182,9 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||||||
double marketPriceAsDouble = marketPrice.getPrice();
|
double marketPriceAsDouble = marketPrice.getPrice();
|
||||||
double targetPriceAsDouble = marketPriceAsDouble * factor;
|
double targetPriceAsDouble = marketPriceAsDouble * factor;
|
||||||
try {
|
try {
|
||||||
int precision = CurrencyUtil.isCryptoCurrency(currencyCode) ?
|
int precision = CurrencyUtil.isTraditionalCurrency(currencyCode) ?
|
||||||
Altcoin.SMALLEST_UNIT_EXPONENT :
|
TraditionalMoney.SMALLEST_UNIT_EXPONENT :
|
||||||
Fiat.SMALLEST_UNIT_EXPONENT;
|
CryptoMoney.SMALLEST_UNIT_EXPONENT;
|
||||||
double scaled = MathUtils.scaleUpByPowerOf10(targetPriceAsDouble, precision);
|
double scaled = MathUtils.scaleUpByPowerOf10(targetPriceAsDouble, precision);
|
||||||
final long roundedToLong = MathUtils.roundDoubleToLong(scaled);
|
final long roundedToLong = MathUtils.roundDoubleToLong(scaled);
|
||||||
return Price.valueOf(currencyCode, roundedToLong);
|
return Price.valueOf(currencyCode, roundedToLong);
|
||||||
@ -528,6 +528,10 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||||||
return getCurrencyCode().equals("XMR");
|
return getCurrencyCode().equals("XMR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTraditionalOffer() {
|
||||||
|
return CurrencyUtil.isTraditionalCurrency(currencyCode);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFiatOffer() {
|
public boolean isFiatOffer() {
|
||||||
return CurrencyUtil.isFiatCurrency(currencyCode);
|
return CurrencyUtil.isFiatCurrency(currencyCode);
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ public class OfferFilterService {
|
|||||||
return insufficientCounterpartyTradeLimitCache.get(offerId);
|
return insufficientCounterpartyTradeLimitCache.get(offerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean result = offer.isFiatOffer() &&
|
boolean result = offer.isTraditionalOffer() &&
|
||||||
!accountAgeWitnessService.verifyPeersTradeAmount(offer, offer.getAmount(),
|
!accountAgeWitnessService.verifyPeersTradeAmount(offer, offer.getAmount(),
|
||||||
errorMessage -> {
|
errorMessage -> {
|
||||||
});
|
});
|
||||||
@ -215,7 +215,7 @@ public class OfferFilterService {
|
|||||||
accountOptional.isPresent() ? accountOptional.get().getAccountName() : "null",
|
accountOptional.isPresent() ? accountOptional.get().getAccountName() : "null",
|
||||||
Coin.valueOf(myTradeLimit).toFriendlyString(),
|
Coin.valueOf(myTradeLimit).toFriendlyString(),
|
||||||
Coin.valueOf(offerMinAmount).toFriendlyString());
|
Coin.valueOf(offerMinAmount).toFriendlyString());
|
||||||
boolean result = offer.isFiatOffer() &&
|
boolean result = offer.isTraditionalOffer() &&
|
||||||
accountOptional.isPresent() &&
|
accountOptional.isPresent() &&
|
||||||
myTradeLimit < offerMinAmount;
|
myTradeLimit < offerMinAmount;
|
||||||
myInsufficientTradeLimitCache.put(offerId, result);
|
myInsufficientTradeLimitCache.put(offerId, result);
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
package haveno.core.offer;
|
package haveno.core.offer;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import haveno.common.util.MathUtils;
|
|
||||||
import haveno.core.locale.CurrencyUtil;
|
import haveno.core.locale.CurrencyUtil;
|
||||||
import haveno.core.locale.Res;
|
import haveno.core.locale.Res;
|
||||||
|
import haveno.core.monetary.CryptoMoney;
|
||||||
import haveno.core.monetary.Price;
|
import haveno.core.monetary.Price;
|
||||||
import haveno.core.monetary.Volume;
|
import haveno.core.monetary.Volume;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -64,9 +64,9 @@ public class OfferForJson {
|
|||||||
public long primaryMarketMinVolume;
|
public long primaryMarketMinVolume;
|
||||||
|
|
||||||
@JsonIgnore
|
@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
|
@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
|
@JsonIgnore
|
||||||
transient private final MonetaryFormat coinFormat = MonetaryFormat.BTC;
|
transient private final MonetaryFormat coinFormat = MonetaryFormat.BTC;
|
||||||
|
|
||||||
@ -99,43 +99,34 @@ public class OfferForJson {
|
|||||||
private void setDisplayStrings() {
|
private void setDisplayStrings() {
|
||||||
try {
|
try {
|
||||||
final Price price = getPrice();
|
final Price price = getPrice();
|
||||||
|
|
||||||
if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
|
if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
|
||||||
primaryMarketDirection = direction == OfferDirection.BUY ? OfferDirection.SELL : OfferDirection.BUY;
|
primaryMarketDirection = direction == OfferDirection.BUY ? OfferDirection.SELL : OfferDirection.BUY;
|
||||||
currencyPair = currencyCode + "/" + Res.getBaseCurrencyCode();
|
currencyPair = currencyCode + "/" + Res.getBaseCurrencyCode();
|
||||||
|
|
||||||
// int precision = 8;
|
|
||||||
//decimalFormat.setMaximumFractionDigits(precision);
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
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 {
|
} else {
|
||||||
primaryMarketDirection = direction;
|
primaryMarketDirection = direction;
|
||||||
currencyPair = Res.getBaseCurrencyCode() + "/" + currencyCode;
|
currencyPair = Res.getBaseCurrencyCode() + "/" + currencyCode;
|
||||||
|
}
|
||||||
|
|
||||||
priceDisplayString = fiatFormat.noCode().format(price.getMonetary()).toString();
|
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
|
||||||
|
priceDisplayString = traditionalFormat.noCode().format(price.getMonetary()).toString();
|
||||||
primaryMarketMinAmountDisplayString = HavenoUtils.formatXmr(getMinAmount()).toString();
|
primaryMarketMinAmountDisplayString = HavenoUtils.formatXmr(getMinAmount()).toString();
|
||||||
primaryMarketAmountDisplayString = HavenoUtils.formatXmr(getAmount()).toString();
|
primaryMarketAmountDisplayString = HavenoUtils.formatXmr(getAmount()).toString();
|
||||||
primaryMarketMinVolumeDisplayString = fiatFormat.noCode().format(getMinVolume().getMonetary()).toString();
|
primaryMarketMinVolumeDisplayString = traditionalFormat.noCode().format(getMinVolume().getMonetary()).toString();
|
||||||
primaryMarketVolumeDisplayString = fiatFormat.noCode().format(getVolume().getMonetary()).toString();
|
primaryMarketVolumeDisplayString = traditionalFormat.noCode().format(getVolume().getMonetary()).toString();
|
||||||
|
} else {
|
||||||
// we use precision 4 for fiat based price but on the markets api we use precision 8 so we scale up by 10000
|
// amount and volume is inverted for json
|
||||||
primaryMarketPrice = (long) MathUtils.scaleUpByPowerOf10(price.getValue(), 4);
|
priceDisplayString = cryptoFormat.noCode().format(price.getMonetary()).toString();
|
||||||
primaryMarketMinVolume = (long) MathUtils.scaleUpByPowerOf10(getMinVolume().getValue(), 4);
|
primaryMarketMinAmountDisplayString = cryptoFormat.noCode().format(getMinVolume().getMonetary()).toString();
|
||||||
primaryMarketVolume = (long) MathUtils.scaleUpByPowerOf10(getVolume().getValue(), 4);
|
primaryMarketAmountDisplayString = cryptoFormat.noCode().format(getVolume().getMonetary()).toString();
|
||||||
|
primaryMarketMinVolumeDisplayString = HavenoUtils.formatXmr(getMinAmount()).toString();
|
||||||
primaryMarketMinAmount = getMinAmount().longValueExact();
|
primaryMarketVolumeDisplayString = HavenoUtils.formatXmr(getAmount()).toString();
|
||||||
primaryMarketAmount = getAmount().longValueExact();
|
|
||||||
}
|
}
|
||||||
|
primaryMarketPrice = price.getValue();
|
||||||
|
primaryMarketMinAmount = getMinVolume().getValue();
|
||||||
|
primaryMarketAmount = getVolume().getValue();
|
||||||
|
primaryMarketMinVolume = getMinAmount().longValueExact();
|
||||||
|
primaryMarketVolume = getAmount().longValueExact();
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.error("Error at setDisplayStrings: " + t.getMessage());
|
log.error("Error at setDisplayStrings: " + t.getMessage());
|
||||||
|
@ -56,8 +56,8 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
|||||||
|
|
||||||
protected final String id;
|
protected final String id;
|
||||||
protected final long date;
|
protected final long date;
|
||||||
// For fiat offer the baseCurrencyCode is BTC and the counterCurrencyCode is the fiat currency
|
// For traditional offer the baseCurrencyCode is XMR and the counterCurrencyCode is the traditional currency
|
||||||
// For altcoin offers it is the opposite. baseCurrencyCode is the altcoin and the counterCurrencyCode is BTC.
|
// For crypto offers it is the opposite. baseCurrencyCode is the crypto and the counterCurrencyCode is XMR.
|
||||||
protected final String baseCurrencyCode;
|
protected final String baseCurrencyCode;
|
||||||
protected final String counterCurrencyCode;
|
protected final String counterCurrencyCode;
|
||||||
// price if fixed price is used (usePercentageBasedPrice = false), otherwise 0
|
// 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;
|
protected List<String> reserveTxKeyImages;
|
||||||
|
|
||||||
// Keys for extra map
|
// 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 ACCOUNT_AGE_WITNESS_HASH = "accountAgeWitnessHash";
|
||||||
public static final String REFERRAL_ID = "referralId";
|
public static final String REFERRAL_ID = "referralId";
|
||||||
// Only used in payment method F2F
|
// 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
|
// In the offer we support base and counter currency
|
||||||
// Fiat offers have base currency XMR and counterCurrency Fiat
|
// 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
|
// The rest of the app does not support yet that concept of base currency and counter currencies
|
||||||
// so we map here for convenience
|
// so we map here for convenience
|
||||||
public String getCurrencyCode() {
|
public String getCurrencyCode() {
|
||||||
|
@ -26,6 +26,7 @@ import haveno.core.filter.FilterManager;
|
|||||||
import haveno.core.locale.CurrencyUtil;
|
import haveno.core.locale.CurrencyUtil;
|
||||||
import haveno.core.locale.Res;
|
import haveno.core.locale.Res;
|
||||||
import haveno.core.monetary.Price;
|
import haveno.core.monetary.Price;
|
||||||
|
import haveno.core.monetary.TraditionalMoney;
|
||||||
import haveno.core.monetary.Volume;
|
import haveno.core.monetary.Volume;
|
||||||
import haveno.core.payment.CashByMailAccount;
|
import haveno.core.payment.CashByMailAccount;
|
||||||
import haveno.core.payment.F2FAccount;
|
import haveno.core.payment.F2FAccount;
|
||||||
@ -42,7 +43,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.bitcoinj.core.Transaction;
|
import org.bitcoinj.core.Transaction;
|
||||||
import org.bitcoinj.core.TransactionInput;
|
import org.bitcoinj.core.TransactionInput;
|
||||||
import org.bitcoinj.core.TransactionOutput;
|
import org.bitcoinj.core.TransactionOutput;
|
||||||
import org.bitcoinj.utils.Fiat;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@ -169,7 +169,7 @@ public class OfferUtil {
|
|||||||
CoinFormatter formatter) {
|
CoinFormatter formatter) {
|
||||||
String userCurrencyCode = preferences.getPreferredTradeCurrency().getCode();
|
String userCurrencyCode = preferences.getPreferredTradeCurrency().getCode();
|
||||||
if (CurrencyUtil.isCryptoCurrency(userCurrencyCode)) {
|
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
|
// we derive the fiat currency from the user country
|
||||||
String countryCode = preferences.getUserCountry().code;
|
String countryCode = preferences.getUserCountry().code;
|
||||||
userCurrencyCode = CurrencyUtil.getCurrencyByCountryCode(countryCode).getCode();
|
userCurrencyCode = CurrencyUtil.getCurrencyByCountryCode(countryCode).getCode();
|
||||||
@ -184,7 +184,7 @@ public class OfferUtil {
|
|||||||
String currencyCode,
|
String currencyCode,
|
||||||
OfferDirection direction) {
|
OfferDirection direction) {
|
||||||
Map<String, String> extraDataMap = new HashMap<>();
|
Map<String, String> extraDataMap = new HashMap<>();
|
||||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
|
||||||
String myWitnessHashAsHex = accountAgeWitnessService
|
String myWitnessHashAsHex = accountAgeWitnessService
|
||||||
.getMyWitnessHashAsHex(paymentAccount.getPaymentAccountPayload());
|
.getMyWitnessHashAsHex(paymentAccount.getPaymentAccountPayload());
|
||||||
extraDataMap.put(ACCOUNT_AGE_WITNESS_HASH, myWitnessHashAsHex);
|
extraDataMap.put(ACCOUNT_AGE_WITNESS_HASH, myWitnessHashAsHex);
|
||||||
@ -236,7 +236,7 @@ public class OfferUtil {
|
|||||||
private Optional<Volume> getFeeInUserFiatCurrency(BigInteger makerFee, String userCurrencyCode, CoinFormatter formatter) {
|
private Optional<Volume> getFeeInUserFiatCurrency(BigInteger makerFee, String userCurrencyCode, CoinFormatter formatter) {
|
||||||
MarketPrice marketPrice = priceFeedService.getMarketPrice(userCurrencyCode);
|
MarketPrice marketPrice = priceFeedService.getMarketPrice(userCurrencyCode);
|
||||||
if (marketPrice != null && makerFee != null) {
|
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);
|
Price userCurrencyPrice = Price.valueOf(userCurrencyCode, marketPriceAsLong);
|
||||||
return Optional.of(userCurrencyPrice.getVolumeByAmount(makerFee));
|
return Optional.of(userCurrencyPrice.getVolumeByAmount(makerFee));
|
||||||
} else {
|
} 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");
|
return offer.getBaseCurrencyCode().equals("XMR");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAltcoinOffer(Offer offer) {
|
public static boolean isCryptoOffer(Offer offer) {
|
||||||
return offer.getCounterCurrencyCode().equals("XMR");
|
return offer.getCounterCurrencyCode().equals("XMR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,9 @@ package haveno.core.offer;
|
|||||||
|
|
||||||
import haveno.common.util.MathUtils;
|
import haveno.common.util.MathUtils;
|
||||||
import haveno.core.locale.CurrencyUtil;
|
import haveno.core.locale.CurrencyUtil;
|
||||||
import haveno.core.monetary.Altcoin;
|
import haveno.core.monetary.CryptoMoney;
|
||||||
import haveno.core.monetary.Price;
|
import haveno.core.monetary.Price;
|
||||||
|
import haveno.core.monetary.TraditionalMoney;
|
||||||
import haveno.core.provider.mempool.MempoolService;
|
import haveno.core.provider.mempool.MempoolService;
|
||||||
import haveno.core.provider.price.MarketPrice;
|
import haveno.core.provider.price.MarketPrice;
|
||||||
import haveno.core.provider.price.PriceFeedService;
|
import haveno.core.provider.price.PriceFeedService;
|
||||||
@ -28,7 +29,6 @@ import haveno.network.p2p.BootstrapListener;
|
|||||||
import haveno.network.p2p.P2PService;
|
import haveno.network.p2p.P2PService;
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bitcoinj.utils.Fiat;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@ -110,10 +110,10 @@ public class TriggerPriceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String currencyCode = openOffer.getOffer().getCurrencyCode();
|
String currencyCode = openOffer.getOffer().getCurrencyCode();
|
||||||
boolean cryptoCurrency = CurrencyUtil.isCryptoCurrency(currencyCode);
|
boolean traditionalCurrency = CurrencyUtil.isTraditionalCurrency(currencyCode);
|
||||||
int smallestUnitExponent = cryptoCurrency ?
|
int smallestUnitExponent = traditionalCurrency ?
|
||||||
Altcoin.SMALLEST_UNIT_EXPONENT :
|
TraditionalMoney.SMALLEST_UNIT_EXPONENT :
|
||||||
Fiat.SMALLEST_UNIT_EXPONENT;
|
CryptoMoney.SMALLEST_UNIT_EXPONENT;
|
||||||
long marketPriceAsLong = roundDoubleToLong(
|
long marketPriceAsLong = roundDoubleToLong(
|
||||||
scaleUpByPowerOf10(marketPrice.getPrice(), smallestUnitExponent));
|
scaleUpByPowerOf10(marketPrice.getPrice(), smallestUnitExponent));
|
||||||
long triggerPrice = openOffer.getTriggerPrice();
|
long triggerPrice = openOffer.getTriggerPrice();
|
||||||
@ -123,6 +123,7 @@ public class TriggerPriceService {
|
|||||||
|
|
||||||
OfferDirection direction = openOffer.getOffer().getDirection();
|
OfferDirection direction = openOffer.getOffer().getDirection();
|
||||||
boolean isSellOffer = direction == OfferDirection.SELL;
|
boolean isSellOffer = direction == OfferDirection.SELL;
|
||||||
|
boolean cryptoCurrency = CurrencyUtil.isCryptoCurrency(currencyCode);
|
||||||
boolean condition = isSellOffer && !cryptoCurrency || !isSellOffer && cryptoCurrency;
|
boolean condition = isSellOffer && !cryptoCurrency || !isSellOffer && cryptoCurrency;
|
||||||
return condition ?
|
return condition ?
|
||||||
marketPriceAsLong < triggerPrice :
|
marketPriceAsLong < triggerPrice :
|
||||||
@ -132,9 +133,9 @@ public class TriggerPriceService {
|
|||||||
private void checkPriceThreshold(MarketPrice marketPrice, OpenOffer openOffer) {
|
private void checkPriceThreshold(MarketPrice marketPrice, OpenOffer openOffer) {
|
||||||
if (wasTriggered(marketPrice, openOffer)) {
|
if (wasTriggered(marketPrice, openOffer)) {
|
||||||
String currencyCode = openOffer.getOffer().getCurrencyCode();
|
String currencyCode = openOffer.getOffer().getCurrencyCode();
|
||||||
int smallestUnitExponent = CurrencyUtil.isCryptoCurrency(currencyCode) ?
|
int smallestUnitExponent = CurrencyUtil.isTraditionalCurrency(currencyCode) ?
|
||||||
Altcoin.SMALLEST_UNIT_EXPONENT :
|
TraditionalMoney.SMALLEST_UNIT_EXPONENT :
|
||||||
Fiat.SMALLEST_UNIT_EXPONENT;
|
CryptoMoney.SMALLEST_UNIT_EXPONENT;
|
||||||
long triggerPrice = openOffer.getTriggerPrice();
|
long triggerPrice = openOffer.getTriggerPrice();
|
||||||
|
|
||||||
log.info("Market price exceeded the trigger price of the open offer.\n" +
|
log.info("Market price exceeded the trigger price of the open offer.\n" +
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.AchTransferAccountPayload;
|
import haveno.core.payment.payload.AchTransferAccountPayload;
|
||||||
import haveno.core.payment.payload.BankAccountPayload;
|
import haveno.core.payment.payload.BankAccountPayload;
|
||||||
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class AchTransferAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
|
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() {
|
public AchTransferAccount() {
|
||||||
super(PaymentMethod.ACH_TRANSFER);
|
super(PaymentMethod.ACH_TRANSFER);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.AdvancedCashAccountPayload;
|
import haveno.core.payment.payload.AdvancedCashAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -32,13 +32,13 @@ import java.util.List;
|
|||||||
public final class AdvancedCashAccount extends PaymentAccount {
|
public final class AdvancedCashAccount extends PaymentAccount {
|
||||||
|
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("BRL"),
|
new TraditionalCurrency("BRL"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("KZT"),
|
new TraditionalCurrency("KZT"),
|
||||||
new FiatCurrency("RUB"),
|
new TraditionalCurrency("RUB"),
|
||||||
new FiatCurrency("UAH"),
|
new TraditionalCurrency("UAH"),
|
||||||
new FiatCurrency("USD"));
|
new TraditionalCurrency("USD"));
|
||||||
|
|
||||||
public AdvancedCashAccount() {
|
public AdvancedCashAccount() {
|
||||||
super(PaymentMethod.ADVANCED_CASH);
|
super(PaymentMethod.ADVANCED_CASH);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.AliPayAccountPayload;
|
import haveno.core.payment.payload.AliPayAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class AliPayAccount extends PaymentAccount {
|
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() {
|
public AliPayAccount() {
|
||||||
super(PaymentMethod.ALI_PAY);
|
super(PaymentMethod.ALI_PAY);
|
||||||
|
@ -20,7 +20,7 @@ package haveno.core.payment;
|
|||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.Country;
|
import haveno.core.locale.Country;
|
||||||
import haveno.core.locale.CountryUtil;
|
import haveno.core.locale.CountryUtil;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.AmazonGiftCardAccountPayload;
|
import haveno.core.payment.payload.AmazonGiftCardAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -33,17 +33,17 @@ import java.util.List;
|
|||||||
public final class AmazonGiftCardAccount extends PaymentAccount {
|
public final class AmazonGiftCardAccount extends PaymentAccount {
|
||||||
|
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("AUD"),
|
new TraditionalCurrency("AUD"),
|
||||||
new FiatCurrency("CAD"),
|
new TraditionalCurrency("CAD"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("INR"),
|
new TraditionalCurrency("INR"),
|
||||||
new FiatCurrency("JPY"),
|
new TraditionalCurrency("JPY"),
|
||||||
new FiatCurrency("SAR"),
|
new TraditionalCurrency("SAR"),
|
||||||
new FiatCurrency("SEK"),
|
new TraditionalCurrency("SEK"),
|
||||||
new FiatCurrency("SGD"),
|
new TraditionalCurrency("SGD"),
|
||||||
new FiatCurrency("TRY"),
|
new TraditionalCurrency("TRY"),
|
||||||
new FiatCurrency("USD")
|
new TraditionalCurrency("USD")
|
||||||
);
|
);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.AustraliaPayidAccountPayload;
|
import haveno.core.payment.payload.AustraliaPayidAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public final class AustraliaPayidAccount extends PaymentAccount {
|
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() {
|
public AustraliaPayidAccount() {
|
||||||
super(PaymentMethod.AUSTRALIA_PAYID);
|
super(PaymentMethod.AUSTRALIA_PAYID);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.BizumAccountPayload;
|
import haveno.core.payment.payload.BizumAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class BizumAccount extends CountryBasedPaymentAccount {
|
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() {
|
public BizumAccount() {
|
||||||
super(PaymentMethod.BIZUM);
|
super(PaymentMethod.BIZUM);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.CapitualAccountPayload;
|
import haveno.core.payment.payload.CapitualAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -32,10 +32,10 @@ import java.util.List;
|
|||||||
public final class CapitualAccount extends PaymentAccount {
|
public final class CapitualAccount extends PaymentAccount {
|
||||||
|
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("BRL"),
|
new TraditionalCurrency("BRL"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("USD")
|
new TraditionalCurrency("USD")
|
||||||
);
|
);
|
||||||
|
|
||||||
public CapitualAccount() {
|
public CapitualAccount() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.CashAppAccountPayload;
|
import haveno.core.payment.payload.CashAppAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class CashAppAccount extends PaymentAccount {
|
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() {
|
public CashAppAccount() {
|
||||||
super(PaymentMethod.CASH_APP);
|
super(PaymentMethod.CASH_APP);
|
||||||
|
@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public final class CashByMailAccount extends PaymentAccount {
|
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() {
|
public CashByMailAccount() {
|
||||||
super(PaymentMethod.CASH_BY_MAIL);
|
super(PaymentMethod.CASH_BY_MAIL);
|
||||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public final class CashDepositAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
|
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() {
|
public CashDepositAccount() {
|
||||||
super(PaymentMethod.CASH_DEPOSIT);
|
super(PaymentMethod.CASH_DEPOSIT);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.CelPayAccountPayload;
|
import haveno.core.payment.payload.CelPayAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -33,11 +33,11 @@ public final class CelPayAccount extends PaymentAccount {
|
|||||||
|
|
||||||
// https://github.com/bisq-network/growth/issues/231
|
// https://github.com/bisq-network/growth/issues/231
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("AUD"),
|
new TraditionalCurrency("AUD"),
|
||||||
new FiatCurrency("CAD"),
|
new TraditionalCurrency("CAD"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("HKD"),
|
new TraditionalCurrency("HKD"),
|
||||||
new FiatCurrency("USD")
|
new TraditionalCurrency("USD")
|
||||||
);
|
);
|
||||||
|
|
||||||
public CelPayAccount() {
|
public CelPayAccount() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.ChaseQuickPayAccountPayload;
|
import haveno.core.payment.payload.ChaseQuickPayAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class ChaseQuickPayAccount extends PaymentAccount {
|
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() {
|
public ChaseQuickPayAccount() {
|
||||||
super(PaymentMethod.CHASE_QUICK_PAY);
|
super(PaymentMethod.CHASE_QUICK_PAY);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.BankAccountPayload;
|
import haveno.core.payment.payload.BankAccountPayload;
|
||||||
import haveno.core.payment.payload.DomesticWireTransferAccountPayload;
|
import haveno.core.payment.payload.DomesticWireTransferAccountPayload;
|
||||||
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class DomesticWireTransferAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
|
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() {
|
public DomesticWireTransferAccount() {
|
||||||
super(PaymentMethod.DOMESTIC_WIRE_TRANSFER);
|
super(PaymentMethod.DOMESTIC_WIRE_TRANSFER);
|
||||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class F2FAccount extends CountryBasedPaymentAccount {
|
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(
|
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.FasterPaymentsAccountPayload;
|
import haveno.core.payment.payload.FasterPaymentsAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -39,7 +39,7 @@ public final class FasterPaymentsAccount extends PaymentAccount {
|
|||||||
PaymentAccountFormField.FieldId.SALT
|
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() {
|
public FasterPaymentsAccount() {
|
||||||
super(PaymentMethod.FASTER_PAYMENTS);
|
super(PaymentMethod.FASTER_PAYMENTS);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.HalCashAccountPayload;
|
import haveno.core.payment.payload.HalCashAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class HalCashAccount extends PaymentAccount {
|
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() {
|
public HalCashAccount() {
|
||||||
super(PaymentMethod.HAL_CASH);
|
super(PaymentMethod.HAL_CASH);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -27,7 +27,7 @@ import java.util.List;
|
|||||||
|
|
||||||
abstract public class IfscBasedAccount extends CountryBasedPaymentAccount {
|
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) {
|
protected IfscBasedAccount(PaymentMethod paymentMethod) {
|
||||||
super(paymentMethod);
|
super(paymentMethod);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.ImpsAccountPayload;
|
import haveno.core.payment.payload.ImpsAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class ImpsAccount extends CountryBasedPaymentAccount {
|
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() {
|
public ImpsAccount() {
|
||||||
super(PaymentMethod.IMPS);
|
super(PaymentMethod.IMPS);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.InteracETransferAccountPayload;
|
import haveno.core.payment.payload.InteracETransferAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class InteracETransferAccount extends PaymentAccount {
|
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() {
|
public InteracETransferAccount() {
|
||||||
super(PaymentMethod.INTERAC_E_TRANSFER);
|
super(PaymentMethod.INTERAC_E_TRANSFER);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.JapanBankAccountPayload;
|
import haveno.core.payment.payload.JapanBankAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public final class JapanBankAccount extends PaymentAccount {
|
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() {
|
public JapanBankAccount() {
|
||||||
super(PaymentMethod.JAPAN_BANK);
|
super(PaymentMethod.JAPAN_BANK);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.MoneseAccountPayload;
|
import haveno.core.payment.payload.MoneseAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -33,9 +33,9 @@ public final class MoneseAccount extends PaymentAccount {
|
|||||||
|
|
||||||
// https://github.com/bisq-network/growth/issues/227
|
// https://github.com/bisq-network/growth/issues/227
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("RON")
|
new TraditionalCurrency("RON")
|
||||||
);
|
);
|
||||||
|
|
||||||
public MoneseAccount() {
|
public MoneseAccount() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.MoneyBeamAccountPayload;
|
import haveno.core.payment.payload.MoneyBeamAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class MoneyBeamAccount extends PaymentAccount {
|
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() {
|
public MoneyBeamAccount() {
|
||||||
super(PaymentMethod.MONEY_BEAM);
|
super(PaymentMethod.MONEY_BEAM);
|
||||||
|
@ -20,7 +20,7 @@ package haveno.core.payment;
|
|||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.Country;
|
import haveno.core.locale.Country;
|
||||||
import haveno.core.locale.CountryUtil;
|
import haveno.core.locale.CountryUtil;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.MoneyGramAccountPayload;
|
import haveno.core.payment.payload.MoneyGramAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
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(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("AED"),
|
new TraditionalCurrency("AED"),
|
||||||
new FiatCurrency("ARS"),
|
new TraditionalCurrency("ARS"),
|
||||||
new FiatCurrency("AUD"),
|
new TraditionalCurrency("AUD"),
|
||||||
new FiatCurrency("BND"),
|
new TraditionalCurrency("BND"),
|
||||||
new FiatCurrency("CAD"),
|
new TraditionalCurrency("CAD"),
|
||||||
new FiatCurrency("CHF"),
|
new TraditionalCurrency("CHF"),
|
||||||
new FiatCurrency("CZK"),
|
new TraditionalCurrency("CZK"),
|
||||||
new FiatCurrency("DKK"),
|
new TraditionalCurrency("DKK"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("FJD"),
|
new TraditionalCurrency("FJD"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("HKD"),
|
new TraditionalCurrency("HKD"),
|
||||||
new FiatCurrency("HUF"),
|
new TraditionalCurrency("HUF"),
|
||||||
new FiatCurrency("IDR"),
|
new TraditionalCurrency("IDR"),
|
||||||
new FiatCurrency("ILS"),
|
new TraditionalCurrency("ILS"),
|
||||||
new FiatCurrency("INR"),
|
new TraditionalCurrency("INR"),
|
||||||
new FiatCurrency("JPY"),
|
new TraditionalCurrency("JPY"),
|
||||||
new FiatCurrency("KRW"),
|
new TraditionalCurrency("KRW"),
|
||||||
new FiatCurrency("KWD"),
|
new TraditionalCurrency("KWD"),
|
||||||
new FiatCurrency("LKR"),
|
new TraditionalCurrency("LKR"),
|
||||||
new FiatCurrency("MAD"),
|
new TraditionalCurrency("MAD"),
|
||||||
new FiatCurrency("MGA"),
|
new TraditionalCurrency("MGA"),
|
||||||
new FiatCurrency("MXN"),
|
new TraditionalCurrency("MXN"),
|
||||||
new FiatCurrency("MYR"),
|
new TraditionalCurrency("MYR"),
|
||||||
new FiatCurrency("NOK"),
|
new TraditionalCurrency("NOK"),
|
||||||
new FiatCurrency("NZD"),
|
new TraditionalCurrency("NZD"),
|
||||||
new FiatCurrency("OMR"),
|
new TraditionalCurrency("OMR"),
|
||||||
new FiatCurrency("PEN"),
|
new TraditionalCurrency("PEN"),
|
||||||
new FiatCurrency("PGK"),
|
new TraditionalCurrency("PGK"),
|
||||||
new FiatCurrency("PHP"),
|
new TraditionalCurrency("PHP"),
|
||||||
new FiatCurrency("PKR"),
|
new TraditionalCurrency("PKR"),
|
||||||
new FiatCurrency("PLN"),
|
new TraditionalCurrency("PLN"),
|
||||||
new FiatCurrency("SAR"),
|
new TraditionalCurrency("SAR"),
|
||||||
new FiatCurrency("SBD"),
|
new TraditionalCurrency("SBD"),
|
||||||
new FiatCurrency("SCR"),
|
new TraditionalCurrency("SCR"),
|
||||||
new FiatCurrency("SEK"),
|
new TraditionalCurrency("SEK"),
|
||||||
new FiatCurrency("SGD"),
|
new TraditionalCurrency("SGD"),
|
||||||
new FiatCurrency("THB"),
|
new TraditionalCurrency("THB"),
|
||||||
new FiatCurrency("TOP"),
|
new TraditionalCurrency("TOP"),
|
||||||
new FiatCurrency("TRY"),
|
new TraditionalCurrency("TRY"),
|
||||||
new FiatCurrency("TWD"),
|
new TraditionalCurrency("TWD"),
|
||||||
new FiatCurrency("USD"),
|
new TraditionalCurrency("USD"),
|
||||||
new FiatCurrency("VND"),
|
new TraditionalCurrency("VND"),
|
||||||
new FiatCurrency("VUV"),
|
new TraditionalCurrency("VUV"),
|
||||||
new FiatCurrency("WST"),
|
new TraditionalCurrency("WST"),
|
||||||
new FiatCurrency("XOF"),
|
new TraditionalCurrency("XOF"),
|
||||||
new FiatCurrency("XPF"),
|
new TraditionalCurrency("XPF"),
|
||||||
new FiatCurrency("ZAR")
|
new TraditionalCurrency("ZAR")
|
||||||
);
|
);
|
||||||
|
|
||||||
public MoneyGramAccount() {
|
public MoneyGramAccount() {
|
||||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class NationalBankAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
|
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() {
|
public NationalBankAccount() {
|
||||||
super(PaymentMethod.NATIONAL_BANK);
|
super(PaymentMethod.NATIONAL_BANK);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.NequiAccountPayload;
|
import haveno.core.payment.payload.NequiAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class NequiAccount extends CountryBasedPaymentAccount {
|
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() {
|
public NequiAccount() {
|
||||||
super(PaymentMethod.NEQUI);
|
super(PaymentMethod.NEQUI);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.OKPayAccountPayload;
|
import haveno.core.payment.payload.OKPayAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -34,29 +34,29 @@ import java.util.List;
|
|||||||
public final class OKPayAccount extends PaymentAccount {
|
public final class OKPayAccount extends PaymentAccount {
|
||||||
|
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("AED"),
|
new TraditionalCurrency("AED"),
|
||||||
new FiatCurrency("ARS"),
|
new TraditionalCurrency("ARS"),
|
||||||
new FiatCurrency("AUD"),
|
new TraditionalCurrency("AUD"),
|
||||||
new FiatCurrency("BRL"),
|
new TraditionalCurrency("BRL"),
|
||||||
new FiatCurrency("CAD"),
|
new TraditionalCurrency("CAD"),
|
||||||
new FiatCurrency("CHF"),
|
new TraditionalCurrency("CHF"),
|
||||||
new FiatCurrency("CNY"),
|
new TraditionalCurrency("CNY"),
|
||||||
new FiatCurrency("DKK"),
|
new TraditionalCurrency("DKK"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("HKD"),
|
new TraditionalCurrency("HKD"),
|
||||||
new FiatCurrency("ILS"),
|
new TraditionalCurrency("ILS"),
|
||||||
new FiatCurrency("INR"),
|
new TraditionalCurrency("INR"),
|
||||||
new FiatCurrency("JPY"),
|
new TraditionalCurrency("JPY"),
|
||||||
new FiatCurrency("KES"),
|
new TraditionalCurrency("KES"),
|
||||||
new FiatCurrency("MXN"),
|
new TraditionalCurrency("MXN"),
|
||||||
new FiatCurrency("NOK"),
|
new TraditionalCurrency("NOK"),
|
||||||
new FiatCurrency("NZD"),
|
new TraditionalCurrency("NZD"),
|
||||||
new FiatCurrency("PHP"),
|
new TraditionalCurrency("PHP"),
|
||||||
new FiatCurrency("PLN"),
|
new TraditionalCurrency("PLN"),
|
||||||
new FiatCurrency("SEK"),
|
new TraditionalCurrency("SEK"),
|
||||||
new FiatCurrency("SGD"),
|
new TraditionalCurrency("SGD"),
|
||||||
new FiatCurrency("USD")
|
new TraditionalCurrency("USD")
|
||||||
);
|
);
|
||||||
|
|
||||||
public OKPayAccount() {
|
public OKPayAccount() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaxumAccountPayload;
|
import haveno.core.payment.payload.PaxumAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -40,24 +40,24 @@ public final class PaxumAccount extends PaymentAccount {
|
|||||||
|
|
||||||
// https://github.com/bisq-network/growth/issues/235
|
// https://github.com/bisq-network/growth/issues/235
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("AUD"),
|
new TraditionalCurrency("AUD"),
|
||||||
new FiatCurrency("CAD"),
|
new TraditionalCurrency("CAD"),
|
||||||
new FiatCurrency("CHF"),
|
new TraditionalCurrency("CHF"),
|
||||||
new FiatCurrency("CZK"),
|
new TraditionalCurrency("CZK"),
|
||||||
new FiatCurrency("DKK"),
|
new TraditionalCurrency("DKK"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("HUF"),
|
new TraditionalCurrency("HUF"),
|
||||||
new FiatCurrency("IDR"),
|
new TraditionalCurrency("IDR"),
|
||||||
new FiatCurrency("INR"),
|
new TraditionalCurrency("INR"),
|
||||||
new FiatCurrency("NOK"),
|
new TraditionalCurrency("NOK"),
|
||||||
new FiatCurrency("NZD"),
|
new TraditionalCurrency("NZD"),
|
||||||
new FiatCurrency("PLN"),
|
new TraditionalCurrency("PLN"),
|
||||||
new FiatCurrency("RON"),
|
new TraditionalCurrency("RON"),
|
||||||
new FiatCurrency("SEK"),
|
new TraditionalCurrency("SEK"),
|
||||||
new FiatCurrency("THB"),
|
new TraditionalCurrency("THB"),
|
||||||
new FiatCurrency("USD"),
|
new TraditionalCurrency("USD"),
|
||||||
new FiatCurrency("ZAR")
|
new TraditionalCurrency("ZAR")
|
||||||
);
|
);
|
||||||
|
|
||||||
public PaxumAccount() {
|
public PaxumAccount() {
|
||||||
|
@ -24,7 +24,7 @@ import com.google.gson.stream.JsonToken;
|
|||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import haveno.core.locale.Country;
|
import haveno.core.locale.Country;
|
||||||
import haveno.core.locale.CountryUtil;
|
import haveno.core.locale.CountryUtil;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.Res;
|
import haveno.core.locale.Res;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
@ -435,7 +435,7 @@ class PaymentAccountTypeAdapter extends TypeAdapter<PaymentAccount> {
|
|||||||
|
|
||||||
if (account.isCountryBasedPaymentAccount()) {
|
if (account.isCountryBasedPaymentAccount()) {
|
||||||
((CountryBasedPaymentAccount) account).setCountry(country.get());
|
((CountryBasedPaymentAccount) account).setCountry(country.get());
|
||||||
FiatCurrency fiatCurrency = getCurrencyByCountryCode(checkNotNull(countryCode));
|
TraditionalCurrency fiatCurrency = getCurrencyByCountryCode(checkNotNull(countryCode));
|
||||||
account.setSingleTradeCurrency(fiatCurrency);
|
account.setSingleTradeCurrency(fiatCurrency);
|
||||||
} else if (account.hasPaymentMethodWithId(MONEY_GRAM_ID)) {
|
} else if (account.hasPaymentMethodWithId(MONEY_GRAM_ID)) {
|
||||||
((MoneyGramAccount) account).setCountry(country.get());
|
((MoneyGramAccount) account).setCountry(country.get());
|
||||||
|
@ -295,7 +295,7 @@ public class PaymentAccountUtil {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String getCountryCode(PaymentAccount paymentAccount) {
|
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) {
|
if (paymentAccount instanceof CountryBasedPaymentAccount) {
|
||||||
Country country = (((CountryBasedPaymentAccount) paymentAccount)).getCountry();
|
Country country = (((CountryBasedPaymentAccount) paymentAccount)).getCountry();
|
||||||
return country != null ? country.code : null;
|
return country != null ? country.code : null;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -33,38 +33,38 @@ public final class PayseraAccount extends PaymentAccount {
|
|||||||
|
|
||||||
// https://github.com/bisq-network/growth/issues/233
|
// https://github.com/bisq-network/growth/issues/233
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("AUD"),
|
new TraditionalCurrency("AUD"),
|
||||||
new FiatCurrency("BGN"),
|
new TraditionalCurrency("BGN"),
|
||||||
new FiatCurrency("BYN"),
|
new TraditionalCurrency("BYN"),
|
||||||
new FiatCurrency("CAD"),
|
new TraditionalCurrency("CAD"),
|
||||||
new FiatCurrency("CHF"),
|
new TraditionalCurrency("CHF"),
|
||||||
new FiatCurrency("CNY"),
|
new TraditionalCurrency("CNY"),
|
||||||
new FiatCurrency("CZK"),
|
new TraditionalCurrency("CZK"),
|
||||||
new FiatCurrency("DKK"),
|
new TraditionalCurrency("DKK"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("GEL"),
|
new TraditionalCurrency("GEL"),
|
||||||
new FiatCurrency("HKD"),
|
new TraditionalCurrency("HKD"),
|
||||||
new FiatCurrency("HRK"),
|
new TraditionalCurrency("HRK"),
|
||||||
new FiatCurrency("HUF"),
|
new TraditionalCurrency("HUF"),
|
||||||
new FiatCurrency("ILS"),
|
new TraditionalCurrency("ILS"),
|
||||||
new FiatCurrency("INR"),
|
new TraditionalCurrency("INR"),
|
||||||
new FiatCurrency("JPY"),
|
new TraditionalCurrency("JPY"),
|
||||||
new FiatCurrency("KZT"),
|
new TraditionalCurrency("KZT"),
|
||||||
new FiatCurrency("MXN"),
|
new TraditionalCurrency("MXN"),
|
||||||
new FiatCurrency("NOK"),
|
new TraditionalCurrency("NOK"),
|
||||||
new FiatCurrency("NZD"),
|
new TraditionalCurrency("NZD"),
|
||||||
new FiatCurrency("PHP"),
|
new TraditionalCurrency("PHP"),
|
||||||
new FiatCurrency("PLN"),
|
new TraditionalCurrency("PLN"),
|
||||||
new FiatCurrency("RON"),
|
new TraditionalCurrency("RON"),
|
||||||
new FiatCurrency("RSD"),
|
new TraditionalCurrency("RSD"),
|
||||||
new FiatCurrency("RUB"),
|
new TraditionalCurrency("RUB"),
|
||||||
new FiatCurrency("SEK"),
|
new TraditionalCurrency("SEK"),
|
||||||
new FiatCurrency("SGD"),
|
new TraditionalCurrency("SGD"),
|
||||||
new FiatCurrency("THB"),
|
new TraditionalCurrency("THB"),
|
||||||
new FiatCurrency("TRY"),
|
new TraditionalCurrency("TRY"),
|
||||||
new FiatCurrency("USD"),
|
new TraditionalCurrency("USD"),
|
||||||
new FiatCurrency("ZAR")
|
new TraditionalCurrency("ZAR")
|
||||||
);
|
);
|
||||||
|
|
||||||
public PayseraAccount() {
|
public PayseraAccount() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class PerfectMoneyAccount extends PaymentAccount {
|
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() {
|
public PerfectMoneyAccount() {
|
||||||
super(PaymentMethod.PERFECT_MONEY);
|
super(PaymentMethod.PERFECT_MONEY);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class PixAccount extends CountryBasedPaymentAccount {
|
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() {
|
public PixAccount() {
|
||||||
super(PaymentMethod.PIX);
|
super(PaymentMethod.PIX);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class PopmoneyAccount extends PaymentAccount {
|
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() {
|
public PopmoneyAccount() {
|
||||||
super(PaymentMethod.POPMONEY);
|
super(PaymentMethod.POPMONEY);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class PromptPayAccount extends PaymentAccount {
|
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() {
|
public PromptPayAccount() {
|
||||||
super(PaymentMethod.PROMPT_PAY);
|
super(PaymentMethod.PROMPT_PAY);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
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
|
// 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(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("AED"),
|
new TraditionalCurrency("AED"),
|
||||||
new FiatCurrency("AUD"),
|
new TraditionalCurrency("AUD"),
|
||||||
new FiatCurrency("BGN"),
|
new TraditionalCurrency("BGN"),
|
||||||
new FiatCurrency("CAD"),
|
new TraditionalCurrency("CAD"),
|
||||||
new FiatCurrency("CHF"),
|
new TraditionalCurrency("CHF"),
|
||||||
new FiatCurrency("CZK"),
|
new TraditionalCurrency("CZK"),
|
||||||
new FiatCurrency("DKK"),
|
new TraditionalCurrency("DKK"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("HKD"),
|
new TraditionalCurrency("HKD"),
|
||||||
new FiatCurrency("HRK"),
|
new TraditionalCurrency("HRK"),
|
||||||
new FiatCurrency("HUF"),
|
new TraditionalCurrency("HUF"),
|
||||||
new FiatCurrency("ILS"),
|
new TraditionalCurrency("ILS"),
|
||||||
new FiatCurrency("ISK"),
|
new TraditionalCurrency("ISK"),
|
||||||
new FiatCurrency("JPY"),
|
new TraditionalCurrency("JPY"),
|
||||||
new FiatCurrency("MAD"),
|
new TraditionalCurrency("MAD"),
|
||||||
new FiatCurrency("MXN"),
|
new TraditionalCurrency("MXN"),
|
||||||
new FiatCurrency("NOK"),
|
new TraditionalCurrency("NOK"),
|
||||||
new FiatCurrency("NZD"),
|
new TraditionalCurrency("NZD"),
|
||||||
new FiatCurrency("PLN"),
|
new TraditionalCurrency("PLN"),
|
||||||
new FiatCurrency("QAR"),
|
new TraditionalCurrency("QAR"),
|
||||||
new FiatCurrency("RON"),
|
new TraditionalCurrency("RON"),
|
||||||
new FiatCurrency("RSD"),
|
new TraditionalCurrency("RSD"),
|
||||||
new FiatCurrency("RUB"),
|
new TraditionalCurrency("RUB"),
|
||||||
new FiatCurrency("SAR"),
|
new TraditionalCurrency("SAR"),
|
||||||
new FiatCurrency("SEK"),
|
new TraditionalCurrency("SEK"),
|
||||||
new FiatCurrency("SGD"),
|
new TraditionalCurrency("SGD"),
|
||||||
new FiatCurrency("THB"),
|
new TraditionalCurrency("THB"),
|
||||||
new FiatCurrency("TRY"),
|
new TraditionalCurrency("TRY"),
|
||||||
new FiatCurrency("USD"),
|
new TraditionalCurrency("USD"),
|
||||||
new FiatCurrency("ZAR")
|
new TraditionalCurrency("ZAR")
|
||||||
);
|
);
|
||||||
|
|
||||||
public RevolutAccount() {
|
public RevolutAccount() {
|
||||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class SameBankAccount extends CountryBasedPaymentAccount implements BankNameRestrictedBankAccount, SameCountryRestrictedBankAccount {
|
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() {
|
public SameBankAccount() {
|
||||||
super(PaymentMethod.SAME_BANK);
|
super(PaymentMethod.SAME_BANK);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class SatispayAccount extends CountryBasedPaymentAccount {
|
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() {
|
public SatispayAccount() {
|
||||||
super(PaymentMethod.SATISPAY);
|
super(PaymentMethod.SATISPAY);
|
||||||
|
@ -21,7 +21,7 @@ import haveno.core.api.model.PaymentAccountForm;
|
|||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.Country;
|
import haveno.core.locale.Country;
|
||||||
import haveno.core.locale.CountryUtil;
|
import haveno.core.locale.CountryUtil;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -46,7 +46,7 @@ public final class SepaAccount extends CountryBasedPaymentAccount implements Ban
|
|||||||
PaymentAccountFormField.FieldId.SALT
|
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() {
|
public SepaAccount() {
|
||||||
super(PaymentMethod.SEPA);
|
super(PaymentMethod.SEPA);
|
||||||
|
@ -21,7 +21,7 @@ import haveno.core.api.model.PaymentAccountForm;
|
|||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.Country;
|
import haveno.core.locale.Country;
|
||||||
import haveno.core.locale.CountryUtil;
|
import haveno.core.locale.CountryUtil;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -36,7 +36,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class SepaInstantAccount extends CountryBasedPaymentAccount implements BankAccount {
|
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() {
|
public SepaInstantAccount() {
|
||||||
super(PaymentMethod.SEPA_INSTANT);
|
super(PaymentMethod.SEPA_INSTANT);
|
||||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class SpecificBanksAccount extends CountryBasedPaymentAccount implements BankNameRestrictedBankAccount, SameCountryRestrictedBankAccount {
|
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() {
|
public SpecificBanksAccount() {
|
||||||
super(PaymentMethod.SPECIFIC_BANKS);
|
super(PaymentMethod.SPECIFIC_BANKS);
|
||||||
|
@ -20,7 +20,7 @@ package haveno.core.payment;
|
|||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.Country;
|
import haveno.core.locale.Country;
|
||||||
import haveno.core.locale.CountryUtil;
|
import haveno.core.locale.CountryUtil;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class StrikeAccount extends CountryBasedPaymentAccount {
|
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"));
|
public static final List<Country> SUPPORTED_COUNTRIES = CountryUtil.getCountries(List.of("US"));
|
||||||
|
|
||||||
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static haveno.core.locale.CurrencyUtil.getAllSortedFiatCurrencies;
|
import static haveno.core.locale.CurrencyUtil.getAllSortedTraditionalCurrencies;
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class SwiftAccount extends PaymentAccount {
|
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(
|
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
|
||||||
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
PaymentAccountFormField.FieldId.ACCOUNT_NAME,
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class SwishAccount extends PaymentAccount {
|
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() {
|
public SwishAccount() {
|
||||||
super(PaymentMethod.SWISH);
|
super(PaymentMethod.SWISH);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class TikkieAccount extends CountryBasedPaymentAccount {
|
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() {
|
public TikkieAccount() {
|
||||||
super(PaymentMethod.TIKKIE);
|
super(PaymentMethod.TIKKIE);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -40,48 +40,48 @@ public final class TransferwiseAccount extends PaymentAccount {
|
|||||||
|
|
||||||
// https://github.com/bisq-network/proposals/issues/243
|
// https://github.com/bisq-network/proposals/issues/243
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("AED"),
|
new TraditionalCurrency("AED"),
|
||||||
new FiatCurrency("ARS"),
|
new TraditionalCurrency("ARS"),
|
||||||
new FiatCurrency("AUD"),
|
new TraditionalCurrency("AUD"),
|
||||||
new FiatCurrency("BGN"),
|
new TraditionalCurrency("BGN"),
|
||||||
new FiatCurrency("CAD"),
|
new TraditionalCurrency("CAD"),
|
||||||
new FiatCurrency("CHF"),
|
new TraditionalCurrency("CHF"),
|
||||||
new FiatCurrency("CLP"),
|
new TraditionalCurrency("CLP"),
|
||||||
new FiatCurrency("CZK"),
|
new TraditionalCurrency("CZK"),
|
||||||
new FiatCurrency("DKK"),
|
new TraditionalCurrency("DKK"),
|
||||||
new FiatCurrency("EGP"),
|
new TraditionalCurrency("EGP"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("GEL"),
|
new TraditionalCurrency("GEL"),
|
||||||
new FiatCurrency("HKD"),
|
new TraditionalCurrency("HKD"),
|
||||||
new FiatCurrency("HRK"),
|
new TraditionalCurrency("HRK"),
|
||||||
new FiatCurrency("HUF"),
|
new TraditionalCurrency("HUF"),
|
||||||
new FiatCurrency("IDR"),
|
new TraditionalCurrency("IDR"),
|
||||||
new FiatCurrency("ILS"),
|
new TraditionalCurrency("ILS"),
|
||||||
new FiatCurrency("JPY"),
|
new TraditionalCurrency("JPY"),
|
||||||
new FiatCurrency("KES"),
|
new TraditionalCurrency("KES"),
|
||||||
new FiatCurrency("KRW"),
|
new TraditionalCurrency("KRW"),
|
||||||
new FiatCurrency("MAD"),
|
new TraditionalCurrency("MAD"),
|
||||||
new FiatCurrency("MXN"),
|
new TraditionalCurrency("MXN"),
|
||||||
new FiatCurrency("MYR"),
|
new TraditionalCurrency("MYR"),
|
||||||
new FiatCurrency("NOK"),
|
new TraditionalCurrency("NOK"),
|
||||||
new FiatCurrency("NPR"),
|
new TraditionalCurrency("NPR"),
|
||||||
new FiatCurrency("NZD"),
|
new TraditionalCurrency("NZD"),
|
||||||
new FiatCurrency("PEN"),
|
new TraditionalCurrency("PEN"),
|
||||||
new FiatCurrency("PHP"),
|
new TraditionalCurrency("PHP"),
|
||||||
new FiatCurrency("PKR"),
|
new TraditionalCurrency("PKR"),
|
||||||
new FiatCurrency("PLN"),
|
new TraditionalCurrency("PLN"),
|
||||||
new FiatCurrency("RON"),
|
new TraditionalCurrency("RON"),
|
||||||
new FiatCurrency("RUB"),
|
new TraditionalCurrency("RUB"),
|
||||||
new FiatCurrency("SEK"),
|
new TraditionalCurrency("SEK"),
|
||||||
new FiatCurrency("SGD"),
|
new TraditionalCurrency("SGD"),
|
||||||
new FiatCurrency("THB"),
|
new TraditionalCurrency("THB"),
|
||||||
new FiatCurrency("TRY"),
|
new TraditionalCurrency("TRY"),
|
||||||
new FiatCurrency("UGX"),
|
new TraditionalCurrency("UGX"),
|
||||||
new FiatCurrency("VND"),
|
new TraditionalCurrency("VND"),
|
||||||
new FiatCurrency("XOF"),
|
new TraditionalCurrency("XOF"),
|
||||||
new FiatCurrency("ZAR"),
|
new TraditionalCurrency("ZAR"),
|
||||||
new FiatCurrency("ZMW")
|
new TraditionalCurrency("ZMW")
|
||||||
);
|
);
|
||||||
|
|
||||||
public TransferwiseAccount() {
|
public TransferwiseAccount() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class TransferwiseUsdAccount extends CountryBasedPaymentAccount {
|
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() {
|
public TransferwiseUsdAccount() {
|
||||||
super(PaymentMethod.TRANSFERWISE_USD);
|
super(PaymentMethod.TRANSFERWISE_USD);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class USPostalMoneyOrderAccount extends PaymentAccount {
|
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() {
|
public USPostalMoneyOrderAccount() {
|
||||||
super(PaymentMethod.US_POSTAL_MONEY_ORDER);
|
super(PaymentMethod.US_POSTAL_MONEY_ORDER);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
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
|
// https://support.uphold.com/hc/en-us/articles/202473803-Supported-currencies
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("AED"),
|
new TraditionalCurrency("AED"),
|
||||||
new FiatCurrency("ARS"),
|
new TraditionalCurrency("ARS"),
|
||||||
new FiatCurrency("AUD"),
|
new TraditionalCurrency("AUD"),
|
||||||
new FiatCurrency("BRL"),
|
new TraditionalCurrency("BRL"),
|
||||||
new FiatCurrency("CAD"),
|
new TraditionalCurrency("CAD"),
|
||||||
new FiatCurrency("CHF"),
|
new TraditionalCurrency("CHF"),
|
||||||
new FiatCurrency("CNY"),
|
new TraditionalCurrency("CNY"),
|
||||||
new FiatCurrency("DKK"),
|
new TraditionalCurrency("DKK"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("GBP"),
|
new TraditionalCurrency("GBP"),
|
||||||
new FiatCurrency("HKD"),
|
new TraditionalCurrency("HKD"),
|
||||||
new FiatCurrency("ILS"),
|
new TraditionalCurrency("ILS"),
|
||||||
new FiatCurrency("INR"),
|
new TraditionalCurrency("INR"),
|
||||||
new FiatCurrency("JPY"),
|
new TraditionalCurrency("JPY"),
|
||||||
new FiatCurrency("KES"),
|
new TraditionalCurrency("KES"),
|
||||||
new FiatCurrency("MXN"),
|
new TraditionalCurrency("MXN"),
|
||||||
new FiatCurrency("NOK"),
|
new TraditionalCurrency("NOK"),
|
||||||
new FiatCurrency("NZD"),
|
new TraditionalCurrency("NZD"),
|
||||||
new FiatCurrency("PHP"),
|
new TraditionalCurrency("PHP"),
|
||||||
new FiatCurrency("PLN"),
|
new TraditionalCurrency("PLN"),
|
||||||
new FiatCurrency("SEK"),
|
new TraditionalCurrency("SEK"),
|
||||||
new FiatCurrency("SGD"),
|
new TraditionalCurrency("SGD"),
|
||||||
new FiatCurrency("USD")
|
new TraditionalCurrency("USD")
|
||||||
);
|
);
|
||||||
|
|
||||||
public UpholdAccount() {
|
public UpholdAccount() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class VenmoAccount extends PaymentAccount {
|
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() {
|
public VenmoAccount() {
|
||||||
super(PaymentMethod.VENMO);
|
super(PaymentMethod.VENMO);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -33,11 +33,11 @@ public final class VerseAccount extends PaymentAccount {
|
|||||||
|
|
||||||
// https://github.com/bisq-network/growth/issues/223
|
// https://github.com/bisq-network/growth/issues/223
|
||||||
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = List.of(
|
||||||
new FiatCurrency("DKK"),
|
new TraditionalCurrency("DKK"),
|
||||||
new FiatCurrency("EUR"),
|
new TraditionalCurrency("EUR"),
|
||||||
new FiatCurrency("HUF"),
|
new TraditionalCurrency("HUF"),
|
||||||
new FiatCurrency("PLN"),
|
new TraditionalCurrency("PLN"),
|
||||||
new FiatCurrency("SEK")
|
new TraditionalCurrency("SEK")
|
||||||
);
|
);
|
||||||
|
|
||||||
public VerseAccount() {
|
public VerseAccount() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package haveno.core.payment;
|
package haveno.core.payment;
|
||||||
|
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
import haveno.core.locale.FiatCurrency;
|
import haveno.core.locale.TraditionalCurrency;
|
||||||
import haveno.core.locale.TradeCurrency;
|
import haveno.core.locale.TradeCurrency;
|
||||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||||
import haveno.core.payment.payload.PaymentMethod;
|
import haveno.core.payment.payload.PaymentMethod;
|
||||||
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public final class WeChatPayAccount extends PaymentAccount {
|
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() {
|
public WeChatPayAccount() {
|
||||||
super(PaymentMethod.WECHAT_PAY);
|
super(PaymentMethod.WECHAT_PAY);
|
||||||
|
@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public final class WesternUnionAccount extends CountryBasedPaymentAccount {
|
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() {
|
public WesternUnionAccount() {
|
||||||
super(PaymentMethod.WESTERN_UNION);
|
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