diff --git a/assets/src/main/java/haveno/asset/RippleAddressValidator.java b/assets/src/main/java/haveno/asset/RippleAddressValidator.java new file mode 100644 index 0000000000..7325818143 --- /dev/null +++ b/assets/src/main/java/haveno/asset/RippleAddressValidator.java @@ -0,0 +1,32 @@ +/* + * 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 . + */ + +package haveno.asset; + +/** + * Validates a Ripple address using a regular expression. + */ +public class RippleAddressValidator extends RegexAddressValidator { + + public RippleAddressValidator() { + super("^r[1-9A-HJ-NP-Za-km-z]{25,34}$"); + } + + public RippleAddressValidator(String errorMessageI18nKey) { + super("^r[1-9A-HJ-NP-Za-km-z]{25,34}$", errorMessageI18nKey); + } +} diff --git a/assets/src/main/java/haveno/asset/coins/Ripple.java b/assets/src/main/java/haveno/asset/coins/Ripple.java new file mode 100644 index 0000000000..04ce84475d --- /dev/null +++ b/assets/src/main/java/haveno/asset/coins/Ripple.java @@ -0,0 +1,28 @@ +/* + * 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 . + */ + +package haveno.asset.coins; + +import haveno.asset.Coin; +import haveno.asset.RippleAddressValidator; + +public class Ripple extends Coin { + + public Ripple() { + super("Ripple", "XRP", new RippleAddressValidator()); + } +} diff --git a/assets/src/main/resources/META-INF/services/haveno.asset.Asset b/assets/src/main/resources/META-INF/services/haveno.asset.Asset index 80b9cd036d..a10943e769 100644 --- a/assets/src/main/resources/META-INF/services/haveno.asset.Asset +++ b/assets/src/main/resources/META-INF/services/haveno.asset.Asset @@ -7,6 +7,7 @@ haveno.asset.coins.BitcoinCash haveno.asset.coins.Ether haveno.asset.coins.Litecoin haveno.asset.coins.Monero +haveno.asset.coins.Ripple haveno.asset.tokens.TetherUSDERC20 haveno.asset.tokens.TetherUSDTRC20 haveno.asset.tokens.USDCoinERC20 diff --git a/assets/src/test/java/haveno/asset/coins/RippleTest.java b/assets/src/test/java/haveno/asset/coins/RippleTest.java new file mode 100644 index 0000000000..d984d78174 --- /dev/null +++ b/assets/src/test/java/haveno/asset/coins/RippleTest.java @@ -0,0 +1,44 @@ +/* + * 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 . + */ + +package haveno.asset.coins; + +import haveno.asset.AbstractAssetTest; +import org.junit.jupiter.api.Test; + +public class RippleTest extends AbstractAssetTest { + + public RippleTest() { + super(new Ripple()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("r9CxAMAoZAgyVGP8CY9F1arzf9bJg3Y7U8"); + assertValidAddress("rsXMbDtCAmzSWajWiii7ffWygAjYVNDxY7"); + assertValidAddress("rE3nYkQy121JEVb37JKX8LSH6wUBnNvNo2"); + assertValidAddress("rMzucuWFUEE6aM9DC992BqqMgZNPrv4kvi"); + assertValidAddress("rJUmAFPWE36cpdbN4DUEAFBLtG2xkEavY8"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("RJUmAFPWE36cpdbN4DUEAFBLtG2xkEavY8"); + assertInvalidAddress("zJUmAFPWE36cpdbN4DUEAFBLtG2xkEavY8"); + assertInvalidAddress("1LgfapHEPhZbRF9pMd5WPT35hFXcZS1USrW"); + } +} diff --git a/core/src/main/java/haveno/core/locale/CurrencyUtil.java b/core/src/main/java/haveno/core/locale/CurrencyUtil.java index 25605ab18a..e3b61eefaf 100644 --- a/core/src/main/java/haveno/core/locale/CurrencyUtil.java +++ b/core/src/main/java/haveno/core/locale/CurrencyUtil.java @@ -200,6 +200,7 @@ public class CurrencyUtil { result.add(new CryptoCurrency("BCH", "Bitcoin Cash")); result.add(new CryptoCurrency("ETH", "Ether")); result.add(new CryptoCurrency("LTC", "Litecoin")); + result.add(new CryptoCurrency("XRP", "Ripple")); result.add(new CryptoCurrency("DAI-ERC20", "Dai Stablecoin")); result.add(new CryptoCurrency("USDT-ERC20", "Tether USD")); result.add(new CryptoCurrency("USDT-TRC20", "Tether USD")); diff --git a/desktop/src/main/java/haveno/desktop/images.css b/desktop/src/main/java/haveno/desktop/images.css index c721f2ee7b..549549605e 100644 --- a/desktop/src/main/java/haveno/desktop/images.css +++ b/desktop/src/main/java/haveno/desktop/images.css @@ -353,6 +353,10 @@ -fx-image: url("../../images/xmr_logo.png"); } +#image-xrp-logo { + -fx-image: url("../../images/xrp_logo.png"); +} + #image-dark-mode-toggle { -fx-image: url("../../images/dark_mode_toggle.png"); } diff --git a/desktop/src/main/resources/images/xrp_logo.png b/desktop/src/main/resources/images/xrp_logo.png new file mode 100644 index 0000000000..0c1034a6c6 Binary files /dev/null and b/desktop/src/main/resources/images/xrp_logo.png differ