Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List SperoCoin(SPERO) #5940

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 53 additions & 0 deletions assets/src/main/java/bisq/asset/coins/SperoCoin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.AddressValidationResult;
import bisq.asset.Base58AddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;

public class SperoCoin extends Coin {
public SperoCoin() {
super("SperoCoin", "SPERO", new SperoCoinAddressValidator());
}

public static class SperoCoinAddressValidator extends Base58AddressValidator {

public SperoCoinAddressValidator() {
super(new SperoCoinParams());
}

@Override
public AddressValidationResult validate(String address) {
if (!address.matches("^[S][a-km-zA-HJ-NP-Z1-9]{24,33}$"))
return AddressValidationResult.invalidStructure();

return super.validate(address);
}
}

public static class SperoCoinParams extends NetworkParametersAdapter {

public SperoCoinParams() {
super();
addressHeader = 63;
p2shHeader = 5;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ bisq.asset.coins.SixEleven
bisq.asset.coins.Solo
bisq.asset.coins.SpaceCash
bisq.asset.coins.Spectrecoin
bisq.asset.coins.SperoCoin
bisq.asset.coins.Starwels
bisq.asset.coins.SUB1X
bisq.asset.coins.TEO
Expand Down
44 changes: 44 additions & 0 deletions assets/src/test/java/bisq/asset/coins/SperoCoinTest.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 SperoCoinTest extends AbstractAssetTest {

public SperoCoinTest() {
super(new SperoCoin());
}

@Test
public void testValidAddresses() {
assertValidAddress("SUwnfteGBCuHMRVtY9yohpdqQRbuVY67ae");
assertValidAddress("SZqFZ6vfAqHPqH4ap2pn3CwKRuNrAMcLkr");
assertValidAddress("SZqFZ6vfAqHPqH4ap2pn3CwKRuNrAMcLkr");

}

@Test
public void testInvalidAddresses() {
assertInvalidAddress("1ZqFZ6vfAqHPqH4ap2pn3CwKRuNrAMcLkr");
assertInvalidAddress("SZqFZ6vfAqHPqH4ap2pn3CwKRuNrAMcLkrd");
assertInvalidAddress("SZqFZ6vfAqHPqH4ap2pn3CwKRuNrAMcLk#");
}
}