diff --git a/pom.xml b/pom.xml
index 92a8b14d..7a3b9aab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
org.altcoinj
altcoinj
- 0.13-SNAPSHOT
+ 0.14-SNAPSHOT
jar
diff --git a/src/main/java/org/altcoinj/core/AltcoinSerializer.java b/src/main/java/org/altcoinj/core/AltcoinSerializer.java
index 2cd57f28..8d9da792 100644
--- a/src/main/java/org/altcoinj/core/AltcoinSerializer.java
+++ b/src/main/java/org/altcoinj/core/AltcoinSerializer.java
@@ -17,8 +17,8 @@ import org.bitcoinj.core.ProtocolException;
*/
public class AltcoinSerializer extends BitcoinSerializer {
- public AltcoinSerializer(NetworkParameters params, boolean parseLazy, boolean parseRetain) {
- super(params, parseLazy, parseRetain);
+ public AltcoinSerializer(NetworkParameters params, boolean parseRetain) {
+ super(params, parseRetain);
}
@Override
diff --git a/src/main/java/org/altcoinj/params/AbstractDogecoinParams.java b/src/main/java/org/altcoinj/params/AbstractDogecoinParams.java
index 9797c376..6ece9da6 100644
--- a/src/main/java/org/altcoinj/params/AbstractDogecoinParams.java
+++ b/src/main/java/org/altcoinj/params/AbstractDogecoinParams.java
@@ -109,7 +109,7 @@ public abstract class AbstractDogecoinParams extends NetworkParameters implement
}
private static AltcoinBlock createGenesis(NetworkParameters params) {
- AltcoinBlock genesisBlock = new AltcoinBlock(params);
+ AltcoinBlock genesisBlock = new AltcoinBlock(params, Block.BLOCK_VERSION_GENESIS);
Transaction t = new Transaction(params);
try {
byte[] bytes = Utils.HEX.decode
@@ -305,8 +305,8 @@ public abstract class AbstractDogecoinParams extends NetworkParameters implement
}
@Override
- public AltcoinSerializer getSerializer(boolean parseLazy, boolean parseRetain) {
- return new AltcoinSerializer(this, parseLazy, parseRetain);
+ public AltcoinSerializer getSerializer(boolean parseRetain) {
+ return new AltcoinSerializer(this, parseRetain);
}
@Override
diff --git a/src/main/java/org/bitcoinj/core/AltcoinBlock.java b/src/main/java/org/bitcoinj/core/AltcoinBlock.java
index 757dc1a0..49389ebc 100644
--- a/src/main/java/org/bitcoinj/core/AltcoinBlock.java
+++ b/src/main/java/org/bitcoinj/core/AltcoinBlock.java
@@ -58,8 +58,8 @@ public class AltcoinBlock extends org.bitcoinj.core.Block {
private ScryptHash scryptHash;
/** Special case constructor, used for the genesis node, cloneAsHeader and unit tests. */
- public AltcoinBlock(NetworkParameters params) {
- super(params);
+ public AltcoinBlock(final NetworkParameters params, final long version) {
+ super(params, version);
}
/** Special case constructor, used for the genesis node, cloneAsHeader and unit tests. */
@@ -156,39 +156,15 @@ public class AltcoinBlock extends org.bitcoinj.core.Block {
}
@Override
- void parse() throws ProtocolException {
- parseHeader();
+ protected void parseTransactions(final int offset) {
parseAuxPoW();
- parseTransactions();
- length = cursor - offset;
- }
-
- @Override
- protected void parseTransactions() {
if (null != this.auxpow) {
- parseTransactions(HEADER_SIZE + auxpow.getMessageSize());
+ super.parseTransactions(offset + auxpow.getMessageSize());
} else {
- parseTransactions(HEADER_SIZE);
+ super.parseTransactions(offset);
}
}
- @Override
- protected void parseLite() throws ProtocolException {
- // Ignore the header since it has fixed length. If length is not provided we will have to
- // invoke a light parse of transactions to calculate the length.
- if (length == UNKNOWN_LENGTH) {
- Preconditions.checkState(serializer.isParseLazyMode(),
- "Performing lite parse of block transaction as block was initialised from byte array " +
- "without providing length. This should never need to happen.");
- parseAuxPoW();
- parseTransactions();
- length = cursor - offset;
- } else {
- transactionBytesValid = !transactionsParsed || serializer.isParseRetainMode() && length > HEADER_SIZE;
- }
- headerBytesValid = !headerParsed || serializer.isParseRetainMode() && length >= HEADER_SIZE;
- }
-
@Override
void writeHeader(OutputStream stream) throws IOException {
super.writeHeader(stream);
@@ -200,7 +176,7 @@ public class AltcoinBlock extends org.bitcoinj.core.Block {
/** Returns a copy of the block, but without any transactions. */
@Override
public Block cloneAsHeader() {
- AltcoinBlock block = new AltcoinBlock(params);
+ AltcoinBlock block = new AltcoinBlock(params, getVersion());
super.copyBitcoinHeaderTo(block);
block.auxpow = auxpow;
return block;
diff --git a/src/main/java/org/bitcoinj/core/AuxPoW.java b/src/main/java/org/bitcoinj/core/AuxPoW.java
index da930b49..581c7156 100644
--- a/src/main/java/org/bitcoinj/core/AuxPoW.java
+++ b/src/main/java/org/bitcoinj/core/AuxPoW.java
@@ -35,7 +35,7 @@ import java.util.*;
* NetworkParameters for AuxPoW networks must implement AltcoinNetworkParameters
* in order for AuxPoW to work.
*/
-public class AuxPoW extends ChildMessage implements Serializable {
+public class AuxPoW extends ChildMessage {
public static final byte[] MERGED_MINING_HEADER = new byte[] {
(byte) 0xfa, (byte) 0xbe, "m".getBytes()[0], "m".getBytes()[0]
@@ -93,12 +93,6 @@ public class AuxPoW extends ChildMessage implements Serializable {
super(params, payload, 0, parent, serializer, Message.UNKNOWN_LENGTH);
}
- @Override
- protected void parseLite() throws ProtocolException {
- length = calcLength(payload, offset);
- cursor = offset + length;
- }
-
protected static int calcLength(byte[] buf, int offset) {
VarInt varint;
// jump past transaction
@@ -120,11 +114,7 @@ public class AuxPoW extends ChildMessage implements Serializable {
}
@Override
- void parse() throws ProtocolException {
-
- if (parsed)
- return;
-
+ protected void parse() throws ProtocolException {
cursor = offset;
transaction = new Transaction(params, payload, cursor, this, serializer, Message.UNKNOWN_LENGTH);
cursor += transaction.getOptimalEncodingMessageSize();
@@ -153,7 +143,6 @@ public class AuxPoW extends ChildMessage implements Serializable {
public int getOptimalEncodingMessageSize() {
if (optimalEncodingMessageSize != 0)
return optimalEncodingMessageSize;
- maybeParse();
if (optimalEncodingMessageSize != 0)
return optimalEncodingMessageSize;
optimalEncodingMessageSize = getMessageSize();
@@ -208,16 +197,6 @@ public class AuxPoW extends ChildMessage implements Serializable {
return result;
}
- /**
- * Ensure object is fully parsed before invoking java serialization. The backing byte array
- * is transient so if the object has parseLazy = true and hasn't invoked checkParse yet
- * then data will be lost during serialization.
- */
- private void writeObject(ObjectOutputStream out) throws IOException {
- maybeParse();
- out.defaultWriteObject();
- }
-
/**
* Get the block header from the parent blockchain. The hash of the header
* is the value which should match the difficulty target. Note that blocks are
@@ -251,27 +230,6 @@ public class AuxPoW extends ChildMessage implements Serializable {
return coinbaseBranch;
}
- /**
- * Checks the transaction contents for sanity, in ways that can be done in a standalone manner.
- * Does not perform all checks on a transaction such as whether the inputs are already spent.
- * Specifically this method verifies:
- *
- *
- * - That there is at least one input and output.
- * - That the serialized size is not larger than the max block size.
- * - That no outputs have negative value.
- * - That the outputs do not sum to larger than the max allowed quantity of coin in the system.
- * - If the tx is a coinbase tx, the coinbase scriptSig size is within range. Otherwise that there are no
- * coinbase inputs in the tx.
- *
- *
- * @throws VerificationException
- */
- public void verify() throws VerificationException {
- maybeParse();
- // TODO: Verify the AuxPoW data
- }
-
/**
* Check the proof of work for this AuxPoW header meets the target
* difficulty.
diff --git a/src/main/java/org/bitcoinj/core/MerkleBranch.java b/src/main/java/org/bitcoinj/core/MerkleBranch.java
index 9c7f9e9b..2f35c234 100644
--- a/src/main/java/org/bitcoinj/core/MerkleBranch.java
+++ b/src/main/java/org/bitcoinj/core/MerkleBranch.java
@@ -19,14 +19,11 @@ package org.bitcoinj.core;
import javax.annotation.Nullable;
import java.io.IOException;
-import java.io.ObjectOutputStream;
import java.io.OutputStream;
-import java.io.Serializable;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import static org.bitcoinj.core.Sha256Hash.newDigest;
/**
* A Merkle branch contains the hashes from a leaf of a Merkle tree
@@ -37,7 +34,7 @@ import static org.bitcoinj.core.Sha256Hash.newDigest;
* TODO: Has a lot of similarity to PartialMerkleTree, should attempt to merge
* the two.
*/
-public class MerkleBranch extends ChildMessage implements Serializable {
+public class MerkleBranch extends ChildMessage {
private static final long serialVersionUID = 2;
// Merkle branches can be encoded in a way that will use more bytes than is optimal
@@ -89,12 +86,6 @@ public class MerkleBranch extends ChildMessage implements Serializable {
this.index = branchSideMask;
}
- @Override
- protected void parseLite() throws ProtocolException {
- length = calcLength(payload, offset);
- cursor = offset + length;
- }
-
public static int calcLength(byte[] buf, int offset) {
VarInt varint = new VarInt(buf, offset);
@@ -102,10 +93,7 @@ public class MerkleBranch extends ChildMessage implements Serializable {
}
@Override
- void parse() throws ProtocolException {
- if (parsed)
- return;
-
+ protected void parse() throws ProtocolException {
cursor = offset;
final int hashCount = (int) readVarInt();
@@ -117,6 +105,7 @@ public class MerkleBranch extends ChildMessage implements Serializable {
optimalEncodingMessageSize += 32 * hashCount;
setIndex(readUint32());
optimalEncodingMessageSize += 4;
+ length = cursor - offset;
}
@Override
@@ -196,7 +185,6 @@ public class MerkleBranch extends ChildMessage implements Serializable {
public int getOptimalEncodingMessageSize() {
if (optimalEncodingMessageSize != 0)
return optimalEncodingMessageSize;
- maybeParse();
if (optimalEncodingMessageSize != 0)
return optimalEncodingMessageSize;
optimalEncodingMessageSize = getMessageSize();
@@ -211,26 +199,6 @@ public class MerkleBranch extends ChildMessage implements Serializable {
return "Merkle branch";
}
- /**
- * Ensure object is fully parsed before invoking java serialization. The backing byte array
- * is transient so if the object has parseLazy = true and hasn't invoked checkParse yet
- * then data will be lost during serialization.
- */
- private void writeObject(ObjectOutputStream out) throws IOException {
- maybeParse();
- out.defaultWriteObject();
- }
-
- /**
- * Should check that the merkle branch side bits are not wider than the
- * provided hashes.
- * @throws VerificationException If the branch is invalid.
- */
- public void verify() throws VerificationException {
- maybeParse();
- // TODO: Check the flags make sense for the inputs
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;