From a284fd12e462b72c180640628b84e33298569b95 Mon Sep 17 00:00:00 2001 From: Walter Karshat Date: Sun, 20 May 2018 20:44:54 -0700 Subject: [PATCH] List Zero (ZER) --- .travis.yml | 2 + src/main/java/bisq/asset/coins/Zero.java | 42 ++++++++++++++++++ .../META-INF/services/bisq.asset.Asset | 11 ++--- src/test/java/bisq/asset/coins/ZeroTest.java | 43 +++++++++++++++++++ 4 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Zero.java create mode 100644 src/test/java/bisq/asset/coins/ZeroTest.java diff --git a/.travis.yml b/.travis.yml index 44acc32..b5432cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: java jdk: oraclejdk8 +before_install: + grep -v '^#' src/main/resources/META-INF/services/bisq.asset.Asset | sort --check --dictionary-order --ignore-case notifications: slack: on_success: change diff --git a/src/main/java/bisq/asset/coins/Zero.java b/src/main/java/bisq/asset/coins/Zero.java new file mode 100644 index 0000000..910d25f --- /dev/null +++ b/src/main/java/bisq/asset/coins/Zero.java @@ -0,0 +1,42 @@ +/* + * 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.AddressValidator; +import bisq.asset.Coin; + +public class Zero extends Coin { + + public Zero() { + super("Zero", "ZER", new ZeroAddressValidator()); + } + + + public static class ZeroAddressValidator implements AddressValidator { + + @Override + public AddressValidationResult validate(String address) { + // We only support t addresses (transparent transactions) + if (!address.startsWith("t1")) + return AddressValidationResult.invalidAddress("", "validation.altcoin.zAddressesNotSupported"); + + return AddressValidationResult.validAddress(); + } + } +} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index ea7081b..b3a31aa 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -1,17 +1,17 @@ # All assets available for trading on the Bisq network. -# Contents are sorted according to the output of `sort --ignore-case`. +# Contents are sorted according to the output of `sort --ignore-case --dictionary-order`. # See bisq.asset.Asset and bisq.asset.AssetRegistry for further details. # See https://bisq.network/list-asset for complete instructions. bisq.asset.coins.Achievecoin bisq.asset.coins.Angelcoin bisq.asset.coins.Aquachain bisq.asset.coins.Arto -bisq.asset.coins.Bitcoin$Mainnet -bisq.asset.coins.Bitcoin$Regtest -bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.BitcoinCash bisq.asset.coins.BitcoinClashic bisq.asset.coins.BitcoinGold +bisq.asset.coins.Bitcoin$Mainnet +bisq.asset.coins.Bitcoin$Regtest +bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.Bitcore bisq.asset.coins.BitDaric bisq.asset.coins.BitZeny @@ -49,10 +49,10 @@ bisq.asset.coins.Koto bisq.asset.coins.Kumacoin bisq.asset.coins.LBRY bisq.asset.coins.Lisk +bisq.asset.coins.LitecoinExtreme bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet -bisq.asset.coins.LitecoinExtreme bisq.asset.coins.Madbyte bisq.asset.coins.Madcoin bisq.asset.coins.MaidSafeCoin @@ -99,6 +99,7 @@ bisq.asset.coins.Yenten bisq.asset.coins.Zcash bisq.asset.coins.Zcoin bisq.asset.coins.ZenCash +bisq.asset.coins.Zero bisq.asset.tokens.BetterBetting bisq.asset.tokens.DaiStablecoin bisq.asset.tokens.Ellaism diff --git a/src/test/java/bisq/asset/coins/ZeroTest.java b/src/test/java/bisq/asset/coins/ZeroTest.java new file mode 100644 index 0000000..fc110d1 --- /dev/null +++ b/src/test/java/bisq/asset/coins/ZeroTest.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 ZeroTest extends AbstractAssetTest { + + public ZeroTest() { + super(new Zero()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("t1cZTNaKS6juH6tGEhCUZmZhtbYGeYeuTrK"); + assertValidAddress("t1ZBPYJwK2UPbshwcYWRiCq7vw8VPDYumWu"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"); + assertInvalidAddress("38NwrYsD1HxQW5zfLT0QcUUXGMPvQgzTSn"); + assertInvalidAddress("8tP9rh3SH6n9cSLmV22vnSNNw56LKGpLrB"); + assertInvalidAddress("8Zbvjr"); + } +}