From 6fe132dd9befab462ab6e7553f800e6d8e037c31 Mon Sep 17 00:00:00 2001 From: tundak Date: Wed, 16 Sep 2020 15:19:50 +0530 Subject: [PATCH] List Bitcoin Black(BCB) --- .../src/main/java/bisq/asset/coins/Bcb.java | 29 +++++++++++++ .../META-INF/services/bisq.asset.Asset | 1 + .../test/java/bisq/asset/coins/BcbTest.java | 42 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 assets/src/main/java/bisq/asset/coins/Bcb.java create mode 100644 assets/src/test/java/bisq/asset/coins/BcbTest.java diff --git a/assets/src/main/java/bisq/asset/coins/Bcb.java b/assets/src/main/java/bisq/asset/coins/Bcb.java new file mode 100644 index 00000000000..6c98021811c --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/Bcb.java @@ -0,0 +1,29 @@ +/* + * 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.Coin; +import bisq.asset.RegexAddressValidator; + +public class Bcb extends Coin { + private static final String BCB_VALIDATION_REGEX = "^(bcb)_[13]{1}[13456789abcdefghijkmnopqrstuwxyz]{59}$"; + + public Bcb() { + super("BitcoinBlack", "BCB", new RegexAddressValidator(BCB_VALIDATION_REGEX)); + } +} 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 80a6168463b..a1fb2fe480e 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -10,6 +10,7 @@ bisq.asset.coins.Animecoin bisq.asset.coins.Arqma bisq.asset.coins.Askcoin bisq.asset.coins.Australiacash +bisq.asset.coins.Bcb bisq.asset.coins.Beam bisq.asset.coins.Bitcoin$Mainnet bisq.asset.coins.Bitcoin$Regtest diff --git a/assets/src/test/java/bisq/asset/coins/BcbTest.java b/assets/src/test/java/bisq/asset/coins/BcbTest.java new file mode 100644 index 00000000000..66c12d68ae6 --- /dev/null +++ b/assets/src/test/java/bisq/asset/coins/BcbTest.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.AbstractAssetTest; + +public class BcbTest extends AbstractAssetTest { + public BcbTest() { + super(new Bcb()); + } + + @Override + public void testValidAddresses() { + assertValidAddress("bcb_1fuckbtc6p55wt64eo4rz7brq3ubjfd8unhz3it5fbdpta8tww7ywk8p9su7"); + } + + @Override + public void testInvalidAddresses() { + //exceed the limit + assertInvalidAddress("bcb_1j78msn5omp8jrjge8txwxm4x3smusa1cojg7nuk8fdzoux41fqeeogg5aa111"); + //invalid prefix + assertInvalidAddress("cda_1j78msn5omp8jrjge8txwxm4x3smusa1cojg7nuk8fdzoux41fqeeogg5aa1"); + //not valid address + assertInvalidAddress(""); + assertInvalidAddress("not is an address"); + } +}