List MonetaryUnit (MUE)

This commit is contained in:
Sotiris Blad 2018-10-27 21:26:37 +03:00 committed by GitHub
parent 3239b401ae
commit 425b85a9b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 103 additions and 0 deletions

View File

@ -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 MonetaryUnit extends Coin {
public MonetaryUnit() {
super("MonetaryUnit", "MUE", new MonetaryUnitAddressValidator());
}
public static class MonetaryUnitAddressValidator extends Base58BitcoinAddressValidator {
public MonetaryUnitAddressValidator() {
super(new MonetaryUnitParams());
}
@Override
public AddressValidationResult validate(String address) {
if (!address.matches("^[7][a-km-zA-HJ-NP-Z1-9]{25,34}$"))
return AddressValidationResult.invalidStructure();
return super.validate(address);
}
}
public static class MonetaryUnitParams extends NetworkParametersAdapter {
public MonetaryUnitParams() {
addressHeader = 16;
p2shHeader = 76;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View File

@ -83,6 +83,7 @@ bisq.asset.coins.MFCoin
bisq.asset.coins.MicroCoin
bisq.asset.coins.MobitGlobal
bisq.asset.coins.Monero
bisq.asset.coins.MonetaryUnit
bisq.asset.coins.Motion
bisq.asset.coins.Myriadcoin
bisq.asset.coins.Namecoin

View File

@ -0,0 +1,46 @@
/*
* 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 MonetaryUnitTest extends AbstractAssetTest {
public MonetaryUnitTest() {
super(new MonetaryUnit());
}
@Test
public void testValidAddresses() {
assertValidAddress("7VjG4Vjnu488k14QdpxswKk1acVgySqV6c");
assertValidAddress("7U42XyYEf7CsLsaq84mRxMaMfst7f3r4By");
assertValidAddress("7hbLQSY9SnyHf1RwiTniMt8vT94x7pqJEr");
assertValidAddress("7oM4HbCStpDQ8imocHPVjNWGVj9gg54erh");
assertValidAddress("7SUheC6Xp12G9CCgoMJ2dT8e9zwnFRwjrU");
}
@Test
public void testInvalidAddresses() {
assertInvalidAddress("0U42XyYEf7CsLsaq84mRxMaMfst7f3r4By");
assertInvalidAddress("#7VjG4Vjnu488k14QdpxswKk1acVgySqV6c");
assertInvalidAddress("7SUheC6Xp12G9CCgoMJ2dT8e9zwnFRwjr");
assertInvalidAddress("7AUheX6X");
}
}