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

List Kumacoin (KUMA) #25

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("KUMA", "Kumacoin"));

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.KumaParams;
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 "KUMA":
try {
Address.fromBase58(KumaParams.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/KumaParams.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 KumaParams extends NetworkParameters {

private static KumaParams instance;

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

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

// 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("KUMA");

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 testKUMA() {
AltCoinAddressValidator validator = new AltCoinAddressValidator();
validator.setCurrencyCode("KUMA");

assertTrue(validator.validate("KKeZ46ELdrcnB9TT8R7GiU3cdd29gA6mQm").isValid);
assertTrue(validator.validate("KD5xtaJFmKpR5fqJGApfisMT2Mh4uNZdLF").isValid);
assertTrue(validator.validate("4FmFUcHecwkepmAtwFZoJGJUnQsLMqKY3k").isValid);
assertTrue(validator.validate("4EvJMtRRnkCtaocadbr6CQUP2qRh6Pwcjp").isValid);

assertFalse(validator.validate("KKeZ46ELdrcnB9TT8R7GiU3cdd29gA6mQmm").isValid);
assertFalse(validator.validate("KKeZ46ELdrcnB9TT8R7GiU3cdd29gA6mQ").isValid);
assertFalse(validator.validate("KKeZ46ELdrcnB9TT8R7GiU3cdd29gA6mQm#").isValid);
assertFalse(validator.validate("4FmFUcHecwkepmAtwFZoJGJUnQsLMqKY3kk").isValid);
assertFalse(validator.validate("4FmFUcHecwkepmAtwFZoJGJUnQsLMqKY3").isValid);
assertFalse(validator.validate("4FmFUcHecwkepmAtwFZoJGJUnQsLMqKY3k#").isValid);
assertFalse(validator.validate("").isValid);
}
}