mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Merge branch 'DAO' into disk-protobuffer
This commit is contained in:
commit
3a79e573ff
26 changed files with 534 additions and 77 deletions
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.common;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.common.crypto;
|
||||
|
|
|
@ -138,6 +138,7 @@ public class CurrencyUtil {
|
|||
result.add(new CryptoCurrency("HNC", "HunCoin"));
|
||||
result.add(new CryptoCurrency("IOC", "I/O Coin"));
|
||||
result.add(new CryptoCurrency("IOP", "Fermat"));
|
||||
result.add(new CryptoCurrency("JNS", "Janus", true));
|
||||
result.add(new CryptoCurrency("JPYT", "JPY Tether"));
|
||||
result.add(new CryptoCurrency("JBS", "Jumbucks"));
|
||||
result.add(new CryptoCurrency("LBC", "LBRY Credits"));
|
||||
|
@ -158,6 +159,7 @@ public class CurrencyUtil {
|
|||
result.add(new CryptoCurrency("NBT", "NuBits"));
|
||||
result.add(new CryptoCurrency("NSR", "NuShares"));
|
||||
result.add(new CryptoCurrency("NXT", "Nxt"));
|
||||
result.add(new CryptoCurrency("888", "OctoCoin"));
|
||||
result.add(new CryptoCurrency("OK", "OKCash"));
|
||||
result.add(new CryptoCurrency("OMNI", "Omni"));
|
||||
result.add(new CryptoCurrency("OPAL", "Opal"));
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.common.proto;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.common.proto;
|
||||
|
|
|
@ -58,7 +58,7 @@ public class JsonFileManager {
|
|||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void writeToDisc(String json, String fileName) {
|
||||
executor.execute(() -> {
|
||||
File jsonFile = new File(Paths.get(dir.getAbsolutePath(), fileName + ".json").toString());
|
||||
|
|
|
@ -956,7 +956,8 @@ dao.wallet.send.send=Send BSQ funds
|
|||
dao.wallet.send.sendFunds.headline=Confirm withdrawal request
|
||||
dao.wallet.send.sendFunds.details=Sending: {0}\nTo receiving address: {1}.\nRequired transaction fee is: {2} ({3} Satoshis/byte)\nTransaction size: {4} Kb\n\nThe recipient will receive: {5}\n\nAre you sure you want to withdraw that amount?
|
||||
dao.wallet.bsqFee=BSQ fee payment
|
||||
dao.wallet.chainHeight=Synced with blockchain height: {0} (chain tip height: {1})
|
||||
dao.wallet.chainHeightSynced=Synchronized with blockchain height. Current height: {0} / Best chain height: {1}
|
||||
dao.wallet.chainHeightSyncing=Synchronizing with blockchain height. Current height: {0} / Best chain height: {1}
|
||||
|
||||
dao.wallet.tx.type=Type
|
||||
dao.tx.type.enum.UNVERIFIED=Unverified BSQ transaction
|
||||
|
|
|
@ -1019,7 +1019,7 @@ popup.error.tryRestart=Por favor pruebe a reiniciar la aplicación y comprobar s
|
|||
popup.error.createTx=Error creando la transacción\: {0}
|
||||
|
||||
popup.warning.walletNotInitialized=La cartera aún no sea ha iniciado
|
||||
popup.warning.wrongVersion=Probablemente tenga una versión de Bitsquare incorrecta para este ordenador.\nLa arquitectura de su ordenador es\: {0}.\nLos binarios de Bitsquare instalados son\: {1}.\nPor favor cierre y reinstale la versión correcta ( {2} ).
|
||||
popup.warning.wrongVersion=Probablemente tenga una versión de bisq incorrecta para este ordenador.\nLa arquitectura de su ordenador es\: {0}.\nLos binarios de Bitsquare instalados son\: {1}.\nPor favor cierre y reinstale la versión correcta ( {2} ).
|
||||
popup.warning.incompatibleDB=Hemos detectado archivos de base de datos incompatbles\!\n\nEstos archivos de base de datos no son compatibles con nuestro actual código base\:\n{0}\n\nHemos hecho una copia de seguridad de el archivo/s corrupto/s y aplicado los valores por defecto a la nueva versión de la base de datos.\n\nLa copia de seguridad se encuentra en\:\n{1}/db/backup_of_corrupted_data.\n\nPor favor compruebe que tiene la última versión de bisq instalada.\nPuede descargarla en\:\nhttps\://bisq.io/downloads\n\nPor favor, reinicie la aplicación.
|
||||
popup.warning.cannotConnectAtStartup=Aún no se ha conecta a la red {0}.\nSi aún usa Tor para Bitcoin puede ser que tenga un circuito Tor inestable.\nPuede esperar más o intentar reiniciando.
|
||||
popup.warning.unknownProblemAtStartup=Hay un problema desconocido al inicio.\nPor favor, reinicea y si el problema continua realice un reporte de error.
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.core.btc.wallet;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.core.btc.wallet;
|
||||
|
|
|
@ -98,7 +98,7 @@ public class BsqLiteNode extends BsqNode {
|
|||
NodeAddress peersNodeAddress = p2PService.getSeedNodeAddresses().stream().findFirst().get();
|
||||
|
||||
GetBsqBlocksRequest getBsqBlocksRequest = new GetBsqBlocksRequest(startBlockHeight);
|
||||
log.info("sendMessage " + getBsqBlocksRequest + " to " + peersNodeAddress);
|
||||
log.info("sendMessage " + getBsqBlocksRequest + " to " + peersNodeAddress + " with startBlockHeight=" + startBlockHeight);
|
||||
SettableFuture<Connection> future = p2PService.getNetworkNode().sendMessage(peersNodeAddress, getBsqBlocksRequest);
|
||||
Futures.addCallback(future, new FutureCallback<Connection>() {
|
||||
@Override
|
||||
|
@ -133,7 +133,9 @@ public class BsqLiteNode extends BsqNode {
|
|||
GetBsqBlocksResponse getBsqBlocksResponse = (GetBsqBlocksResponse) msg;
|
||||
byte[] bsqBlocksBytes = getBsqBlocksResponse.getBsqBlocksBytes();
|
||||
List<BsqBlock> bsqBlockList = Utilities.<ArrayList<BsqBlock>>deserialize(bsqBlocksBytes);
|
||||
log.info("received msg with {} items", bsqBlockList.size());
|
||||
log.info("received msg with {} items", bsqBlockList.size(), bsqBlockList.get(bsqBlockList.size() - 1).getHeight());
|
||||
if (bsqBlockList.size() > 0)
|
||||
log.info("block height of last item: ", bsqBlockList.get(bsqBlockList.size() - 1).getHeight());
|
||||
// Be safe and reset all mutable data in case the provider would not have done it
|
||||
bsqBlockList.stream().forEach(BsqBlock::reset);
|
||||
bsqLiteNodeExecutor.parseBsqBlocksForLiteNode(bsqBlockList,
|
||||
|
@ -156,7 +158,7 @@ public class BsqLiteNode extends BsqNode {
|
|||
BsqBlock bsqBlock = Utilities.<BsqBlock>deserialize(bsqBlockBytes);
|
||||
// Be safe and reset all mutable data in case the provider would not have done it
|
||||
bsqBlock.reset();
|
||||
log.info("received broadcastNewBsqBlock bsqBlock {}", bsqBlock);
|
||||
log.info("received broadcastNewBsqBlock bsqBlock {}", bsqBlock.getHeight());
|
||||
if (!bsqChainState.containsBlock(bsqBlock)) {
|
||||
bsqLiteNodeExecutor.parseBsqBlockForLiteNode(bsqBlock,
|
||||
genesisBlockHeight,
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.google.common.util.concurrent.Futures;
|
|||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.inject.Inject;
|
||||
import io.bisq.common.storage.FileUtil;
|
||||
import io.bisq.common.storage.JsonFileManager;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.common.util.Utilities;
|
||||
|
@ -35,6 +36,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
import javax.inject.Named;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -56,21 +58,33 @@ public class JsonChainStateExporter {
|
|||
this.bsqChainState = bsqChainState;
|
||||
this.dumpBlockchainData = dumpBlockchainData;
|
||||
|
||||
init(storageDir, dumpBlockchainData);
|
||||
}
|
||||
|
||||
private void init(@Named(Storage.STORAGE_DIR) File storageDir, @Named(DaoOptionKeys.DUMP_BLOCKCHAIN_DATA) boolean dumpBlockchainData) {
|
||||
if (dumpBlockchainData) {
|
||||
txDir = new File(Paths.get(storageDir.getAbsolutePath(), "tx").toString());
|
||||
if (!txDir.exists())
|
||||
if (!txDir.mkdir())
|
||||
log.warn("make txDir failed.\ntxDir=" + txDir.getAbsolutePath());
|
||||
|
||||
txOutputDir = new File(Paths.get(storageDir.getAbsolutePath(), "txo").toString());
|
||||
if (!txOutputDir.exists())
|
||||
if (!txOutputDir.mkdir())
|
||||
log.warn("make txOutputDir failed.\ntxOutputDir=" + txOutputDir.getAbsolutePath());
|
||||
|
||||
bsqChainStateDir = new File(Paths.get(storageDir.getAbsolutePath(), "all").toString());
|
||||
if (!bsqChainStateDir.exists())
|
||||
if (!bsqChainStateDir.mkdir())
|
||||
log.warn("make bsqChainStateDir failed.\nbsqChainStateDir=" + bsqChainStateDir.getAbsolutePath());
|
||||
try {
|
||||
if (txDir.exists())
|
||||
FileUtil.deleteDirectory(txDir);
|
||||
if (txOutputDir.exists())
|
||||
FileUtil.deleteDirectory(txOutputDir);
|
||||
if (bsqChainStateDir.exists())
|
||||
FileUtil.deleteDirectory(bsqChainStateDir);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!txDir.mkdir())
|
||||
log.warn("make txDir failed.\ntxDir=" + txDir.getAbsolutePath());
|
||||
|
||||
if (!txOutputDir.mkdir())
|
||||
log.warn("make txOutputDir failed.\ntxOutputDir=" + txOutputDir.getAbsolutePath());
|
||||
|
||||
if (!bsqChainStateDir.mkdir())
|
||||
log.warn("make bsqChainStateDir failed.\nbsqChainStateDir=" + bsqChainStateDir.getAbsolutePath());
|
||||
|
||||
txFileManager = new JsonFileManager(txDir);
|
||||
txOutputFileManager = new JsonFileManager(txOutputDir);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.core.dao.blockchain.json;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.core.dao.blockchain.json;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.core.dao.blockchain.parse;
|
||||
|
@ -156,7 +156,6 @@ public class BsqChainState implements Persistable {
|
|||
public void applySnapshot() {
|
||||
lock.write(() -> {
|
||||
BsqChainState snapshot = snapshotBsqChainStateStorage.initAndGetPersistedWithFileName("BsqChainState");
|
||||
|
||||
blocks.clear();
|
||||
txMap.clear();
|
||||
unspentTxOutputsMap.clear();
|
||||
|
@ -164,11 +163,14 @@ public class BsqChainState implements Persistable {
|
|||
genesisTx = null;
|
||||
|
||||
if (snapshot != null) {
|
||||
log.info("applySnapshot snapshot.chainHeadHeight=" + snapshot.chainHeadHeight);
|
||||
blocks.addAll(snapshot.blocks);
|
||||
txMap.putAll(snapshot.txMap);
|
||||
unspentTxOutputsMap.putAll(snapshot.unspentTxOutputsMap);
|
||||
chainHeadHeight = snapshot.chainHeadHeight;
|
||||
genesisTx = snapshot.genesisTx;
|
||||
} else {
|
||||
log.info("Try to apply snapshot but no stored snapshot available");
|
||||
}
|
||||
|
||||
printDetails();
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.core.dao.blockchain.vo;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.core.dao.blockchain.vo;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.core.user;
|
||||
|
|
|
@ -47,6 +47,7 @@ import javafx.collections.transformation.SortedList;
|
|||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.Callback;
|
||||
|
@ -81,6 +82,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
|
|||
private Label chainHeightLabel;
|
||||
private BsqChainStateListener bsqChainStateListener;
|
||||
private BsqBalanceListener bsqBalanceListener;
|
||||
private ProgressBar chainSyncIndicator;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -116,16 +118,25 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
|
|||
addConfidenceColumn();
|
||||
addTxTypeColumn();
|
||||
|
||||
chainSyncIndicator = new ProgressBar();
|
||||
chainSyncIndicator.setPrefWidth(120);
|
||||
chainSyncIndicator.setProgress(-1);
|
||||
chainSyncIndicator.setPadding(new Insets(-6, 0, -10, 5));
|
||||
|
||||
chainHeightLabel = FormBuilder.addLabel(root, ++gridRow, "");
|
||||
chainHeightLabel.setId("num-offers");
|
||||
chainHeightLabel.setPadding(new Insets(-5, 0, -10, 5));
|
||||
|
||||
HBox hBox = new HBox();
|
||||
hBox.setSpacing(10);
|
||||
hBox.getChildren().addAll(chainHeightLabel, chainSyncIndicator);
|
||||
|
||||
VBox vBox = new VBox();
|
||||
vBox.setSpacing(10);
|
||||
GridPane.setRowIndex(vBox, ++gridRow);
|
||||
GridPane.setColumnSpan(vBox, 2);
|
||||
GridPane.setMargin(vBox, new Insets(40, -10, 5, -10));
|
||||
vBox.getChildren().addAll(tableView, chainHeightLabel);
|
||||
vBox.getChildren().addAll(tableView, hBox);
|
||||
root.getChildren().add(vBox);
|
||||
|
||||
walletBsqTransactionsListener = change -> updateList();
|
||||
|
@ -170,9 +181,26 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
|
|||
}
|
||||
|
||||
private void onChainHeightChanged() {
|
||||
chainHeightLabel.setText(Res.get("dao.wallet.chainHeight",
|
||||
bsqChainState.getChainHeadHeight(),
|
||||
bsqWalletService.getBestChainHeight()));
|
||||
if (bsqWalletService.getBestChainHeight() > 0) {
|
||||
final boolean synced = bsqWalletService.getBestChainHeight() == bsqChainState.getChainHeadHeight();
|
||||
chainSyncIndicator.setVisible(!synced);
|
||||
chainSyncIndicator.setManaged(!synced);
|
||||
if (bsqChainState.getChainHeadHeight() > 0)
|
||||
chainSyncIndicator.setProgress((double) bsqChainState.getChainHeadHeight() / (double) bsqWalletService.getBestChainHeight());
|
||||
|
||||
if (synced)
|
||||
chainHeightLabel.setText(Res.get("dao.wallet.chainHeightSynced",
|
||||
bsqChainState.getChainHeadHeight(),
|
||||
bsqWalletService.getBestChainHeight()));
|
||||
else
|
||||
chainHeightLabel.setText(Res.get("dao.wallet.chainHeightSyncing",
|
||||
bsqChainState.getChainHeadHeight(),
|
||||
bsqWalletService.getBestChainHeight()));
|
||||
} else {
|
||||
chainHeightLabel.setText(Res.get("dao.wallet.chainHeightSyncing",
|
||||
bsqChainState.getChainHeadHeight(),
|
||||
bsqWalletService.getBestChainHeight()));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
|
|
|
@ -170,6 +170,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
|
|||
Label label = new Label(Res.get("support.filter"));
|
||||
HBox.setMargin(label, new Insets(5, 0, 0, 0));
|
||||
filterTextField = new InputTextField();
|
||||
filterTextField.setText("open");
|
||||
filterTextFieldListener = (observable, oldValue, newValue) -> applyFilteredListPredicate(filterTextField.getText());
|
||||
|
||||
filterBox = new HBox();
|
||||
|
|
|
@ -131,13 +131,13 @@ public class SpendFromDepositTxWindow extends Overlay<SpendFromDepositTxWindow>
|
|||
sellerPubKeyAsHex.setText("");
|
||||
sellerPrivateKeyAsHex.setText("");
|
||||
|
||||
//4.9
|
||||
//4.9 (pkfcmj42c6es6tjt.onion)
|
||||
// arbitratorAddressString.setText("19xdeiQM2Hn2M2wbpT5imcYWzqhiSDHPy4");
|
||||
// arbitratorPubKeyAsHex.setText("02c62e794fe67f3a2115e2de4757143ff7f27bdf38aa4ae58a3595baa6d676875b");
|
||||
|
||||
// 4.2
|
||||
arbitratorAddressString.setText("1FdFzBazmHQxbUbdCUJwuCtR37DrZrEobu");
|
||||
arbitratorPubKeyAsHex.setText("030fdc2ebc297df4047442f6079f1ce3b7d1938a41f88bd11497545cc94fcfd315");
|
||||
// 4.2 (ntjhaj27rylxwvnp.onion)
|
||||
arbitratorAddressString.setText("1FdFzBazmHQxbUbdCUJwuCtR37DrZrEobu");
|
||||
arbitratorPubKeyAsHex.setText("030fdc2ebc297df4047442f6079f1ce3b7d1938a41f88bd11497545cc94fcfd315");
|
||||
|
||||
actionButtonText("Sign and publish transaction");
|
||||
|
||||
|
|
|
@ -20,7 +20,10 @@ package io.bisq.gui.util.validation;
|
|||
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.gui.util.validation.altcoins.ByteballAddressValidator;
|
||||
import io.bisq.gui.util.validation.altcoins.NxtReedSolomonValidator;
|
||||
import io.bisq.gui.util.validation.altcoins.OctocoinAddressValidator;
|
||||
import io.bisq.gui.util.validation.params.IOPParams;
|
||||
import io.bisq.gui.util.validation.params.OctocoinParams;
|
||||
import io.bisq.gui.util.validation.params.PivxParams;
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.AddressFormatException;
|
||||
|
@ -61,11 +64,11 @@ public final class AltCoinAddressValidator extends InputValidator {
|
|||
switch (currencyCode) {
|
||||
case "ETH":
|
||||
// https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403
|
||||
if (!input.matches("^(0x)?[0-9a-fA-F]{40}$"))
|
||||
if (!input.matches("^(0x)?[0-9a-fA-F]{40}$"))
|
||||
return regexTestFailed;
|
||||
else
|
||||
return new ValidationResult(true);
|
||||
// Example for BTC, though for BTC we use the BitcoinJ library address check
|
||||
return new ValidationResult(true);
|
||||
// Example for BTC, though for BTC we use the BitcoinJ library address check
|
||||
case "BTC":
|
||||
// taken form: https://stackoverflow.com/questions/21683680/regex-to-match-bitcoin-addresses
|
||||
if (input.matches("^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
|
||||
|
@ -114,6 +117,21 @@ public final class AltCoinAddressValidator extends InputValidator {
|
|||
} else {
|
||||
return regexTestFailed;
|
||||
}
|
||||
case "888":
|
||||
if (input.matches("^[83][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
|
||||
if (OctocoinAddressValidator.ValidateAddress(input)) {
|
||||
try {
|
||||
new Address(OctocoinParams.get(), input);
|
||||
return new ValidationResult(true);
|
||||
} catch (AddressFormatException e) {
|
||||
return new ValidationResult(false, getErrorMessage(e));
|
||||
}
|
||||
} else {
|
||||
return wrongChecksum;
|
||||
}
|
||||
} else {
|
||||
return regexTestFailed;
|
||||
}
|
||||
case "ZEC":
|
||||
// We only support t addresses (transparent transactions)
|
||||
if (input.startsWith("t"))
|
||||
|
@ -138,6 +156,16 @@ public final class AltCoinAddressValidator extends InputValidator {
|
|||
}*/
|
||||
case "GBYTE":
|
||||
return ByteballAddressValidator.validate(input);
|
||||
case "NXT":
|
||||
if (!input.startsWith("NXT-") || !input.equals(input.toUpperCase())) {
|
||||
return regexTestFailed;
|
||||
}
|
||||
try {
|
||||
long accountId = NxtReedSolomonValidator.decode(input.substring(4));
|
||||
return new ValidationResult(accountId != 0);
|
||||
} catch (NxtReedSolomonValidator.DecodeException e) {
|
||||
return wrongChecksum;
|
||||
}
|
||||
default:
|
||||
log.debug("Validation for AltCoinAddress not implemented yet. currencyCode: " + currencyCode);
|
||||
return validationResult;
|
||||
|
|
|
@ -0,0 +1,197 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
/*
|
||||
Reed Solomon Encoding and Decoding for Nxt
|
||||
|
||||
Version: 1.0, license: Public Domain, coder: NxtChg (admin@nxtchg.com)
|
||||
Java Version: ChuckOne (ChuckOne@mail.de).
|
||||
*/
|
||||
|
||||
package io.bisq.gui.util.validation.altcoins;
|
||||
|
||||
|
||||
public 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
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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 io.bisq.gui.util.validation.altcoins;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class OctocoinAddressValidator {
|
||||
private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* This file is part of bisq.
|
||||
*
|
||||
* bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.gui.util.validation.params;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.BlockStoreException;
|
||||
import org.bitcoinj.utils.MonetaryFormat;
|
||||
|
||||
public class OctocoinParams extends NetworkParameters {
|
||||
|
||||
private static OctocoinParams instance;
|
||||
|
||||
public static synchronized OctocoinParams get() {
|
||||
if (instance == null) {
|
||||
instance = new OctocoinParams();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
// We only use the properties needed for address validation
|
||||
public OctocoinParams() {
|
||||
super();
|
||||
addressHeader = 18;
|
||||
p2shHeader = 5;
|
||||
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
|
||||
}
|
||||
|
||||
// default dummy implementations, not used...
|
||||
@Override
|
||||
public String getPaymentProtocolId() {
|
||||
return PAYMENT_PROTOCOL_ID_MAINNET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coin getMaxMoney() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coin getMinNonDustOutput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MonetaryFormat getMonetaryFormat() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUriScheme() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMaxMoney() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BitcoinSerializer getSerializer(boolean parseRetain) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersionNum(ProtocolVersion version) {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -105,4 +105,34 @@ public class AltCoinAddressValidatorTest {
|
|||
assertFalse(validator.validate("2a65Aca4D5fC5B5C859090a6c34d16413539822g").isValid);
|
||||
assertFalse(validator.validate("").isValid);
|
||||
}
|
||||
@Test
|
||||
public void test888() {
|
||||
AltCoinAddressValidator validator = new AltCoinAddressValidator();
|
||||
validator.setCurrencyCode("888");
|
||||
|
||||
assertTrue(validator.validate("8TP9rh3SH6n9cSLmV22vnSNNw56LKGpLra").isValid);
|
||||
assertTrue(validator.validate("37NwrYsD1HxQW5zfLTuQcUUXGMPvQgzTSn").isValid);
|
||||
|
||||
assertFalse(validator.validate("1ANNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i").isValid);
|
||||
assertFalse(validator.validate("38NwrYsD1HxQW5zfLT0QcUUXGMPvQgzTSn").isValid);
|
||||
assertFalse(validator.validate("8tP9rh3SH6n9cSLmV22vnSNNw56LKGpLrB").isValid);
|
||||
assertFalse(validator.validate("8Zbvjr").isValid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNXT() {
|
||||
AltCoinAddressValidator validator = new AltCoinAddressValidator();
|
||||
validator.setCurrencyCode("NXT");
|
||||
|
||||
assertTrue(validator.validate("NXT-JM2U-U4AE-G7WF-3NP9F").isValid);
|
||||
assertTrue(validator.validate("NXT-6UNJ-UMFM-Z525-4S24M").isValid);
|
||||
assertTrue(validator.validate("NXT-2223-2222-KB8Y-22222").isValid);
|
||||
|
||||
assertFalse(validator.validate("").isValid);
|
||||
assertFalse(validator.validate("abcde").isValid);
|
||||
assertFalse(validator.validate("NXT-").isValid);
|
||||
assertFalse(validator.validate("NXT-JM2U-U4AE-G7WF-3ND9F").isValid);
|
||||
assertFalse(validator.validate("NXT-JM2U-U4AE-G7WF-3Np9F").isValid);
|
||||
assertFalse(validator.validate("NXT-2222-2222-2222-22222").isValid);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue