Merge pull request #1650 from ripcurlx/create-mono-repository

Create mono repository
This commit is contained in:
Christoph Atteneder 2018-09-05 17:35:03 +02:00 committed by GitHub
commit 708d9a4325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1933 changed files with 133155 additions and 154 deletions

8
.gitignore vendored
View file

@ -1,7 +1,7 @@
/docs
/log
/bin
/out
*/docs
*/log
*/bin
*/out
.idea
!.idea/copyright/bisq_Affero_GPLv3.xml
!.idea/copyright/profiles_settings.xml

38
assets/build.gradle Normal file
View file

@ -0,0 +1,38 @@
plugins {
id 'java'
id 'maven'
}
group 'network.bisq'
version '-SNAPSHOT'
sourceCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
javadoc {
options.author = true
options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
}
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
compile project(':common')
compile 'commons-codec:commons-codec:1.9'
testCompile 'junit:junit:4.12'
}

View file

@ -0,0 +1,62 @@
/*
* 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;
import static org.apache.commons.lang3.Validate.notBlank;
import static org.apache.commons.lang3.Validate.notNull;
/**
* Abstract base class for {@link Asset} implementations. Most implementations should not
* extend this class directly, but should rather extend {@link Coin}, {@link Token} or one
* of their subtypes.
*
* @author Chris Beams
* @since 0.7.0
*/
public abstract class AbstractAsset implements Asset {
private final String name;
private final String tickerSymbol;
private final AddressValidator addressValidator;
public AbstractAsset(String name, String tickerSymbol, AddressValidator addressValidator) {
this.name = notBlank(name);
this.tickerSymbol = notBlank(tickerSymbol);
this.addressValidator = notNull(addressValidator);
}
@Override
public final String getName() {
return name;
}
@Override
public final String getTickerSymbol() {
return tickerSymbol;
}
@Override
public final AddressValidationResult validateAddress(String address) {
return addressValidator.validate(address);
}
@Override
public String toString() {
return getClass().getName();
}
}

View file

@ -0,0 +1,73 @@
/*
* 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;
/**
* Value object representing the result of validating an {@link Asset} address. Various
* factory methods are provided for typical use cases.
*
* @author Chris Beams
* @since 0.7.0
* @see Asset#validateAddress(String)
*/
public class AddressValidationResult {
private static AddressValidationResult VALID_ADDRESS = new AddressValidationResult(true, "", "");
private final boolean isValid;
private final String message;
private final String i18nKey;
private AddressValidationResult(boolean isValid, String message, String i18nKey) {
this.isValid = isValid;
this.message = message;
this.i18nKey = i18nKey;
}
public boolean isValid() {
return isValid;
}
public String getI18nKey() {
return i18nKey;
}
public String getMessage() {
return message;
}
public static AddressValidationResult validAddress() {
return VALID_ADDRESS;
}
public static AddressValidationResult invalidAddress(Throwable cause) {
return invalidAddress(cause.getMessage());
}
public static AddressValidationResult invalidAddress(String cause) {
return invalidAddress(cause, "validation.altcoin.invalidAddress");
}
public static AddressValidationResult invalidAddress(String cause, String i18nKey) {
return new AddressValidationResult(false, cause, i18nKey);
}
public static AddressValidationResult invalidStructure() {
return invalidAddress("", "validation.altcoin.wrongStructure");
}
}

View file

@ -0,0 +1,29 @@
/*
* 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;
/**
* An {@link Asset} address validation function.
*
* @author Chris Beams
* @since 0.7.0
*/
public interface AddressValidator {
AddressValidationResult validate(String address);
}

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;
/**
* Interface representing a given ("crypto") asset in its most abstract form, having a
* {@link #getName() name}, eg "Bitcoin", a {@link #getTickerSymbol() ticker symbol},
* eg "BTC", and an address validation function. Together, these properties represent
* the minimum information and functionality required to register and trade an asset on
* the Bisq network.
* <p>
* Implementations typically extend either the {@link Coin} or {@link Token} base
* classes, and must be registered in the {@code META-INF/services/bisq.asset.Asset} file
* in order to be available in the {@link AssetRegistry} at runtime.
*
* @author Chris Beams
* @since 0.7.0
* @see AbstractAsset
* @see Coin
* @see Token
* @see Erc20Token
* @see AssetRegistry
*/
public interface Asset {
String getName();
String getTickerSymbol();
AddressValidationResult validateAddress(String address);
}

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;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import java.util.stream.Stream;
/**
* Provides {@link Stream}-based access to {@link Asset} implementations registered in
* the {@code META-INF/services/bisq.asset.Asset} provider-configuration file.
*
* @author Chris Beams
* @since 0.7.0
* @see ServiceLoader
*/
public class AssetRegistry {
private static final List<Asset> registeredAssets = new ArrayList<>();
static {
for (Asset asset : ServiceLoader.load(Asset.class)) {
registeredAssets.add(asset);
}
}
public Stream<Asset> stream() {
return registeredAssets.stream();
}
}

View file

@ -0,0 +1,54 @@
/*
* 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;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.params.MainNetParams;
/**
* {@link AddressValidator} for Base58-encoded Bitcoin addresses.
*
* @author Chris Beams
* @since 0.7.0
* @see org.bitcoinj.core.Address#fromBase58(NetworkParameters, String)
*/
public class Base58BitcoinAddressValidator implements AddressValidator {
private final NetworkParameters networkParameters;
public Base58BitcoinAddressValidator() {
this(MainNetParams.get());
}
public Base58BitcoinAddressValidator(NetworkParameters networkParameters) {
this.networkParameters = networkParameters;
}
@Override
public AddressValidationResult validate(String address) {
try {
Address.fromBase58(networkParameters, address);
} catch (AddressFormatException ex) {
return AddressValidationResult.invalidAddress(ex);
}
return AddressValidationResult.validAddress();
}
}

View file

@ -0,0 +1,55 @@
/*
* 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;
/**
* Abstract base class for {@link Asset}s with their own dedicated blockchain, such as
* {@link bisq.asset.coins.Bitcoin} itself or one of its many derivatives, competitors and
* alternatives, often called "altcoins", such as {@link bisq.asset.coins.Litecoin},
* {@link bisq.asset.coins.Ether}, {@link bisq.asset.coins.Monero} and
* {@link bisq.asset.coins.Zcash}.
* <p>
* In addition to the usual {@code Asset} properties, a {@code Coin} maintains information
* about which {@link Network} it may be used on. By default, coins are constructed with
* the assumption they are for use on that coin's "main network", or "main blockchain",
* i.e. that they are "real" coins for use in a production environment. In testing
* scenarios, however, a coin may be constructed for use only on "testnet" or "regtest"
* networks.
*
* @author Chris Beams
* @since 0.7.0
*/
public abstract class Coin extends AbstractAsset {
public enum Network { MAINNET, TESTNET, REGTEST }
private final Network network;
public Coin(String name, String tickerSymbol, AddressValidator addressValidator) {
this(name, tickerSymbol, addressValidator, Network.MAINNET);
}
public Coin(String name, String tickerSymbol, AddressValidator addressValidator, Network network) {
super(name, tickerSymbol, addressValidator);
this.network = network;
}
public Network getNetwork() {
return network;
}
}

