Skip to content

Commit

Permalink
List Blur (BLUR)
Browse files Browse the repository at this point in the history
  • Loading branch information
The Blur Network committed Oct 11, 2018
1 parent 56965c1 commit 7acd03d
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 11 deletions.
44 changes: 33 additions & 11 deletions assets/src/main/java/bisq/asset/CryptonoteAddressValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,38 @@ public AddressValidationResult validate(String address) {
// Invalid characters
return AddressValidationResult.invalidStructure();
}

if (address.startsWith(prefix) && address.length() == 94 + prefix.length()) {
// Standard address
return AddressValidationResult.validAddress();
} else if (address.startsWith(subAddressPrefix) && address.length() == 94 + subAddressPrefix.length()) {
// Subaddress
return AddressValidationResult.validAddress();
} else {
// Integrated? Invalid? Doesn't matter
if (address.startsWith(prefix)) {
if (prefix.length() == 1 && address.length() == 94 + prefix.length()) {
// XMR-type Standard address
return AddressValidationResult.validAddress();
}
else if (prefix.length() == 2 && address.length() == 95 + prefix.length()) {
//Aeon & Blur-type addresses
return AddressValidationResult.validAddress();
}
else {
//Non-supported prefix
return AddressValidationResult.invalidStructure();
}
}
if (address.startsWith(subAddressprefix)) {
if (subAddressPrefix.length() == 1 && address.length() == 94 + subAddressPrefix.length()) {
// XMR-type subaddress
return AddressValidationResult.validAddress();
}
else if (subAddressPrefix.length() == 2 && address.length() == 95 + subAddressPrefix.length()) {
// Aeon & Blur-type subaddress
return AddressValidationResult.validAddress();
}
else {
// Non-supported subAddress
return AddressValidationResult.invalidStructure();
}
}
}
}
else {
//Integrated? Invalid? Doesn't matter
return AddressValidationResult.invalidStructure();
}
}
}

28 changes: 28 additions & 0 deletions assets/src/main/java/bisq/asset/coins/Blur.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

package bisq.asset.coins;

import bisq.asset.Coin;
import bisq.asset.CryptonoteAddressValidator;

public class Blur extends Coin {

public Blur() {
super("Blur", "BLUR", new CryptonoteAddressValidator("bL", "Ry"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bisq.asset.coins.Bitcoin$Testnet
bisq.asset.coins.Bitcore
bisq.asset.coins.BitDaric
bisq.asset.coins.BitZeny
bisq.asset.coins.Blur
bisq.asset.coins.BSQ$Mainnet
bisq.asset.coins.BSQ$Regtest
bisq.asset.coins.BSQ$Testnet
Expand Down
44 changes: 44 additions & 0 deletions assets/src/test/java/bisq/asset/coins/BlurTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

package bisq.asset.coins;

import bisq.asset.AbstractAssetTest;
import org.junit.Test;

public class BlurTest extends AbstractAssetTest {

public BlurTest() {
super(new Blur());
}

@Test
public void testValidAddresses() {
assertValidAddress("bL3W1g1d12sbxQDTQ6q8bgU2bBp2rkfFFKfNvQuUQTHqgQHRaxKTHqK5Nqdm53BU3ibPnsqbdYAnnJMyqJ6FfN9m3CSZSNqDE");
assertValidAddress("bL2zBGUBDkQdyYasdoAdvQCxWLa9Mk5Q1PW8Zk7S38vx9xu7T7NMPPWNfieXqUyswo544ZSB3C1n9jLMfsUvR6p91rnrSdx9h");
assertValidAddress("Ry49oErHtqyHucxADDT2DfEJ9pRv2ciSpKV9XseCuWmx1PK1CZi4gbPKxhWBdtvLJNNc94c4yDutmZrD3WrsHPYV1nvE9X4Cc");
}

@Test
public void testInvalidAddresses() {
assertInvalidAddress("");
assertInvalidAddress("bl4E2BCFY31DPLjeqF6Gu7TEUM5v2JwpmudFX64AubQtFDYEPBvgvQPzidaawDhjAmHeZSw92wEBnUfdfY5144Sad2ZCknZzC");
assertInvalidAddress("Ry49oErHtqyHucxADDT2DfEJ9pRv2ciSpKV9XseCuWmx1PK1CZi4gbPKxhWBdtvLJNNc94c4yDutmZrD3WrsHPYV1nvE9X40");
assertInvalidAddress("bLNHRh8pFh5Y14bhBVAoD4cvqHyoPsQJqB3dr49zoF6bNDFrts96tuuj#RoUKWRwpTHmYt4Kf78FES7LCXAXKXFf6bMsx1sdgz");
assertInvalidAddress("82zBGUBDkQdyYasdoAdvQCxWLa9Mk5Q1PW#8Zk7S38vx9xu7T7NMPPWNfieXqUyswo544ZSB3C1n9jLMfsUvR6p91rnrSdxwd");
}
}

0 comments on commit 7acd03d

Please sign in to comment.