diff --git a/src/main/java/bisq/asset/coins/FuturoCoin.java b/src/main/java/bisq/asset/coins/FuturoCoin.java new file mode 100644 index 0000000..3d67dab --- /dev/null +++ b/src/main/java/bisq/asset/coins/FuturoCoin.java @@ -0,0 +1,54 @@ +/* + * 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.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class FuturoCoin extends Coin { + + public FuturoCoin() { + super("FuturoCoin", "FTO", new FuturoCoinValidator()); + } + + public static class FuturoCoinValidator extends Base58BitcoinAddressValidator { + + public FuturoCoinValidator() { + super(new FuturoCoin.FuturoCoinParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[F][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + public static class FuturoCoinParams extends NetworkParametersAdapter { + + public FuturoCoinParams() { + addressHeader = 36; + p2shHeader = 13; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 445a4f4..7357d0f 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -42,6 +42,7 @@ bisq.asset.coins.DynamicCoin bisq.asset.coins.Espers bisq.asset.coins.Ether bisq.asset.coins.EtherClassic +bisq.asset.coins.FuturoCoin bisq.asset.coins.Graft bisq.asset.coins.Gridcoin bisq.asset.coins.InfinityEconomics diff --git a/src/test/java/bisq/asset/coins/FuturoCoinTest.java b/src/test/java/bisq/asset/coins/FuturoCoinTest.java new file mode 100644 index 0000000..4cae7e7 --- /dev/null +++ b/src/test/java/bisq/asset/coins/FuturoCoinTest.java @@ -0,0 +1,50 @@ +/* + * 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; + +public class FuturoCoinTest extends AbstractAssetTest { + + public FuturoCoinTest() { + super(new FuturoCoin()); + } + + @Override + public void testValidAddresses() { + assertValidAddress("FkWEKpguPvG3CbaLpg46Fka4ZCCh2zuUCZ"); + assertValidAddress("FZ6UhtneD6AciLywYWJSwmN3XgdoDGEjjF"); + assertValidAddress("FYjkqH1XVp4oF5PvFK5JJdC1Mb2eZAbGDk"); + assertValidAddress("FheRu8mY47PpUCx4kvjgsRQcLtoG9uDbT8"); + assertValidAddress("FYdmbRBJ3LBRATvj8E8CwjW7v1EkngTCDa"); + assertValidAddress("FaKWCQ662qG3nmy6bjWV5a4Mse6wfMFde6"); + assertValidAddress("FcXEfdEPj7BLnSGUjBTHFZomxEwWAo9nyv"); + assertValidAddress("Fd7gZ7dNJ1toY6TeWy3rf2dUvyRudggTLv"); + assertValidAddress("FbRXmJUDgf5URuVGyM223P8R2JArXSSm6u"); + } + + @Override + public void testInvalidAddresses() { + assertInvalidAddress("FkWEKpguPvG3CbaLpg46Fka4ZCCh2zuUC2"); + assertInvalidAddress("FZ6UhtneD6AciLywYWJSwmN3XgdoDGEjjFdd"); + assertInvalidAddress("FYjkqH1XVp4oF5PvFK5JJdC1Mb2eZAb"); + assertInvalidAddress("FheRu8mY47PpUCx4kvjgsRQcLtoG9uDbT9"); + assertInvalidAddress("Fd7gZ7dNJ1toY6TeWy3rf2dUvyRudggTL"); + assertInvalidAddress("FbRXmJUDgf5URuVGyM223P8R2JArXSSm61"); + } +}