UTF-8
- true
-
- d7cf6ac
- 0.16.3
- 1.73
+ true
+
+ 7dc8c6f
+ 0.15.10
+ 1.70
${maven.build.timestamp}
- 1b731d1
+ 1.4.2
3.8.0
-
1.12.0
2.18.0
1.27.1
@@ -24,7 +23,6 @@
0.12.3
4.9.10
1.68.1
-
33.3.1-jre
2.2
1.2.1
@@ -35,7 +33,6 @@
2.3.9
2.42
9.4.56.v20240826
-
1.1.1
20240303
1.18.1
@@ -54,14 +51,10 @@
3.6.0
3.1.3
3.5.2
-
3.25.3
-
1.5.3
1.17
1.7.36
-
-
2.0.10
5.18.2
1.2
@@ -297,23 +290,19 @@
org.apache.maven.plugins
maven-jar-plugin
${maven-jar-plugin.version}
-
-
-
-
-
- false
- true
-
-
- ${git.commit.id.full}
- ${git.commit.time}
- true
-
-
-
-
-
+
+
+
+ false
+ true
+
+
+ ${git.commit.id.full}
+ ${git.commit.time}
+ true
+
+
+
@@ -388,7 +377,6 @@
-
io.github.zlika
reproducible-build-maven-plugin
@@ -411,7 +399,7 @@
maven-surefire-plugin
${maven-surefire-plugin.version}
- ${skipJUnitTests}
+ ${skipTests}
@@ -495,7 +483,7 @@
- com.github.iceburst
+ org.ciyam
AT
${ciyam-at.version}
@@ -513,7 +501,7 @@
- com.github.iceburst
+ com.github.qortal
altcoinj
${altcoinj.version}
diff --git a/src/main/java/org/qortal/account/PublicKeyAccount.java b/src/main/java/org/qortal/account/PublicKeyAccount.java
index d845e632..494fe326 100644
--- a/src/main/java/org/qortal/account/PublicKeyAccount.java
+++ b/src/main/java/org/qortal/account/PublicKeyAccount.java
@@ -1,41 +1,17 @@
package org.qortal.account;
-import org.bouncycastle.crypto.generators.Ed25519KeyPairGenerator;
-import org.bouncycastle.crypto.params.Ed25519KeyGenerationParameters;
import org.bouncycastle.crypto.params.Ed25519PublicKeyParameters;
import org.qortal.crypto.Crypto;
import org.qortal.data.account.AccountData;
import org.qortal.repository.Repository;
-import java.security.SecureRandom;
-
public class PublicKeyAccount extends Account {
protected final byte[] publicKey;
protected final Ed25519PublicKeyParameters edPublicKeyParams;
- /** Constructor for generating a PublicKeyAccount
- *
- * @param repository Block Chain
- * @param publicKey 32 byte Public Key
- * @since v4.7.3
- */
public PublicKeyAccount(Repository repository, byte[] publicKey) {
- super(repository, Crypto.toAddress(publicKey));
-
- Ed25519PublicKeyParameters t = null;
- try {
- t = new Ed25519PublicKeyParameters(publicKey, 0);
- } catch (Exception e) {
- var gen = new Ed25519KeyPairGenerator();
- gen.init(new Ed25519KeyGenerationParameters(new SecureRandom()));
- var keyPair = gen.generateKeyPair();
- t = (Ed25519PublicKeyParameters) keyPair.getPublic();
- } finally {
- this.edPublicKeyParams = t;
- }
-
- this.publicKey = publicKey;
+ this(repository, new Ed25519PublicKeyParameters(publicKey, 0));
}
protected PublicKeyAccount(Repository repository, Ed25519PublicKeyParameters edPublicKeyParams) {
diff --git a/src/main/java/org/qortal/crosschain/Bitcoiny.java b/src/main/java/org/qortal/crosschain/Bitcoiny.java
index 86724c0c..5cd6df35 100644
--- a/src/main/java/org/qortal/crosschain/Bitcoiny.java
+++ b/src/main/java/org/qortal/crosschain/Bitcoiny.java
@@ -8,8 +8,6 @@ import org.bitcoinj.core.*;
import org.bitcoinj.crypto.ChildNumber;
import org.bitcoinj.crypto.DeterministicHierarchy;
import org.bitcoinj.crypto.DeterministicKey;
-import org.bitcoinj.crypto.HDPath;
-import org.bitcoinj.params.AbstractBitcoinNetParams;
import org.bitcoinj.script.Script.ScriptType;
import org.bitcoinj.script.ScriptBuilder;
import org.bitcoinj.wallet.DeterministicKeyChain;
@@ -27,7 +25,7 @@ import java.util.*;
import java.util.stream.Collectors;
/** Bitcoin-like (Bitcoin, Litecoin, etc.) support */
-public abstract class Bitcoiny extends AbstractBitcoinNetParams implements ForeignBlockchain {
+public abstract class Bitcoiny implements ForeignBlockchain {
protected static final Logger LOGGER = LogManager.getLogger(Bitcoiny.class);
@@ -67,7 +65,6 @@ public abstract class Bitcoiny extends AbstractBitcoinNetParams implements Forei
// Constructors and instance
protected Bitcoiny(BitcoinyBlockchainProvider blockchainProvider, Context bitcoinjContext, String currencyCode, Coin feePerKb) {
- this.genesisBlock = this.getGenesisBlock();
this.blockchainProvider = blockchainProvider;
this.bitcoinjContext = bitcoinjContext;
this.currencyCode = currencyCode;
@@ -77,15 +74,6 @@ public abstract class Bitcoiny extends AbstractBitcoinNetParams implements Forei
}
// Getters & setters
- @Override
- public String getPaymentProtocolId() {
- return this.id;
- }
-
- @Override
- public Block getGenesisBlock() {
- return this.genesisBlock;
- }
public BitcoinyBlockchainProvider getBlockchainProvider() {
return this.blockchainProvider;
@@ -602,27 +590,15 @@ public abstract class Bitcoiny extends AbstractBitcoinNetParams implements Forei
return new AddressInfo(
address.toString(),
- toIntegerList( key.getPath() ),
+ toIntegerList( key.getPath()),
summingUnspentOutputs(address.toString()),
key.getPathAsString(),
transactionCount,
candidates.contains(address.toString()));
}
- /**
- * Convert BitcoinJ native type to List of Integers, BitcoinJ v16 compatible
- *
- *
- * @param path path to deterministic key
- * @return Array of Ints representing the keys position in the tree
- * @since v4.7.2
- */
- private static List toIntegerList(HDPath path) {
- return path.stream().map(ChildNumber::num).collect(Collectors.toList());
- }
-
- // BitcoinJ v15 compatible
private static List toIntegerList(ImmutableList path) {
+
return path.stream().map(ChildNumber::num).collect(Collectors.toList());
}
diff --git a/src/main/java/org/qortal/crosschain/BitcoinyTBD.java b/src/main/java/org/qortal/crosschain/BitcoinyTBD.java
index e1c191df..4b2f8173 100644
--- a/src/main/java/org/qortal/crosschain/BitcoinyTBD.java
+++ b/src/main/java/org/qortal/crosschain/BitcoinyTBD.java
@@ -1,6 +1,5 @@
package org.qortal.crosschain;
-import org.bitcoinj.core.Block;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.Context;
import org.bitcoinj.core.NetworkParameters;
@@ -149,16 +148,4 @@ public class BitcoinyTBD extends Bitcoiny {
this.netTBD.setFeeRequired( fee );
}
-
- @Override
- public String getPaymentProtocolId() {
- return params.getId();
- }
-
- @Override
- public Block getGenesisBlock() {
- if(genesisBlock == null)
- genesisBlock = params.getGenesisBlock();
- return this.genesisBlock;
- }
}
\ No newline at end of file
diff --git a/src/main/java/org/qortal/crosschain/DeterminedNetworkParams.java b/src/main/java/org/qortal/crosschain/DeterminedNetworkParams.java
index 90e7eb12..af7d19ac 100644
--- a/src/main/java/org/qortal/crosschain/DeterminedNetworkParams.java
+++ b/src/main/java/org/qortal/crosschain/DeterminedNetworkParams.java
@@ -98,10 +98,9 @@ public class DeterminedNetworkParams extends NetworkParameters implements Altcoi
LOGGER.info( "Creating Genesis Block ...");
- // BitcoinJ v16 has a new native method for this
//this.genesisBlock = CoinParamsUtil.createGenesisBlockFromRequest(this, request);
-// LOGGER.info("Created Genesis Block: genesisBlock = " + genesisBlock );
+ LOGGER.info("Created Genesis Block: genesisBlock = " + genesisBlock );
// this is 100 for each coin from what I can tell
this.spendableCoinbaseDepth = 100;
@@ -114,9 +113,8 @@ public class DeterminedNetworkParams extends NetworkParameters implements Altcoi
//
// LOGGER.info("request = " + request);
//
-// checkState(genesisHash.equals(request.getExpectedGenesisHash()))
-// alertSigningKey is removed in v16
-// this.alertSigningKey = Hex.decode(request.getPubKey());
+// checkState(genesisHash.equals(request.getExpectedGenesisHash()));
+ this.alertSigningKey = Hex.decode(request.getPubKey());
this.majorityEnforceBlockUpgrade = request.getMajorityEnforceBlockUpgrade();
this.majorityRejectBlockOutdated = request.getMajorityRejectBlockOutdated();
@@ -223,12 +221,6 @@ public class DeterminedNetworkParams extends NetworkParameters implements Altcoi
}
}
- @Override
- public Block getGenesisBlock() {
- //ToDo: Finish
- return null;
- }
-
/**
* Get the difficulty target expected for the next block. This includes all
* the weird cases for Litecoin such as testnet blocks which can be maximum
diff --git a/src/main/java/org/qortal/crosschain/LegacyZcashAddress.java b/src/main/java/org/qortal/crosschain/LegacyZcashAddress.java
index 15f9b411..14958242 100644
--- a/src/main/java/org/qortal/crosschain/LegacyZcashAddress.java
+++ b/src/main/java/org/qortal/crosschain/LegacyZcashAddress.java
@@ -184,11 +184,6 @@ public class LegacyZcashAddress extends Address {
return p2sh ? ScriptType.P2SH : ScriptType.P2PKH;
}
- @Override
- public int compareTo(Address address) {
- return this.toString().compareTo(address.toString());
- }
-
/**
* Given an address, examines the version byte and attempts to find a matching NetworkParameters. If you aren't sure
* which network the address is intended for (eg, it was provided by a user), you can use this to decide if it is
diff --git a/src/test/java/org/qortal/test/BootstrapTests.java b/src/test/java/org/qortal/test/BootstrapTests.java
index cf6fe043..58e1cfa2 100644
--- a/src/test/java/org/qortal/test/BootstrapTests.java
+++ b/src/test/java/org/qortal/test/BootstrapTests.java
@@ -212,9 +212,7 @@ public class BootstrapTests extends Common {
@Test
public void testBootstrapHosts() throws IOException {
String[] bootstrapHosts = Settings.getInstance().getBootstrapHosts();
- String[] bootstrapTypes = { "archive" }; // , "toponly", "full"
- boolean invalidFile = false;
- boolean invalidDate = false;
+ String[] bootstrapTypes = { "archive" }; // , "toponly"
for (String host : bootstrapHosts) {
for (String type : bootstrapTypes) {
@@ -232,20 +230,14 @@ public class BootstrapTests extends Common {
// Ensure the bootstrap exists and has a size greated than 100MiB
System.out.println(String.format("%s %s size is %d bytes", host, type, fileSize));
- if(fileSize < 100*1024*1024L)
- invalidFile = true;
- //assertTrue("Bootstrap size must be at least 100MiB", fileSize > 100*1024*1024L);
+ assertTrue("Bootstrap size must be at least 100MiB", fileSize > 100*1024*1024L);
// Ensure the bootstrap has been published recently (in the last 3 days)
long minimumLastMofifiedTimestamp = NTP.getTime() - (3 * 24 * 60 * 60 * 1000L);
System.out.println(String.format("%s %s last modified timestamp is %d", host, type, lastModified));
- if(lastModified < minimumLastMofifiedTimestamp)
- invalidDate = true;
- //assertTrue("Bootstrap last modified date must be in the last 3 days", lastModified > minimumLastMofifiedTimestamp);
+ assertTrue("Bootstrap last modified date must be in the last 3 days", lastModified > minimumLastMofifiedTimestamp);
}
}
- assertFalse("File size must be at least 100MiB", invalidFile);
- assertFalse("Bootstrap last modified date must be in the last 3 days",invalidDate);
}
private void deleteBootstraps() throws IOException {
diff --git a/src/test/java/org/qortal/test/CryptoTests.java b/src/test/java/org/qortal/test/CryptoTests.java
index 13395d62..75422ee7 100644
--- a/src/test/java/org/qortal/test/CryptoTests.java
+++ b/src/test/java/org/qortal/test/CryptoTests.java
@@ -304,7 +304,7 @@ public class CryptoTests extends Common {
@Test
public void testAESFileEncryption() throws NoSuchAlgorithmException, IOException, IllegalBlockSizeException,
- InvalidKeyException, BadPaddingException, InvalidAlgorithmParameterException, NoSuchPaddingException, InterruptedException {
+ InvalidKeyException, BadPaddingException, InvalidAlgorithmParameterException, NoSuchPaddingException {
// Create temporary directory and file paths
java.nio.file.Path tempDir = Files.createTempDirectory("qortal-tests");
@@ -320,7 +320,6 @@ public class CryptoTests extends Common {
// Write it to the input file
FileOutputStream outputStream = new FileOutputStream(inputFilePath);
outputStream.write(randomBytes);
- outputStream.close();
// Make sure only the input file exists
assertTrue(Files.exists(Paths.get(inputFilePath)));
diff --git a/src/test/java/org/qortal/test/GuiTests.java b/src/test/java/org/qortal/test/GuiTests.java
index c391ef92..016518f3 100644
--- a/src/test/java/org/qortal/test/GuiTests.java
+++ b/src/test/java/org/qortal/test/GuiTests.java
@@ -1,22 +1,15 @@
package org.qortal.test;
-import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.qortal.gui.SplashFrame;
import org.qortal.gui.SysTray;
-import org.qortal.repository.DataException;
-import org.qortal.test.common.Common;
import java.awt.TrayIcon.MessageType;
+@Ignore
public class GuiTests {
- @Before
- public void beforeTest() throws DataException {
- Common.useDefaultSettings();
- }
-
@Test
public void testSplashFrame() throws InterruptedException {
SplashFrame splashFrame = SplashFrame.getInstance();
diff --git a/src/test/java/org/qortal/test/MemoryPoWTests.java b/src/test/java/org/qortal/test/MemoryPoWTests.java
index 11a0a2b2..f642c781 100644
--- a/src/test/java/org/qortal/test/MemoryPoWTests.java
+++ b/src/test/java/org/qortal/test/MemoryPoWTests.java
@@ -10,7 +10,7 @@ import java.util.Random;
import static org.junit.Assert.*;
-@Ignore (value="Tests Work Fine - VERY Long Run time (1hr+)")
+@Ignore
public class MemoryPoWTests {
private static final int workBufferLength = 8 * 1024 * 1024;
@@ -26,16 +26,16 @@ public class MemoryPoWTests {
long startTime = System.currentTimeMillis();
- Integer nonce = MemoryPoW.compute2(data, workBufferLength, difficulty);
+ int nonce = MemoryPoW.compute2(data, workBufferLength, difficulty);
long finishTime = System.currentTimeMillis();
assertNotNull(nonce);
- System.out.printf("Memory-hard PoW (buffer size: %dKB, leading zeros: %d) took %dms, nonce: %d%n", workBufferLength / 1024,
+ System.out.println(String.format("Memory-hard PoW (buffer size: %dKB, leading zeros: %d) took %dms, nonce: %d", workBufferLength / 1024,
difficulty,
finishTime - startTime,
- nonce);
+ nonce));
assertTrue(MemoryPoW.verify2(data, workBufferLength, difficulty, nonce));
}
@@ -73,12 +73,12 @@ public class MemoryPoWTests {
double stddev = (double) Math.sqrt( (sampleSize * timesS2 - timesS1 * timesS1) / stddevDivisor );
- System.out.printf("Difficulty: %d, %d timings, mean: %d ms, stddev: %.2f ms, max nonce: %d%n",
+ System.out.println(String.format("Difficulty: %d, %d timings, mean: %d ms, stddev: %.2f ms, max nonce: %d",
difficulty,
sampleSize,
timesS1 / sampleSize,
stddev,
- maxNonce);
+ maxNonce));
}
}
@@ -97,7 +97,7 @@ public class MemoryPoWTests {
expectedNonce = 11032;
nonce = MemoryPoW.compute2(data, workBufferLength, difficulty);
- System.out.printf("Difficulty %d, nonce: %d%n", difficulty, nonce);
+ System.out.println(String.format("Difficulty %d, nonce: %d", difficulty, nonce));
assertEquals(expectedNonce, nonce);
}
diff --git a/src/test/java/org/qortal/test/PenaltyFixTests.java b/src/test/java/org/qortal/test/PenaltyFixTests.java
new file mode 100644
index 00000000..6d06f5f1
--- /dev/null
+++ b/src/test/java/org/qortal/test/PenaltyFixTests.java
@@ -0,0 +1,82 @@
+package org.qortal.test;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.qortal.account.Account;
+import org.qortal.account.PrivateKeyAccount;
+import org.qortal.block.Block;
+import org.qortal.controller.BlockMinter;
+import org.qortal.data.transaction.PaymentTransactionData;
+import org.qortal.data.transaction.TransactionData;
+import org.qortal.repository.DataException;
+import org.qortal.repository.Repository;
+import org.qortal.repository.RepositoryManager;
+import org.qortal.settings.Settings;
+import org.qortal.test.common.BlockUtils;
+import org.qortal.test.common.Common;
+import org.qortal.test.common.TransactionUtils;
+import org.qortal.test.common.transaction.TestTransaction;
+import org.qortal.utils.NTP;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+public class PenaltyFixTests extends Common {
+
+ @Before
+ public void beforeTest() throws DataException {
+ Common.useSettings("test-settings-v2-penalty-fix.json");
+ NTP.setFixedOffset(Settings.getInstance().getTestNtpOffset());
+ }
+
+ @Test
+ public void testSingleSponsor() throws DataException {
+ try (final Repository repository = RepositoryManager.getRepository()) {
+
+ // Alice self share online, and will be used to mint the blocks
+ PrivateKeyAccount aliceSelfShare = Common.getTestAccount(repository, "alice-reward-share");
+ List onlineAccounts = new ArrayList<>();
+ onlineAccounts.add(aliceSelfShare);
+
+ PrivateKeyAccount bobAccount = Common.getTestAccount(repository, "bob");
+
+ // Test account from real penalty data (pen-revert.json)
+ Account penaltyAccount = new Account(repository, "QLcAQpko5egwNjifueCAeAsT8CAj2Sr5qJ");
+
+ // Bob sends a payment to the penalty account, so that it gets a row in the Accounts table
+ TransactionData paymentData = new PaymentTransactionData(TestTransaction.generateBase(bobAccount), penaltyAccount.getAddress(), 1);
+ TransactionUtils.signAndImportValid(repository, paymentData, bobAccount); // updates paymentData's signature
+
+ // Mint blocks up to height 4
+ Block block = null;
+ for (int i = 2; i <= 4; i++)
+ block = BlockMinter.mintTestingBlock(repository, onlineAccounts.toArray(new PrivateKeyAccount[0]));
+
+ assertEquals(4, (int)block.getBlockData().getHeight());
+
+ // Check blocks minted penalty of penalty account
+ assertEquals(0, (int) penaltyAccount.getBlocksMintedPenalty());
+
+ // Penalty revert code runs at block 5
+ block = BlockMinter.mintTestingBlock(repository, onlineAccounts.toArray(new PrivateKeyAccount[0]));
+ assertEquals(5, (int)block.getBlockData().getHeight());
+
+ // +5000000 blocks minted penalty should be applied
+ assertEquals(5000000, (int) penaltyAccount.getBlocksMintedPenalty());
+
+ // Orphan the last block, to simulate a re-org
+ BlockUtils.orphanLastBlock(repository);
+
+ assertEquals(0, (int) penaltyAccount.getBlocksMintedPenalty());
+
+ // Penalty revert code runs again
+ block = BlockMinter.mintTestingBlock(repository, onlineAccounts.toArray(new PrivateKeyAccount[0]));
+ assertEquals(5, (int)block.getBlockData().getHeight());
+
+ // Penalty should still be 5000000, rather than doubled up to 10000000
+ assertEquals(5000000, (int) penaltyAccount.getBlocksMintedPenalty());
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/qortal/test/crosschain/BitcoinyTestsUtils.java b/src/test/java/org/qortal/test/crosschain/BitcoinyTestsUtils.java
index 1660ba9f..a11b5b2f 100644
--- a/src/test/java/org/qortal/test/crosschain/BitcoinyTestsUtils.java
+++ b/src/test/java/org/qortal/test/crosschain/BitcoinyTestsUtils.java
@@ -1,8 +1,9 @@
package org.qortal.test.crosschain;
+import com.google.common.collect.ImmutableList;
import org.bitcoinj.core.NetworkParameters;
+import org.bitcoinj.crypto.ChildNumber;
import org.bitcoinj.crypto.DeterministicKey;
-import org.bitcoinj.crypto.HDPath;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.DeterministicKeyChain;
import org.bitcoinj.wallet.DeterministicSeed;
@@ -32,7 +33,7 @@ public class BitcoinyTestsUtils {
final Wallet wallet = Wallet.createDeterministic(networkParameters, Script.ScriptType.P2PKH);
final DeterministicSeed seed = wallet.getKeyChainSeed();
final DeterministicKeyChain keyChain = DeterministicKeyChain.builder().seed(seed).build();
- final HDPath path = keyChain.getAccountPath();
+ final ImmutableList path = keyChain.getAccountPath();
final DeterministicKey parent = keyChain.getKeyByPath(path, true);
final String rootKey = parent.serializePrivB58(networkParameters);