View file

@ -0,0 +1,41 @@
/*
* 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;
/**
* {@link AddressValidator} for use when no more specific address validation function is
* available. This implementation only checks that a given address is non-null and
* non-empty; it exists for legacy purposes and is deprecated to indicate that new
* {@link Asset} implementations should NOT use it, but should rather provide their own
* {@link AddressValidator} implementation.
*
* @author Chris Beams
* @author Bernard Labno
* @since 0.7.0
*/
@Deprecated
public class DefaultAddressValidator implements AddressValidator {
@Override
public AddressValidationResult validate(String address) {
if (address == null || address.length() == 0)
return AddressValidationResult.invalidAddress("Address may not be empty");
return AddressValidationResult.validAddress();
}
}

View file

@ -0,0 +1,33 @@
/*
* 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;
/**
* Abstract base class for Ethereum-based {@link Token}s that implement the
* <a href="https://theethereum.wiki/w/index.php/ERC20_Token_Standard">ERC-20 Token
* Standard</a>.
*
* @author Chris Beams
* @since 0.7.0
*/
public abstract class Erc20Token extends Token {
public Erc20Token(String name, String tickerSymbol) {
super(name, tickerSymbol, new EtherAddressValidator());
}
}

View file

@ -0,0 +1,36 @@
/*
* 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;
/**
* Validates an Ethereum address using the regular expression on record in the
* <a href="https://github.com/ethereum/web3.js/blob/bd6a890/lib/utils/utils.js#L405">
* ethereum/web3.js</a> project. Note that this implementation is widely used, not just
* for actual {@link bisq.asset.coins.Ether} address validation, but also for
* {@link Erc20Token} implementations and other Ethereum-based {@link Asset}
* implementations.
*
* @author Chris Beams
* @since 0.7.0
*/
public class EtherAddressValidator extends RegexAddressValidator {
public EtherAddressValidator() {
super("^(0x)?[0-9a-fA-F]{40}$");
}
}

View file

@ -0,0 +1,83 @@
/*
* 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;
import org.bitcoinj.core.BitcoinSerializer;
import org.bitcoinj.core.Block;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.StoredBlock;
import org.bitcoinj.core.VerificationException;
import org.bitcoinj.store.BlockStore;
import org.bitcoinj.utils.MonetaryFormat;
/**
* Convenient abstract {@link NetworkParameters} base class providing no-op
* implementations of all methods that are not required for address validation
* purposes.
*
* @author Chris Beams
* @since 0.7.0
*/
public abstract class NetworkParametersAdapter extends NetworkParameters {
@Override
public String getPaymentProtocolId() {
return PAYMENT_PROTOCOL_ID_MAINNET;
}
@Override
public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore)
throws VerificationException {
}
@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;
}
}

View file

@ -0,0 +1,44 @@
/*
* 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;
import bisq.common.util.Tuple2;
import java.util.Comparator;
public class PrintTool {
public static void main(String[] args) {
// Prints out all coins in the format used in the FAQ webpage.
// Run that and copy paste the result to the FAQ webpage at new releases.
StringBuilder sb = new StringBuilder();
new AssetRegistry().stream()
.sorted(Comparator.comparing(o -> o.getName().toLowerCase()))
.filter(e -> !e.getTickerSymbol().equals("BSQ")) // BSQ is not out yet...
.filter(e -> !e.getTickerSymbol().equals("BTC"))
.map(e -> new Tuple2(e.getName(), e.getTickerSymbol())) // We want to get rid of duplicated entries for regtest/testnet...
.distinct()
.forEach(e -> sb.append("<li>&#8220;")
.append(e.second)
.append("&#8221;, &#8220;")
.append(e.first)
.append("&#8221;</li>")
.append("\n"));
System.out.println(sb.toString());
}
}

View file

@ -0,0 +1,41 @@
/*
* 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;
/**
* Validates an {@link Asset} address against a given regular expression.
*
* @author Chris Beams
* @since 0.7.0
*/
public class RegexAddressValidator implements AddressValidator {
private final String regex;
public RegexAddressValidator(String regex) {
this.regex = regex;
}
@Override
public AddressValidationResult validate(String address) {
if (!address.matches(regex))
return AddressValidationResult.invalidStructure();
return AddressValidationResult.validAddress();
}
}

View file

@ -0,0 +1,37 @@
/*
* 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;
/**
* Abstract base class for {@link Asset}s that do not have their own dedicated blockchain,
* but are rather based on or derived from another blockchain. Contrast with {@link Coin}.
* Note that this is essentially a "marker" base class in the sense that it (currently)
* exposes no additional information or functionality beyond that found in
* {@link AbstractAsset}, but it is nevertheless useful in distinguishing between major
* different {@code Asset} types.
*
* @author Chris Beams
* @since 0.7.0
* @see Erc20Token
*/
public abstract class Token extends AbstractAsset {
public Token(String name, String tickerSymbol, AddressValidator addressValidator) {
super(name, tickerSymbol, addressValidator);
}
}

View file

@ -0,0 +1,54 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
import org.bitcoinj.core.Utils;
public class Achievecoin extends Coin {
public Achievecoin() {
super("AchieveCoin", "ACH", new Base58BitcoinAddressValidator(new AchievecoinParams()));
}
public static class AchievecoinParams extends NetworkParametersAdapter {
public AchievecoinParams() {
interval = INTERVAL;
targetTimespan = TARGET_TIMESPAN;
maxTarget = Utils.decodeCompactBits(0x1d00ffffL);
dumpedPrivateKeyHeader = 128;
// Address format is different to BTC, rest is the same
addressHeader = 23; //BTG 38;
p2shHeader = 34; //BTG 23;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
port = 7337; //BTC and BTG 8333
packetMagic = 0x1461de3cL; //BTG 0xe1476d44L, BTC 0xf9beb4d9L;
bip32HeaderPub = 0x02651F71; //BTG and BTC 0x0488B21E; //The 4 byte header that serializes in base58 to "xpub".
bip32HeaderPriv = 0x02355E56; //BTG and BTC 0x0488ADE4; //The 4 byte header that serializes in base58 to "xprv"
id = ID_MAINNET;
}
}
}

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

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class Aquachain extends Coin {
public Aquachain() {
super("Aquachain", "AQUA", new RegexAddressValidator("^(0x)?[0-9a-fA-F]{40}$"));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class Arto extends Coin {
public Arto() {
super("Arto", "RTO", new RegexAddressValidator("^[A][0-9A-Za-z]{94}$"));
}
}

View file

@ -0,0 +1,76 @@
/*
* 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 org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.RegTestParams;
import org.bitcoinj.params.TestNet3Params;
public class BSQ extends Coin {
public BSQ(Network network, NetworkParameters networkParameters) {
super("BSQ", "BSQ", new BSQAddressValidator(networkParameters), network);
}
public static class Mainnet extends BSQ {
public Mainnet() {
super(Network.MAINNET, MainNetParams.get());
}
}
public static class Testnet extends BSQ {
public Testnet() {
super(Network.TESTNET, TestNet3Params.get());
}
}
public static class Regtest extends BSQ {
public Regtest() {
super(Network.REGTEST, RegTestParams.get());
}
}
public static class BSQAddressValidator extends Base58BitcoinAddressValidator {
public BSQAddressValidator(NetworkParameters networkParameters) {
super(networkParameters);
}
@Override
public AddressValidationResult validate(String address) {
if (!address.startsWith("B"))
return AddressValidationResult.invalidAddress("BSQ address must start with 'B'");
String addressAsBtc = address.substring(1, address.length());
return super.validate(addressAsBtc);
}
}
}

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

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class BitDaric extends Coin {
public BitDaric() {
super("BitDaric", "DARX", new RegexAddressValidator("^[R][a-km-zA-HJ-NP-Z1-9]{25,34}$"));
}
}

View file

@ -0,0 +1,39 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class BitZeny extends Coin {
public BitZeny() {
super("BitZeny", "ZNY", new Base58BitcoinAddressValidator(new BitZenyParams()));
}
public static class BitZenyParams extends NetworkParametersAdapter {
public BitZenyParams() {
addressHeader = 81;
p2shHeader = 5;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,57 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.RegTestParams;
import org.bitcoinj.params.TestNet3Params;
public abstract class Bitcoin extends Coin {
public Bitcoin(Network network, NetworkParameters networkParameters) {
super("Bitcoin", "BTC", new Base58BitcoinAddressValidator(networkParameters), network);
}
public static class Mainnet extends Bitcoin {
public Mainnet() {
super(Network.MAINNET, MainNetParams.get());
}
}
public static class Testnet extends Bitcoin {
public Testnet() {
super(Network.TESTNET, TestNet3Params.get());
}
}
public static class Regtest extends Bitcoin {
public Regtest() {
super(Network.REGTEST, RegTestParams.get());
}
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
public class BitcoinCash extends Coin {
public BitcoinCash() {
super("Bitcoin Cash", "BCH", new Base58BitcoinAddressValidator());
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
public class BitcoinClashic extends Coin {
public BitcoinClashic() {
super("Bitcoin Clashic", "BCHC", new Base58BitcoinAddressValidator());
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
public class BitcoinCore extends Coin {
public BitcoinCore() {
super("Bitcoin Core", "BTCC", new Base58BitcoinAddressValidator());
}
}

View file

@ -0,0 +1,54 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
import org.bitcoinj.core.Utils;
public class BitcoinGold extends Coin {
public BitcoinGold() {
super("Bitcoin Gold", "BTG", new Base58BitcoinAddressValidator(new BitcoinGoldParams()));
}
private static class BitcoinGoldParams extends NetworkParametersAdapter {
public BitcoinGoldParams() {
interval = INTERVAL;
targetTimespan = TARGET_TIMESPAN;
maxTarget = Utils.decodeCompactBits(0x1d00ffffL);
dumpedPrivateKeyHeader = 128;
// Address format is different to BTC, rest is the same
addressHeader = 38;
p2shHeader = 23;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
port = 8333;
packetMagic = 0xf9beb4d9L;
bip32HeaderPub = 0x0488B21E; //The 4 byte header that serializes in base58 to "xpub".
bip32HeaderPriv = 0x0488ADE4; //The 4 byte header that serializes in base58 to "xprv"
id = ID_MAINNET;
}
}
}

View file

@ -0,0 +1,39 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class BitcoinInstant extends Coin {
public BitcoinInstant() {
super("Bitcoin Instant", "BTI", new Base58BitcoinAddressValidator(new BitcoinInstantParams()));
}
public static class BitcoinInstantParams extends NetworkParametersAdapter {
public BitcoinInstantParams() {
addressHeader = 0x66;
p2shHeader = 0x05;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
public class Bitcore extends Coin {
public Bitcore() {
super("Bitcore", "BTX", new Base58BitcoinAddressValidator());
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class Burstcoin extends Coin {
public Burstcoin() {
super("Burstcoin", "BURST", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,198 @@
/*
* 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.AddressValidator;
import bisq.asset.Coin;
import org.apache.commons.codec.binary.Base32;
import org.apache.commons.codec.binary.Base64;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Byteball extends Coin {
public Byteball() {
super("Byte", "GBYTE", new ByteballAddressValidator());
}
public static class ByteballAddressValidator implements AddressValidator {
private static final Base32 base32 = new Base32();
private static final Base64 base64 = new Base64();
private static final String PI = "14159265358979323846264338327950288419716939937510";
private static final String[] arrRelativeOffsets = PI.split("");
@SuppressWarnings("CanBeFinal")
private static Integer[] arrOffsets160;
@SuppressWarnings("CanBeFinal")
private static Integer[] arrOffsets288;
static {
try {
arrOffsets160 = calcOffsets(160);
} catch (Exception e) {
e.printStackTrace();
}
try {
arrOffsets288 = calcOffsets(288);
} catch (Exception e) {
e.printStackTrace();
}
}
public AddressValidationResult validate(String input) {
if (!isValidAddress(input)) {
return AddressValidationResult.invalidStructure();
}
return AddressValidationResult.validAddress();
}
private static boolean isValidAddress(String address) {
return isValidChash(address, 32);
}
private static boolean isValidChash(String str, int len) {
return (isStringOfLength(str, len) && isChashValid(str));
}
private static boolean isStringOfLength(String str, int len) {
return str.length() == len;
}
private static void checkLength(int chash_length) throws Exception {
if (chash_length != 160 && chash_length != 288)
throw new Exception("unsupported c-hash length: " + chash_length);
}
private static Integer[] calcOffsets(int chash_length) throws Exception {
checkLength(chash_length);
List<Integer> arrOffsets = new ArrayList<>(chash_length);
int offset = 0;
int index = 0;
for (int i = 0; offset < chash_length; i++) {
int relative_offset = Integer.parseInt(arrRelativeOffsets[i]);
if (relative_offset == 0)
continue;
offset += relative_offset;
if (chash_length == 288)
offset += 4;
if (offset >= chash_length)
break;
arrOffsets.add(offset);
//console.log("index="+index+", offset="+offset);
index++;
}
if (index != 32)
throw new Exception("wrong number of checksum bits");
//noinspection ToArrayCallWithZeroLengthArrayArgument
return arrOffsets.toArray(new Integer[0]);
}
private static ByteballAddressValidator.SeparatedData separateIntoCleanDataAndChecksum(String bin)
throws Exception {
int len = bin.length();
Integer[] arrOffsets;
if (len == 160)
arrOffsets = arrOffsets160;
else if (len == 288)
arrOffsets = arrOffsets288;
else
throw new Exception("bad length");
StringBuilder arrFrags = new StringBuilder();
StringBuilder arrChecksumBits = new StringBuilder();
int start = 0;
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < arrOffsets.length; i++) {
arrFrags.append(bin.substring(start, arrOffsets[i]));
arrChecksumBits.append(bin.substring(arrOffsets[i], arrOffsets[i] + 1));
start = arrOffsets[i] + 1;
}
// add last frag
if (start < bin.length())
arrFrags.append(bin.substring(start));
String binCleanData = arrFrags.toString();
String binChecksum = arrChecksumBits.toString();
return new ByteballAddressValidator.SeparatedData(binCleanData, binChecksum);
}
private static String buffer2bin(byte[] buf) {
StringBuilder bytes = new StringBuilder();
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < buf.length; i++) {
String bin = String.format("%8s", Integer.toBinaryString(buf[i] & 0xFF)).replace(' ', '0');
bytes.append(bin);
}
return bytes.toString();
}
private static byte[] bin2buffer(String bin) {
int len = bin.length() / 8;
byte[] buf = new byte[len];
for (int i = 0; i < len; i++)
buf[i] = (byte) Integer.parseInt(bin.substring(i * 8, (i + 1) * 8), 2);
return buf;
}
private static boolean isChashValid(String encoded) {
int encoded_len = encoded.length();
if (encoded_len != 32 && encoded_len != 48) // 160/5 = 32, 288/6 = 48
return false;
byte[] chash = (encoded_len == 32) ? base32.decode(encoded) : base64.decode(encoded);
String binChash = buffer2bin(chash);
ByteballAddressValidator.SeparatedData separated;
try {
separated = separateIntoCleanDataAndChecksum(binChash);
} catch (Exception e) {
return false;
}
byte[] clean_data = bin2buffer(separated.clean_data);
byte[] checksum = bin2buffer(separated.checksum);
return Arrays.equals(getChecksum(clean_data), checksum);
}
private static byte[] getChecksum(byte[] clean_data) {
try {
byte[] full_checksum = MessageDigest.getInstance("SHA-256").digest(clean_data);
return new byte[]{full_checksum[5], full_checksum[13], full_checksum[21], full_checksum[29]};
} catch (NoSuchAlgorithmException e) {
return null;
}
}
private static class SeparatedData {
final String clean_data;
final String checksum;
public SeparatedData(String clean_data, String checksum) {
this.clean_data = clean_data;
this.checksum = checksum;
}
}
}
}

View file

@ -0,0 +1,55 @@
/*
* 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 Cagecoin extends Coin {
public Cagecoin() {
super("Cagecoin", "CAGE", new CagecoinAddressValidator());
}
public static class CagecoinAddressValidator extends Base58BitcoinAddressValidator {
public CagecoinAddressValidator() {
super(new CagecoinParams());
}
@Override
public AddressValidationResult validate(String address) {
if (!address.matches("^[D][a-zA-Z0-9]{26,34}$"))
return AddressValidationResult.invalidStructure();
return super.validate(address);
}
}
public static class CagecoinParams extends NetworkParametersAdapter {
public CagecoinParams() {
addressHeader = 31;
p2shHeader = 13;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class CassubianDetk extends Coin {
public CassubianDetk() {
super("Cassubian Detk", "CDT", new RegexAddressValidator("^D.*"));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class Conceal extends Coin {
public Conceal() {
super("Conceal", "CCX", new RegexAddressValidator("^ccx7[1-9A-HJ-NP-Za-km-z]{94}$"));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class Counterparty extends Coin {
public Counterparty() {
super("Counterparty", "XCP", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,40 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class Creativecoin extends Coin {
public Creativecoin() {
super("Creativecoin", "CREA", new Base58BitcoinAddressValidator(new CreativecoinParams()));
}
public static class CreativecoinParams extends NetworkParametersAdapter {
public CreativecoinParams() {
int segwitHeader = 35;
addressHeader = 28;
p2shHeader = 5;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader, segwitHeader};
}
}
}

View file

@ -0,0 +1,57 @@
/*
* 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 Credits extends Coin {
public Credits() {
super("Credits", "CRDS", new CreditsAddressValidator());
}
public static class CreditsAddressValidator extends Base58BitcoinAddressValidator {
public CreditsAddressValidator() {
super(new CreditsParams());
}
@Override
public AddressValidationResult validate(String address) {
if (!address.matches("^[C][a-km-zA-HJ-NP-Z1-9]{25,34}$"))
return AddressValidationResult.invalidStructure();
return super.validate(address);
}
}
public static class CreditsParams extends NetworkParametersAdapter {
public CreditsParams() {
addressHeader = 28;
p2shHeader = 5;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,92 @@
/*
* 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.AddressValidator;
import bisq.asset.Coin;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
public class Cryptonite extends Coin {
public Cryptonite() {
super("Cryptonite", "XCN", new CryptoniteAddressValidator());
}
public static class CryptoniteAddressValidator implements AddressValidator {
private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@Override
public AddressValidationResult validate(String address) {
// https://bitcointalk.org/index.php?topic=1801595
if (address.length() != 34)
return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: Length must be 34!");
if (!address.startsWith("C"))
return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: must start with 'C'!");
byte[] decoded = decodeBase58(address);
if (decoded == null)
return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: Base58 decoder error!");
byte[] hash = getSha256(decoded, 21, 2);
if (hash == null || !Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 21, 25)))
return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: Checksum error!");
return AddressValidationResult.validAddress();
}
private static byte[] decodeBase58(String input) {
byte[] output = new byte[25];
for (int i = 0; i < input.length(); i++) {
char t = input.charAt(i);
int p = ALPHABET.indexOf(t);
if (p == -1)
return null;
for (int j = 25 - 1; j >= 0; j--, p /= 256) {
p += 58 * (output[j] & 0xFF);
output[j] = (byte) (p % 256);
}
if (p != 0)
return null;
}
return output;
}
private static byte[] getSha256(byte[] data, int len, int recursion) {
if (recursion == 0)
return data;
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(Arrays.copyOfRange(data, 0, len));
return getSha256(md.digest(), 32, recursion - 1);
} catch (NoSuchAlgorithmException e) {
return null;
}
}
}
}

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

View file

@ -0,0 +1,39 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class DACash extends Coin {
public DACash() {
super("DACash", "DAC", new Base58BitcoinAddressValidator(new DACashParams()));
}
public static class DACashParams extends NetworkParametersAdapter {
public DACashParams() {
addressHeader = 0x1f;
p2shHeader = 0x5a;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

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

View file

@ -0,0 +1,39 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class DSTRA extends Coin {
public DSTRA() {
super("DSTRA", "DST", new Base58BitcoinAddressValidator(new DSTRAParams()));
}
public static class DSTRAParams extends NetworkParametersAdapter {
public DSTRAParams() {
addressHeader = 35;
p2shHeader = 95;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class DarkNet extends Coin {
public DarkNet() {
super("DarkNet", "DNET", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,58 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import org.libdohj.params.DashMainNetParams;
import org.libdohj.params.DashRegTestParams;
import org.libdohj.params.DashTestNet3Params;
import org.bitcoinj.core.NetworkParameters;
public abstract class Dash extends Coin {
public Dash(Network network, NetworkParameters networkParameters) {
super("Dash", "DASH", new Base58BitcoinAddressValidator(networkParameters), network);
}
public static class Mainnet extends Dash {
public Mainnet() {
super(Network.MAINNET, DashMainNetParams.get());
}
}
public static class Testnet extends Dash {
public Testnet() {
super(Network.TESTNET, DashTestNet3Params.get());
}
}
public static class Regtest extends Dash {
public Regtest() {
super(Network.REGTEST, DashRegTestParams.get());
}
}
}

View file

@ -0,0 +1,36 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class Decent extends Coin {
public Decent() {
super("Decent", "DCT", new DecentAddressValidator());
}
public static class DecentAddressValidator extends RegexAddressValidator {
public DecentAddressValidator() {
super("^(?=.{5,63}$)([a-z][a-z0-9-]+[a-z0-9])(\\.[a-z][a-z0-9-]+[a-z0-9])*$");
}
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class Decred extends Coin {
public Decred() {
super("Decred", "DCR", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,39 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class DeepOnion extends Coin {
public DeepOnion() {
super("DeepOnion", "ONION", new Base58BitcoinAddressValidator(new DeepOnionParams()));
}
public static class DeepOnionParams extends NetworkParametersAdapter {
public DeepOnionParams() {
addressHeader = 31;
p2shHeader = 78;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
public class Devcoin extends Coin {
public Devcoin() {
super("Devcoin", "DVC", new Base58BitcoinAddressValidator());
}
}

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

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class DigiMoney extends Coin {
public DigiMoney() {
super("DigiMoney", "DGM", new RegexAddressValidator("^[D-E][a-zA-Z0-9]{33}$"));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class Dinero extends Coin {
public Dinero() {
super("Dinero", "DIN", new RegexAddressValidator("^[D][0-9a-zA-Z]{33}$"));
}
}

View file

@ -0,0 +1,30 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import org.libdohj.params.DogecoinMainNetParams;
public class Dogecoin extends Coin {
public Dogecoin() {
super("Dogecoin", "DOGE", new Base58BitcoinAddressValidator(DogecoinMainNetParams.get()));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class DynamicCoin extends Coin {
public DynamicCoin() {
super("DynamicCoin", "DMC", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class Espers extends Coin {
public Espers() {
super("Espers", "ESP", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.EtherAddressValidator;
public class Ether extends Coin {
public Ether() {
super("Ether", "ETH", new EtherAddressValidator());
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class EtherClassic extends Coin {
public EtherClassic() {
super("Ether Classic", "ETC", new DefaultAddressValidator());
}
}

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

View file

@ -0,0 +1,29 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class Graft extends Coin {
public Graft() {
super("Graft", "GRFT", new RegexAddressValidator("^G[0-9AB][1-9A-HJ-NP-Za-km-z]{93}$"));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class Gridcoin extends Coin {
public Gridcoin() {
super("Gridcoin", "GRC", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,29 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class InfinityEconomics extends Coin {
public InfinityEconomics() {
super("Infinity Economics", "XIN",
new RegexAddressValidator("^XIN-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{5}$"));
}
}

View file

@ -0,0 +1,61 @@
/*
* 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.AddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
public class Instacash extends Coin {
public Instacash() {
super("Instacash", "ICH", new InstacashAddressValidator());
}
public static class InstacashAddressValidator implements AddressValidator {
@Override
public AddressValidationResult validate(String address) {
if (!address.matches("^[A][a-km-zA-HJ-NP-Z1-9]{25,34}$"))
return AddressValidationResult.invalidStructure();
try {
Address.fromBase58(new InstacashParams(), address);
} catch (AddressFormatException ex) {
return AddressValidationResult.invalidAddress(ex);
}
return AddressValidationResult.validAddress();
}
}
public static class InstacashParams extends NetworkParametersAdapter {
public InstacashParams() {
addressHeader = 23;
p2shHeader = 13;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,57 @@
/*
* 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 InternetOfPeople extends Coin {
public InternetOfPeople() {
super("Internet of People", "IOP", new InternetOfPeopleAddressValidator());
}
public static class InternetOfPeopleAddressValidator extends Base58BitcoinAddressValidator {
public InternetOfPeopleAddressValidator() {
super(new InternetOfPeopleParams());
}
@Override
public AddressValidationResult validate(String address) {
if (!address.matches("^[p][a-km-zA-HJ-NP-Z1-9]{25,34}$"))
return AddressValidationResult.invalidStructure();
return super.validate(address);
}
}
public static class InternetOfPeopleParams extends NetworkParametersAdapter {
public InternetOfPeopleParams() {
super();
addressHeader = 117;
p2shHeader = 174;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,92 @@
/*
* 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.AddressValidator;
import bisq.asset.Coin;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
public class Koto extends Coin {
public Koto() {
super("Koto", "KOTO", new KotoAddressValidator());
}
public static class KotoAddressValidator implements AddressValidator {
private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@Override
public AddressValidationResult validate(String address) {
if (address.startsWith("z"))
return AddressValidationResult.invalidAddress("KOTO_Addr_Invalid: z Address not supported!");
if (address.length() != 35)
return AddressValidationResult.invalidAddress("KOTO_Addr_Invalid: Length must be 35!");
if (!address.startsWith("k1") && !address.startsWith("jz"))
return AddressValidationResult.invalidAddress("KOTO_Addr_Invalid: must start with 'k1' or 'jz'!");
byte[] decoded = decodeBase58(address, 58, 26);
if (decoded == null)
return AddressValidationResult.invalidAddress("KOTO_Addr_Invalid: Base58 decoder error!");
byte[] hash = getSha256(decoded, 0, 22, 2);
if (hash == null || !Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 22, 26)))
return AddressValidationResult.invalidAddress("KOTO_Addr_Invalid: Checksum error!");
return AddressValidationResult.validAddress();
}
private static byte[] decodeBase58(String input, int base, int len) {
byte[] output = new byte[len];
for (int i = 0; i < input.length(); i++) {
char t = input.charAt(i);
int p = ALPHABET.indexOf(t);
if (p == -1)
return null;
for (int j = len - 1; j >= 0; j--, p /= 256) {
p += base * (output[j] & 0xFF);
output[j] = (byte) (p % 256);
}
if (p != 0)
return null;
}
return output;
}
private static byte[] getSha256(byte[] data, int start, int len, int recursion) {
if (recursion == 0)
return data;
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(Arrays.copyOfRange(data, start, start + len));
return getSha256(md.digest(), 0, 32, recursion - 1);
} catch (NoSuchAlgorithmException e) {
return null;
}
}
}
}

View file

@ -0,0 +1,39 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class Kumacoin extends Coin {
public Kumacoin() {
super("Kumacoin", "KUMA", new Base58BitcoinAddressValidator(new KumacoinParams()));
}
public static class KumacoinParams extends NetworkParametersAdapter {
public KumacoinParams() {
addressHeader = 45;
p2shHeader = 8;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class LBRY extends Coin {
public LBRY() {
super("LBRY Credits", "LBC", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class Lisk extends Coin {
public Lisk() {
super("Lisk", "LSK", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,58 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import org.libdohj.params.LitecoinMainNetParams;
import org.libdohj.params.LitecoinRegTestParams;
import org.libdohj.params.LitecoinTestNet3Params;
import org.bitcoinj.core.NetworkParameters;
public abstract class Litecoin extends Coin {
public Litecoin(Network network, NetworkParameters networkParameters) {
super("Litecoin", "LTC", new Base58BitcoinAddressValidator(networkParameters), network);
}
public static class Mainnet extends Litecoin {
public Mainnet() {
super(Network.MAINNET, LitecoinMainNetParams.get());
}
}
public static class Testnet extends Litecoin {
public Testnet() {
super(Network.TESTNET, LitecoinTestNet3Params.get());
}
}
public static class Regtest extends Litecoin {
public Regtest() {
super(Network.REGTEST, LitecoinRegTestParams.get());
}
}
}

View file

@ -0,0 +1,27 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class LitecoinExtreme extends Coin {
public LitecoinExtreme(){
super("LitecoinExtreme", "LCE", new RegexAddressValidator("^[E][a-km-zA-HJ-NP-Z1-9]{33}$"));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class Lobstex extends Coin {
public Lobstex() {
super("Lobstex", "LOBS", new RegexAddressValidator("^L[1-9A-Za-z]{26,33}$"));
}
}

View file

@ -0,0 +1,27 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class MFCoin extends Coin {
public MFCoin(){
super("MFCoin", "MFC", new RegexAddressValidator("^[M][a-km-zA-HJ-NP-Z1-9]{33}$"));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class Madbyte extends Coin {
public Madbyte() {
super("Madbyte", "MBYT", new RegexAddressValidator("^[M][a-zA-Z0-9]{33}$"));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class Madcoin extends Coin {
public Madcoin() {
super("Madcoin", "MDC", new RegexAddressValidator("^m[a-zA-Z0-9]{26,33}$"));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class MaidSafeCoin extends Coin {
public MaidSafeCoin() {
super("MaidSafeCoin", "MAID", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class MaxCoin extends Coin {
public MaxCoin() {
super("MaxCoin", "MAX", new RegexAddressValidator("^m[1-9A-Za-z]{26,33}$"));
}
}

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

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

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class MicroCoin extends Coin {
public MicroCoin() {
super("MicroCoin", "MCC", new RegexAddressValidator("([0-9]+\\-[0-9]{2})"));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class Monero extends Coin {
public Monero() {
super("Monero", "XMR", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,39 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class Motion extends Coin {
public Motion() {
super("Motion", "XMN", new Base58BitcoinAddressValidator(new MotionParams()));
}
public static class MotionParams extends NetworkParametersAdapter {
public MotionParams() {
addressHeader = 50;
p2shHeader = 18;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,40 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class Myriadcoin extends Coin {
public Myriadcoin() {
super("Myriadcoin", "XMY", new Base58BitcoinAddressValidator(new MyriadcoinParams()));
}
public static class MyriadcoinParams extends NetworkParametersAdapter {
public MyriadcoinParams() {
super();
addressHeader = 50;
p2shHeader = 9;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,39 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class NEETCOIN extends Coin {
public NEETCOIN() {
super("NEETCOIN", "NEET", new Base58BitcoinAddressValidator(new NEETCOINParams()));
}
public static class NEETCOINParams extends NetworkParametersAdapter {
public NEETCOINParams() {
addressHeader = 53;
p2shHeader = 112;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class Namecoin extends Coin {
public Namecoin() {
super("Namecoin", "NMC", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,30 @@
/*
* 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.Coin;
import bisq.asset.RegexAddressValidator;
public class Nano extends Coin {
private static final String NANO_REGEX = "^(nano_|xrb_)[13456789abcdefghijkmnopqrstuwxyz]{60}";
public Nano() {
super("Nano", "NANO", new RegexAddressValidator(NANO_REGEX));
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class NavCoin extends Coin {
public NavCoin() {
super("Nav Coin", "NAV", new DefaultAddressValidator());
}
}

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

View file

@ -0,0 +1,87 @@
package bisq.asset.coins;
import bisq.asset.AddressValidationResult;
import bisq.asset.AddressValidator;
import bisq.asset.Coin;
import org.bouncycastle.jcajce.provider.digest.Keccak;
import java.nio.charset.StandardCharsets;
public class Nilu extends Coin {
public Nilu() {
super("Nilu", "NILU", new NiluAddressValidator());
}
private static class NiluAddressValidator implements AddressValidator {
private static final String upperOrLowerPattern = "(0x)?([0-9a-f]{40}|[0-9A-F]{40})";
private static final String mixPattern = "(0x)?([0-9a-fA-F]{40})";
@Override
public AddressValidationResult validate(String address) {
if (!isValidAddress(address))
return AddressValidationResult.invalidStructure();
return AddressValidationResult.validAddress();
}
private boolean isValidAddress(String eip55) {
if (eip55 == null || eip55.isEmpty())
return false;
if (eip55.matches(upperOrLowerPattern))
return true;
if (!eip55.matches(mixPattern))
return false;
String addr = convertToEip55Address(eip55);
return addr.replaceFirst("0x", "").equals(eip55.replaceFirst("0x", ""));
}
private String convertToEip55Address(String input) {
String addr = input.replaceFirst("0x", "").toLowerCase();
StringBuilder ret = new StringBuilder("0x");
String hash = sha3String(addr).substring(2);
for (int i = 0; i < addr.length(); i++) {
String a = addr.charAt(i) + "";
ret.append(Integer.parseInt(hash.charAt(i) + "", 16) > 7 ? a.toUpperCase() : a);
}
return ret.toString();
}
private static byte[] sha3(byte[] input, int offset, int length) {
Keccak.DigestKeccak kecc = new Keccak.Digest256();
kecc.update(input, offset, length);
return kecc.digest();
}
private static byte[] sha3(byte[] input) {
return sha3(input, 0, input.length);
}
private static String toHexString(byte[] input, int offset, int length, boolean withPrefix) {
StringBuilder stringBuilder = new StringBuilder();
if (withPrefix) {
stringBuilder.append("0x");
}
for (int i = offset; i < offset + length; ++i) {
stringBuilder.append(String.format("%02x", input[i] & 255));
}
return stringBuilder.toString();
}
private static String toHexString(byte[] input) {
return toHexString(input, 0, input.length, true);
}
private static String sha3String(String utf8String) {
return toHexString(sha3(utf8String.getBytes(StandardCharsets.UTF_8)));
}
}
}

View file

@ -0,0 +1,63 @@
/*
* 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.AddressValidator;
import bisq.asset.Coin;
public class Nimiq extends Coin {
public Nimiq() {
super("Nimiq", "NIM", new NimiqAddressValidator());
}
/**
* Nimiq Address validation code derived from the original JavaScript implementation
*/
public static class NimiqAddressValidator implements AddressValidator {
@Override
public AddressValidationResult validate(String address) {
address = address.replace(" ", "");
if (!address.matches("NQ[0-9]{2}[0-9A-HJ-NP-VXY]{32}")) {
return AddressValidationResult.invalidStructure();
}
if (ibanCheck(address.substring(4) + address.substring(0, 4)) != 1) {
return AddressValidationResult.invalidAddress("Checksum invalid");
}
return AddressValidationResult.validAddress();
}
private int ibanCheck(String str) {
StringBuilder sb = new StringBuilder();
for (char c : str.toUpperCase().toCharArray()) {
if (c >= 48 && c <= 57) {
sb.append(c);
} else {
sb.append(Integer.toString(c - 55));
}
}
String num = sb.toString();
int tmp = 0;
for (int i = 0; i < Math.ceil(num.length() / 6.0); i++) {
tmp = Integer.parseInt(tmp + num.substring(i * 6, Math.min((i + 1) * 6, num.length()))) % 97;
}
return tmp;
}
}
}

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class NuBits extends Coin {
public NuBits() {
super("NuBits", "NBT", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,227 @@
/*
* 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.AddressValidator;
import bisq.asset.Coin;
public class Nxt extends Coin {
public Nxt() {
super("Nxt", "NXT", new NxtAddressValidator());
}
public static class NxtAddressValidator implements AddressValidator {
@Override
public AddressValidationResult validate(String address) {
if (!address.startsWith("NXT-") || !address.equals(address.toUpperCase()))
return AddressValidationResult.invalidStructure();
try {
long accountId = NxtReedSolomonValidator.decode(address.substring(4));
if (accountId == 0)
return AddressValidationResult.invalidStructure();
} catch (NxtReedSolomonValidator.DecodeException e) {
return AddressValidationResult.invalidAddress(e);
}
return AddressValidationResult.validAddress();
}
}
public static final class NxtReedSolomonValidator {
private static final int[] initial_codeword = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
private static final int[] gexp = {
1, 2, 4, 8, 16, 5, 10, 20, 13, 26, 17, 7, 14, 28, 29, 31,
27, 19, 3, 6, 12, 24, 21, 15, 30, 25, 23, 11, 22, 9, 18, 1};
private static final int[] glog = {
0, 0, 1, 18, 2, 5, 19, 11, 3, 29, 6, 27, 20, 8, 12, 23, 4,
10, 30, 17, 7, 22, 28, 26, 21, 25, 9, 16, 13, 14, 24, 15};
private static final int[] codeword_map = {3, 2, 1, 0, 7, 6, 5, 4, 13, 14, 15, 16, 12, 8, 9, 10, 11};
private static final String alphabet = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
private static final int base_32_length = 13;
private static final int base_10_length = 20;
public static String encode(long plain) {
String plain_string = Long.toUnsignedString(plain);
int length = plain_string.length();
int[] plain_string_10 = new int[NxtReedSolomonValidator.base_10_length];
for (int i = 0; i < length; i++) {
plain_string_10[i] = (int) plain_string.charAt(i) - (int) '0';
}
int codeword_length = 0;
int[] codeword = new int[NxtReedSolomonValidator.initial_codeword.length];
do { // base 10 to base 32 conversion
int new_length = 0;
int digit_32 = 0;
for (int i = 0; i < length; i++) {
digit_32 = digit_32 * 10 + plain_string_10[i];
if (digit_32 >= 32) {
plain_string_10[new_length] = digit_32 >> 5;
digit_32 &= 31;
new_length += 1;
} else if (new_length > 0) {
plain_string_10[new_length] = 0;
new_length += 1;
}
}
length = new_length;
codeword[codeword_length] = digit_32;
codeword_length += 1;
} while (length > 0);
int[] p = {0, 0, 0, 0};
for (int i = NxtReedSolomonValidator.base_32_length - 1; i >= 0; i--) {
final int fb = codeword[i] ^ p[3];
p[3] = p[2] ^ NxtReedSolomonValidator.gmult(30, fb);
p[2] = p[1] ^ NxtReedSolomonValidator.gmult(6, fb);
p[1] = p[0] ^ NxtReedSolomonValidator.gmult(9, fb);
p[0] = NxtReedSolomonValidator.gmult(17, fb);
}
System.arraycopy(
p, 0, codeword, NxtReedSolomonValidator.base_32_length,
NxtReedSolomonValidator.initial_codeword.length - NxtReedSolomonValidator.base_32_length);
StringBuilder cypher_string_builder = new StringBuilder();
for (int i = 0; i < 17; i++) {
final int codework_index = NxtReedSolomonValidator.codeword_map[i];
final int alphabet_index = codeword[codework_index];
cypher_string_builder.append(NxtReedSolomonValidator.alphabet.charAt(alphabet_index));
if ((i & 3) == 3 && i < 13) {
cypher_string_builder.append('-');
}
}
return cypher_string_builder.toString();
}
public static long decode(String cypher_string) throws DecodeException {
int[] codeword = new int[NxtReedSolomonValidator.initial_codeword.length];
System.arraycopy(
NxtReedSolomonValidator.initial_codeword, 0, codeword, 0,
NxtReedSolomonValidator.initial_codeword.length);
int codeword_length = 0;
for (int i = 0; i < cypher_string.length(); i++) {
int position_in_alphabet = NxtReedSolomonValidator.alphabet.indexOf(cypher_string.charAt(i));
if (position_in_alphabet <= -1 || position_in_alphabet > NxtReedSolomonValidator.alphabet.length()) {
continue;
}
if (codeword_length > 16) {
throw new CodewordTooLongException();
}
int codework_index = NxtReedSolomonValidator.codeword_map[codeword_length];
codeword[codework_index] = position_in_alphabet;
codeword_length += 1;
}
if (codeword_length == 17 && !NxtReedSolomonValidator.is_codeword_valid(codeword) || codeword_length != 17) {
throw new CodewordInvalidException();
}
int length = NxtReedSolomonValidator.base_32_length;
int[] cypher_string_32 = new int[length];
for (int i = 0; i < length; i++) {
cypher_string_32[i] = codeword[length - i - 1];
}
StringBuilder plain_string_builder = new StringBuilder();
do { // base 32 to base 10 conversion
int new_length = 0;
int digit_10 = 0;
for (int i = 0; i < length; i++) {
digit_10 = digit_10 * 32 + cypher_string_32[i];
if (digit_10 >= 10) {
cypher_string_32[new_length] = digit_10 / 10;
digit_10 %= 10;
new_length += 1;
} else if (new_length > 0) {
cypher_string_32[new_length] = 0;
new_length += 1;
}
}
length = new_length;
plain_string_builder.append((char) (digit_10 + (int) '0'));
} while (length > 0);
return Long.parseUnsignedLong(plain_string_builder.reverse().toString());
}
private static int gmult(int a, int b) {
if (a == 0 || b == 0) {
return 0;
}
int idx = (NxtReedSolomonValidator.glog[a] + NxtReedSolomonValidator.glog[b]) % 31;
return NxtReedSolomonValidator.gexp[idx];
}
private static boolean is_codeword_valid(int[] codeword) {
int sum = 0;
for (int i = 1; i < 5; i++) {
int t = 0;
for (int j = 0; j < 31; j++) {
if (j > 12 && j < 27) {
continue;
}
int pos = j;
if (j > 26) {
pos -= 14;
}
t ^= NxtReedSolomonValidator.gmult(codeword[pos], NxtReedSolomonValidator.gexp[(i * j) % 31]);
}
sum |= t;
}
return sum == 0;
}
public abstract static class DecodeException extends Exception {
}
static final class CodewordTooLongException extends DecodeException {
}
static final class CodewordInvalidException extends DecodeException {
}
private NxtReedSolomonValidator() {
} // never
}
}

View file

@ -0,0 +1,39 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class Obsidian extends Coin {
public Obsidian() {
super("Obsidian", "ODN", new Base58BitcoinAddressValidator(new ObsidianParams()));
}
public static class ObsidianParams extends NetworkParametersAdapter {
public ObsidianParams() {
addressHeader = 75;
p2shHeader = 125;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

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

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

View file

@ -0,0 +1,39 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class PRiVCY extends Coin {
public PRiVCY() {
super("PRiVCY", "PRIV", new Base58BitcoinAddressValidator(new PRiVCYParams()));
}
public static class PRiVCYParams extends NetworkParametersAdapter {
public PRiVCYParams() {
addressHeader = 55;
p2shHeader = 78;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

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

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class PepeCash extends Coin {
public PepeCash() {
super("Pepe Cash", "PEPECASH", new DefaultAddressValidator());
}
}

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

View file

@ -0,0 +1,28 @@
/*
* 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.Coin;
import bisq.asset.DefaultAddressValidator;
public class PostCoin extends Coin {
public PostCoin() {
super("PostCoin", "POST", new DefaultAddressValidator());
}
}

View file

@ -0,0 +1,102 @@
/*
* 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;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
public class Pranacoin extends Coin {
public Pranacoin() {
super("Pranacoin", "PNC", new PranacoinAddressValidator());
}
public static class PranacoinAddressValidator extends Base58BitcoinAddressValidator {
private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
public PranacoinAddressValidator() {
super(new Pranacoin.PranacoinParams());
}
@Override
public AddressValidationResult validate(String address) {
if (!address.matches("^[P3][a-km-zA-HJ-NP-Z1-9]{25,34}$"))
return AddressValidationResult.invalidStructure();
if (!validateAddress(address))
return AddressValidationResult.invalidStructure();
return super.validate(address);
}
public static boolean validateAddress(String addr) {
if (addr.length() < 26 || addr.length() > 35) return false;
byte[] decoded = decodeBase58(addr, 58, 25);
if (decoded == null) return false;
byte[] hash = getSha256(decoded, 0, 21, 2);
return hash != null && Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 21, 25));
}
private static byte[] decodeBase58(String input, int base, int len) {
byte[] output = new byte[len];
for (int i = 0; i < input.length(); i++) {
char t = input.charAt(i);
int p = ALPHABET.indexOf(t);
if (p == -1) return null;
for (int j = len - 1; j >= 0; j--, p /= 256) {
p += base * (output[j] & 0xFF);
output[j] = (byte) (p % 256);
}
if (p != 0) return null;
}
return output;
}
private static byte[] getSha256(byte[] data, int start, int len, int recursion) {
if (recursion == 0) return data;
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(Arrays.copyOfRange(data, start, start + len));
return getSha256(md.digest(), 0, 32, recursion - 1);
} catch (NoSuchAlgorithmException e) {
return null;
}
}
}
public static class PranacoinParams extends NetworkParametersAdapter {
public PranacoinParams() {
addressHeader = 55;
p2shHeader = 5;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

Some files were not shown because too many files have changed in this diff Show more