From 113b6b8370bb73e1246980c4bb530ac48e20480a Mon Sep 17 00:00:00 2001
From: Shelby Sowell <39719925+ssowellsvt@users.noreply.github.com>
Date: Fri, 21 Jun 2019 16:54:05 -0500
Subject: [PATCH] List Genesis (GENX)
---
.../main/java/bisq/asset/coins/Genesis.java | 58 +++++++++++++++++++
.../META-INF/services/bisq.asset.Asset | 1 +
.../java/bisq/asset/coins/GenesisTest.java | 47 +++++++++++++++
3 files changed, 106 insertions(+)
create mode 100644 assets/src/main/java/bisq/asset/coins/Genesis.java
create mode 100644 assets/src/test/java/bisq/asset/coins/GenesisTest.java
diff --git a/assets/src/main/java/bisq/asset/coins/Genesis.java b/assets/src/main/java/bisq/asset/coins/Genesis.java
new file mode 100644
index 00000000000..65c885fd641
--- /dev/null
+++ b/assets/src/main/java/bisq/asset/coins/Genesis.java
@@ -0,0 +1,58 @@
+/*
+ * This file is part of Bisq.
+ *
+ * Bisq 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.
+ *
+ * Bisq 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 Bisq. If not, see .
+ */
+
+package bisq.asset.coins;
+
+import bisq.asset.*;
+import org.bitcoinj.core.Address;
+import org.bitcoinj.core.AddressFormatException;
+
+public class Genesis extends Coin {
+
+ public Genesis() {
+ super("Genesis", "GENX", new GenesisAddressValidator());
+ }
+
+ public static class GenesisAddressValidator extends Base58BitcoinAddressValidator {
+
+ public GenesisAddressValidator() {
+ super(new GenesisParams());
+ }
+
+ @Override
+ public AddressValidationResult validate(String address) {
+ if (address.startsWith("S")) {
+ return super.validate(address);
+ }else if (address.startsWith("genx")){
+ return AddressValidationResult.invalidAddress("Bech32 GENX addresses are not supported on bisq");
+ }else if (address.startsWith("C")){
+ return AddressValidationResult.invalidAddress("Legacy GENX addresses are not supported on bisq");
+ }
+ return AddressValidationResult.invalidStructure();
+ }
+ }
+
+ public static class GenesisParams extends NetworkParametersAdapter {
+
+ public GenesisParams() {
+ addressHeader = 28;
+ p2shHeader = 63;
+ acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
+ }
+ }
+}
+
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 2a6cf1a7d54..27934b90669 100644
--- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset
+++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset
@@ -44,6 +44,7 @@ bisq.asset.coins.FourtyTwo
bisq.asset.coins.Fujicoin
bisq.asset.coins.Galilel
bisq.asset.coins.GambleCoin
+bisq.asset.coins.Genesis
bisq.asset.coins.Grin
bisq.asset.coins.Hatch
bisq.asset.coins.Helium
diff --git a/assets/src/test/java/bisq/asset/coins/GenesisTest.java b/assets/src/test/java/bisq/asset/coins/GenesisTest.java
new file mode 100644
index 00000000000..94dd45c82a1
--- /dev/null
+++ b/assets/src/test/java/bisq/asset/coins/GenesisTest.java
@@ -0,0 +1,47 @@
+/*
+ * This file is part of Bisq.
+ *
+ * Bisq 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.
+ *
+ * Bisq 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 Bisq. If not, see .
+ */
+
+package bisq.asset.coins;
+
+import bisq.asset.AbstractAssetTest;
+import org.junit.Test;
+
+public class GenesisTest extends AbstractAssetTest {
+
+ public GenesisTest() {
+ super(new Genesis());
+ }
+
+ @Test
+ public void testValidAddresses() {
+ assertValidAddress("STE5agX1VkUKZRTHBFufkQu6JtNP1QYJcd"); // Standard SegWit
+ assertValidAddress("SNMcFfcFkes6bWR5dviWQQAL4SYQg8T4Vu"); // Standard SegWit
+ assertValidAddress("SfMmJJdg8uDHK6ajurBNksry7zu3KHdbPv"); // Standard SegWit
+ }
+
+ @Test
+ public void testInvalidAddresses() {
+ assertInvalidAddress("genx1q5dlyjsktuztnwzs85as7vslqfddcmenhfc0ehl"); // Bech32
+ assertInvalidAddress("genx1qxc0hp76tx9hse2evt8dx2k686nx42ljel5nenr"); // Bech32
+ assertInvalidAddress("CT747k1CThgCxk4xRPQeJP6pyKiTfzRM1R"); // valid but unsupported legacy
+ assertInvalidAddress("CbGwkAWfLXjU2esjomFzJfKAFdUiKQjJUd"); // valid but unsupported legacy
+ assertInvalidAddress("0213ba949e295aabda252662ffed7c4c0906"); // random garbage
+ assertInvalidAddress("BwyzAAjVwV2mhR2WQ8SfXhHyUDoy4VL16zBc"); // random garbage
+ assertInvalidAddress("EpGQR83U34JRszcGENjegZLCoDLTwG6YWLBN7jVC"); // random garbage
+ assertInvalidAddress("Xp3Gv2JiP487Z8SULctveCKNM1ffpz5b3n"); // random garbage
+ }
+}