Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

List NEETCOIN (NEET) #26

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/bisq/core/locale/CurrencyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public static List<CryptoCurrency> createAllSortedCryptoCurrenciesList() {
result.add(new CryptoCurrency("GRANS", "10grans", true));
result.add(new CryptoCurrency("ICH", "ICH"));
result.add(new CryptoCurrency("PHR", "Phore"));
result.add(new CryptoCurrency("NEET", "NEETCOIN"));

result.sort(TradeCurrency::compareTo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import bisq.core.payment.validation.params.PNCParams;
import bisq.core.payment.validation.params.PhoreParams;
import bisq.core.payment.validation.params.PivxParams;
import bisq.core.payment.validation.params.NEETParams;
import bisq.core.payment.validation.params.SpeedCashParams;
import bisq.core.payment.validation.params.StrayaParams;
import bisq.core.payment.validation.params.TerracoinParams;
Expand Down Expand Up @@ -439,6 +440,13 @@ public ValidationResult validate(String input) {
return regexTestFailed;
else
return new ValidationResult(true);
case "NEET":
try {
Address.fromBase58(NEETParams.get(), input);
return new ValidationResult(true);
} catch (AddressFormatException e) {
return new ValidationResult(false, getErrorMessage(e));
}
case "STL":
if (!input.matches("^(Se)\\d[0-9A-Za-z]{94}$"))
return regexTestFailed;
Expand Down
88 changes: 88 additions & 0 deletions src/main/java/bisq/core/payment/validation/params/NEETParams.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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.core.payment.validation.params;

import org.bitcoinj.core.*;
import org.bitcoinj.store.BlockStore;
import org.bitcoinj.store.BlockStoreException;
import org.bitcoinj.utils.MonetaryFormat;

public class NEETParams extends NetworkParameters {

private static NEETParams instance;

public static synchronized NEETParams get() {
if (instance == null) {
instance = new NEETParams();
}
return instance;
}

// We only use the properties needed for address validation
public NEETParams() {
super();
addressHeader = 53;
p2shHeader = 112;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}

// default dummy implementations, not used...
@Override
public String getPaymentProtocolId() {
return PAYMENT_PROTOCOL_ID_MAINNET;
}

@Override
public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException {
}

@Override
public Coin getMaxMoney() {
return null;
}

@Override
public Coin getMinNonDustOutput() {
return null;
}

@Override
public MonetaryFormat getMonetaryFormat() {
return null;
}

@Override
public String getUriScheme() {
return null;
}

@Override
public boolean hasMaxMoney() {
return false;
}

@Override
public BitcoinSerializer getSerializer(boolean parseRetain) {
return null;
}

@Override
public int getProtocolVersionNum(ProtocolVersion version) {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ private void printAllCurrencyStats() {
newlyAdded.add("GEO");
newlyAdded.add("GRANS");
newlyAdded.add("ICH");
newlyAdded.add("NEET");

coinsWithValidator.addAll(newlyAdded);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,4 +948,23 @@ public void testPHR() {
assertFalse(validator.validate("P0r3vQ7SkqLELsYGM6qeRumyfPx3366uyU9").isValid);
assertFalse(validator.validate("").isValid);
}

@Test
public void testNEET() {
AltCoinAddressValidator validator = new AltCoinAddressValidator();
validator.setCurrencyCode("NEET");

assertTrue(validator.validate("NW69jcXy7T4cBsjVZ1GVtjNv4XrNa6ZA4o").isValid);
assertTrue(validator.validate("Nac1o79vQVkVk1BGmusDN8JrckPcDAvXVS").isValid);
assertTrue(validator.validate("nDjqdvK7X7MgPCtyzEukcRm1LxEy7LEZVh").isValid);
assertTrue(validator.validate("nJA1pCA2HaYrYwg3zcNs2FJSGtaYFriPca").isValid);

assertFalse(validator.validate("NW69jcXy7T4cBsjVZ1GVtjNv4XrNa6ZA4oo").isValid);
assertFalse(validator.validate("NW69jcXy7T4cBsjVZ1GVtjNv4XrNa6ZA4").isValid);
assertFalse(validator.validate("NW69jcXy7T4cBsjVZ1GVtjNv4XrNa6ZA4o#").isValid);
assertFalse(validator.validate("nDjqdvK7X7MgPCtyzEukcRm1LxEy7LEZVhh").isValid);
assertFalse(validator.validate("nDjqdvK7X7MgPCtyzEukcRm1LxEy7LEZV").isValid);
assertFalse(validator.validate("nDjqdvK7X7MgPCtyzEukcRm1LxEy7LEZVh#").isValid);
assertFalse(validator.validate("").isValid);
}
}