diff --git a/assets/src/main/java/bisq/asset/LiquidBitcoinAddressValidator.java b/assets/src/main/java/bisq/asset/LiquidBitcoinAddressValidator.java new file mode 100644 index 0000000000..b8861bb108 --- /dev/null +++ b/assets/src/main/java/bisq/asset/LiquidBitcoinAddressValidator.java @@ -0,0 +1,12 @@ +package bisq.asset; + +public class LiquidBitcoinAddressValidator extends RegexAddressValidator { + static private final String REGEX = "^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,87}|[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,87})$"; + public LiquidBitcoinAddressValidator() { + super(REGEX); + } + + public LiquidBitcoinAddressValidator(String regex, String errorMessageI18nKey) { + super(REGEX, "validation.altcoin.liquidBitcoin.invalidAddress"); + } +} diff --git a/assets/src/main/java/bisq/asset/coins/LiquidBitcoin.java b/assets/src/main/java/bisq/asset/coins/LiquidBitcoin.java index 6d77350994..3c0be367b0 100644 --- a/assets/src/main/java/bisq/asset/coins/LiquidBitcoin.java +++ b/assets/src/main/java/bisq/asset/coins/LiquidBitcoin.java @@ -19,12 +19,13 @@ package bisq.asset.coins; import bisq.asset.AltCoinAccountDisclaimer; import bisq.asset.Coin; +import bisq.asset.LiquidBitcoinAddressValidator; import bisq.asset.RegexAddressValidator; @AltCoinAccountDisclaimer("account.altcoin.popup.liquidbitcoin.msg") public class LiquidBitcoin extends Coin { public LiquidBitcoin() { - super("Liquid Bitcoin", "L-BTC", new RegexAddressValidator("^([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})$", "validation.altcoin.liquidBitcoin.invalidAddress")); + super("Liquid Bitcoin", "L-BTC", new LiquidBitcoinAddressValidator()); } } diff --git a/assets/src/main/java/bisq/asset/coins/TetherUSDLiquid.java b/assets/src/main/java/bisq/asset/coins/TetherUSDLiquid.java new file mode 100644 index 0000000000..b5b50a8ad1 --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/TetherUSDLiquid.java @@ -0,0 +1,12 @@ +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.LiquidBitcoinAddressValidator; + +public class TetherUSDLiquid extends Coin { + public TetherUSDLiquid() { + // If you add a new USDT variant or want to change this ticker symbol you should also look here: + // core/src/main/java/bisq/core/provider/price/PriceProvider.java:getAll() + super("Tether USD (Liquid Bitcoin)", "L-USDT", new LiquidBitcoinAddressValidator()); + } +} diff --git a/assets/src/main/java/bisq/asset/coins/TetherUSDOmni.java b/assets/src/main/java/bisq/asset/coins/TetherUSDOmni.java new file mode 100644 index 0000000000..b0ab624d71 --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/TetherUSDOmni.java @@ -0,0 +1,12 @@ +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; + +public class TetherUSDOmni extends Coin { + public TetherUSDOmni() { + // If you add a new USDT variant or want to change this ticker symbol you should also look here: + // core/src/main/java/bisq/core/provider/price/PriceProvider.java:getAll() + super("Tether USD (Omni)", "USDT-O", new Base58BitcoinAddressValidator()); + } +} diff --git a/assets/src/main/java/bisq/asset/tokens/TetherUSDERC20.java b/assets/src/main/java/bisq/asset/tokens/TetherUSDERC20.java new file mode 100644 index 0000000000..cb57361a1f --- /dev/null +++ b/assets/src/main/java/bisq/asset/tokens/TetherUSDERC20.java @@ -0,0 +1,11 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class TetherUSDERC20 extends Erc20Token { + public TetherUSDERC20() { + // If you add a new USDT variant or want to change this ticker symbol you should also look here: + // core/src/main/java/bisq/core/provider/price/PriceProvider.java:getAll() + super("Tether USD (ERC20)", "USDT-E"); + } +} diff --git a/assets/src/main/resources/META-INF/services/bisq.asset.Asset b/assets/src/main/resources/META-INF/services/bisq.asset.Asset index 80a6168463..a2f77816d6 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -104,6 +104,8 @@ bisq.asset.coins.Spectrecoin bisq.asset.coins.Starwels bisq.asset.coins.SUB1X bisq.asset.coins.TEO +bisq.asset.coins.TetherUSDLiquid +bisq.asset.coins.TetherUSDOmni bisq.asset.coins.TurtleCoin bisq.asset.coins.UnitedCommunityCoin bisq.asset.coins.Unobtanium @@ -123,6 +125,7 @@ bisq.asset.coins.ZeroClassic bisq.asset.tokens.AugmintEuro bisq.asset.tokens.DaiStablecoin bisq.asset.tokens.EtherStone +bisq.asset.tokens.TetherUSDERC20 bisq.asset.tokens.TrueUSD bisq.asset.tokens.USDCoin bisq.asset.tokens.VectorspaceAI diff --git a/core/src/main/java/bisq/core/provider/price/PriceProvider.java b/core/src/main/java/bisq/core/provider/price/PriceProvider.java index d0ac27c2d7..184be90435 100644 --- a/core/src/main/java/bisq/core/provider/price/PriceProvider.java +++ b/core/src/main/java/bisq/core/provider/price/PriceProvider.java @@ -70,7 +70,12 @@ public class PriceProvider extends HttpClientProvider { final double price = (Double) treeMap.get("price"); // json uses double for our timestampSec long value... final long timestampSec = MathUtils.doubleToLong((Double) treeMap.get("timestampSec")); - marketPriceMap.put(currencyCode, new MarketPrice(currencyCode, price, timestampSec, true)); + if (currencyCode.equals("USDT")) { + addPrice(marketPriceMap, "USDT-O", price, timestampSec); + addPrice(marketPriceMap, "USDT-E", price, timestampSec); + addPrice(marketPriceMap, "L-USDT", price, timestampSec); + } + addPrice(marketPriceMap, currencyCode, price, timestampSec); } catch (Throwable t) { log.error(t.toString()); t.printStackTrace(); @@ -80,6 +85,10 @@ public class PriceProvider extends HttpClientProvider { return new Tuple2<>(tsMap, marketPriceMap); } + private void addPrice(Map marketPriceMap, String currencyCode, double price, long timestampSec) { + marketPriceMap.put(currencyCode, new MarketPrice(currencyCode, price, timestampSec, true)); + } + public String getBaseUrl() { return httpClient.getBaseUrl(); } diff --git a/desktop/src/main/java/bisq/desktop/main/MainView.java b/desktop/src/main/java/bisq/desktop/main/MainView.java index 981c819ea2..cca1f6c164 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainView.java +++ b/desktop/src/main/java/bisq/desktop/main/MainView.java @@ -534,11 +534,10 @@ public class MainView extends InitializableView String selectedCurrencyCode = model.getPriceFeedService().getCurrencyCode(); MarketPrice selectedMarketPrice = model.getPriceFeedService().getMarketPrice(selectedCurrencyCode); - return Res.get("mainView.marketPrice.tooltip", "Bisq Price Index for " + selectedCurrencyCode, "", - DisplayUtils.formatTime(new Date(selectedMarketPrice.getTimestampSec())), + selectedMarketPrice != null ? DisplayUtils.formatTime(new Date(selectedMarketPrice.getTimestampSec())) : Res.get("shared.na"), model.getPriceFeedService().getProviderNodeAddress()); }