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

Commit

Permalink
List MegaCoin (MEC)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalijolijo committed Jun 26, 2018
1 parent 87036ca commit fd59f87
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/main/java/bisq/asset/coins/MegaCoin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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 MegaCoin extends Coin {

public MegaCoin() {
super("MegaCoin", "MEC", new MegaCoinAddressValidator());
}


public static class MegaCoinAddressValidator extends Base58BitcoinAddressValidator {

public MegaCoinAddressValidator() {
super(new MegaCoinParams());
}

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

return super.validate(address);
}
}

public static class MegaCoinParams extends NetworkParametersAdapter {

public MegaCoinParams() {
addressHeader = 50;
p2shHeader = 5;
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 @@ -59,6 +59,7 @@ bisq.asset.coins.Madbyte
bisq.asset.coins.Madcoin
bisq.asset.coins.MaidSafeCoin
bisq.asset.coins.Mazacoin
bisq.asset.coins.MegaCoin
bisq.asset.coins.MFCoin
bisq.asset.coins.Monero
bisq.asset.coins.Namecoin
Expand Down
44 changes: 44 additions & 0 deletions src/test/java/bisq/asset/coins/MegaCoinTest.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 MegaCoinTest extends AbstractAssetTest {

public MegaCoinTest() {
super(new MegaCoin());
}

@Test
public void testValidAddresses() {
assertValidAddress("MWXQfp3wKnir6krS4SQFAxzv1AExpfFMbq");
assertValidAddress("MEfn9iWMjowxQaNCZEbtT7A34pvnJGPZ44");
assertValidAddress("MRaL1xTj5eAuxMR3xDPxLUG6RP3qR1ijuo");
assertValidAddress("M9pCgxBES9EgoNxoUnXxrnaMqYUwZVMttM");
}

@Test
public void testInvalidAddresses() {
assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq");
assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO");
assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek#");
}
}

0 comments on commit fd59f87

Please sign in to comment.