mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Merge pull request #1825 from MUEDEV/list-monetaryunit
List MonetaryUnit (MUE)
This commit is contained in:
commit
95554441e5
56
assets/src/main/java/bisq/asset/coins/MonetaryUnit.java
Normal file
56
assets/src/main/java/bisq/asset/coins/MonetaryUnit.java
Normal 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};
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
46
assets/src/test/java/bisq/asset/coins/MonetaryUnitTest.java
Normal file
46
assets/src/test/java/bisq/asset/coins/MonetaryUnitTest.java
Normal 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");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user