Merge pull request #1825 from MUEDEV/list-monetaryunit

List MonetaryUnit (MUE)
This commit is contained in:
Manfred Karrer 2018-11-16 20:38:46 -05:00 committed by GitHub
commit 95554441e5
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

@ -48,6 +48,7 @@ bisq.asset.coins.MegaCoin
bisq.asset.coins.MicroCoin
bisq.asset.coins.MobitGlobal
bisq.asset.coins.Monero
bisq.asset.coins.MonetaryUnit
bisq.asset.coins.Motion
bisq.asset.coins.MoX
bisq.asset.coins.Myriadcoin

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");
}
}