Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

List NewPowerCoin (NPW) #41

Closed
wants to merge 1 commit into from
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
56 changes: 56 additions & 0 deletions src/main/java/bisq/asset/coins/NewPowerCoin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;

public class NewPowerCoin extends Coin {

public NewPowerCoin() {
super("NewPowerCoin", "NPW", new NewPowerCoinAddressValidator());
}


public static class NewPowerCoinAddressValidator extends Base58BitcoinAddressValidator {

public NewPowerCoinAddressValidator() {
super(new NewPoserCoinParams());
}

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

return super.validate(address);
}
}


public static class NewPoserCoinParams extends NetworkParametersAdapter {

public NewPoserCoinParams() {
addressHeader = 53;
p2shHeader = 13;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/services/bisq.asset.Asset
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ bisq.asset.coins.Monero
bisq.asset.coins.Namecoin
bisq.asset.coins.NavCoin
bisq.asset.coins.NEETCOIN
bisq.asset.coins.NewPowerCoin
bisq.asset.coins.Nilu
bisq.asset.coins.Nimiq
bisq.asset.coins.NuBits
Expand Down
44 changes: 44 additions & 0 deletions src/test/java/bisq/asset/coins/NewPowerCoinTest.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 NewPowerCoinTest extends AbstractAssetTest {

public NewPowerCoinTest() {
super(new NewPowerCoin());
}

@Test
public void testValidAddresses() {
assertValidAddress("NXNc8LCAe2dHumQ9vTyogRXUzGw3PJHr55");
assertValidAddress("NhWDeD4UaNK2Qj8oSKr9u7EAUkCFZxEsDr");
assertValidAddress("NNTuHe4p5Xr8kyN2AJjJS9dcBoG1XQKkW6");
assertValidAddress("NQebfM16pijp2KvFHTKQktD4y2cSKknQEg");
}

@Test
public void testInvalidAddresses() {
assertInvalidAddress("1111111111111111111111111111111111");
assertInvalidAddress("2222222222222222222222222222222222");
assertInvalidAddress("3333333333333333333333333333333333");
}
}