From 258454812ef4b89655c69c0739606924c4754291 Mon Sep 17 00:00:00 2001 From: CaveSpectre11 <36988814+CaveSpectre11@users.noreply.github.com> Date: Thu, 29 Nov 2018 21:25:36 -0500 Subject: [PATCH 1/4] Create DextroTest.java --- .../java/bisq/asset/coins/DextroTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 assets/src/test/java/bisq/asset/coins/DextroTest.java diff --git a/assets/src/test/java/bisq/asset/coins/DextroTest.java b/assets/src/test/java/bisq/asset/coins/DextroTest.java new file mode 100644 index 00000000000..d85d5751d0e --- /dev/null +++ b/assets/src/test/java/bisq/asset/coins/DextroTest.java @@ -0,0 +1,43 @@ +/* + * 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 DextroTest extends AbstractAssetTest { + + public DextroTest() { + super(new Dextro()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("DP9LSAMzxNAuSei1GH3pppMjDqBhNrSGov"); + assertValidAddress("D8HwxDXPJhrSYonPF7YbCGENkM88cAYKb5"); + assertValidAddress("DLhJt6UfwMtWLGMH3ADzjqaLaGG6Bz96Bz"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("DP9LSAMzxNAuSei1GH3pppMjDqBhNrSG0v"); + assertInvalidAddress("DP9LSAMzxNAuSei1GH3pppMjDqBhNrSGovx"); + assertInvalidAddress("DP9LSAMzxNAuSei1GH3pppMjDqBhNrSG#v"); + } +} From 4d93957653f2653492874b3168d91ef2b0075a7d Mon Sep 17 00:00:00 2001 From: CaveSpectre11 <36988814+CaveSpectre11@users.noreply.github.com> Date: Thu, 29 Nov 2018 21:27:03 -0500 Subject: [PATCH 2/4] Create Dextro.java --- .../main/java/bisq/asset/coins/Dextro.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 assets/src/main/java/bisq/asset/coins/Dextro.java diff --git a/assets/src/main/java/bisq/asset/coins/Dextro.java b/assets/src/main/java/bisq/asset/coins/Dextro.java new file mode 100644 index 00000000000..779112231d6 --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/Dextro.java @@ -0,0 +1,40 @@ +/* + * 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.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Dextro extends Coin { + + public Dextro() { + super("Dextro", "DXO", new Base58BitcoinAddressValidator(new DextroParams())); + } + + + public static class DextroParams extends NetworkParametersAdapter { + + public DextroParams() { + super(); + addressHeader = 30; + p2shHeader = 90; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} From 98e2fcf5a895af3546107def44c3ac2e818c9020 Mon Sep 17 00:00:00 2001 From: CaveSpectre11 <36988814+CaveSpectre11@users.noreply.github.com> Date: Thu, 29 Nov 2018 21:28:15 -0500 Subject: [PATCH 3/4] Update bisq.asset.Asset --- assets/src/main/resources/META-INF/services/bisq.asset.Asset | 1 + 1 file changed, 1 insertion(+) 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 e99268b9267..2a61df7f710 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -29,6 +29,7 @@ bisq.asset.coins.Dash$Mainnet bisq.asset.coins.Dash$Regtest bisq.asset.coins.Dash$Testnet bisq.asset.coins.Decred +bisq.asset.coins.Dextro bisq.asset.coins.Dogecoin bisq.asset.coins.Dragonglass bisq.asset.coins.DRIP From 0393af20e03b70f4a5e1d103daa277450a0694cd Mon Sep 17 00:00:00 2001 From: CaveSpectre11 <36988814+CaveSpectre11@users.noreply.github.com> Date: Fri, 30 Nov 2018 09:42:22 -0500 Subject: [PATCH 4/4] List Dextro (DXO) Add AddressValidationResult overrride, with regex expression fix to accurately invalidate 35 char addresses --- .../src/main/java/bisq/asset/coins/Dextro.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/assets/src/main/java/bisq/asset/coins/Dextro.java b/assets/src/main/java/bisq/asset/coins/Dextro.java index 779112231d6..8f880c2bd25 100644 --- a/assets/src/main/java/bisq/asset/coins/Dextro.java +++ b/assets/src/main/java/bisq/asset/coins/Dextro.java @@ -17,6 +17,7 @@ package bisq.asset.coins; +import bisq.asset.AddressValidationResult; import bisq.asset.Base58BitcoinAddressValidator; import bisq.asset.Coin; import bisq.asset.NetworkParametersAdapter; @@ -28,6 +29,22 @@ public Dextro() { } + public static class DextroAddressValidator extends Base58BitcoinAddressValidator { + + public DextroAddressValidator() { + super(new DextroParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[D][a-km-zA-HJ-NP-Z1-9]{33}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + public static class DextroParams extends NetworkParametersAdapter { public DextroParams() {