Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bip91 problem with LTC version: avoid chopping off bits from the version #26

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions core/src/main/java/org/bitcoinj/core/AltcoinBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
package org.bitcoinj.core;

import org.libdohj.core.AltcoinNetworkParameters;
import com.google.common.base.Preconditions;
import org.libdohj.core.AuxPoWNetworkParameters;
import org.libdohj.core.ScryptHash;
import org.libdohj.params.AbstractLitecoinParams;

import javax.annotation.Nullable;
import java.io.ByteArrayOutputStream;
Expand All @@ -28,13 +30,9 @@
import java.security.GeneralSecurityException;
import java.util.BitSet;
import java.util.List;
import static org.bitcoinj.core.Coin.FIFTY_COINS;

import org.libdohj.core.ScryptHash;
import static org.libdohj.core.Utils.scryptDigest;

import static org.bitcoinj.core.Utils.reverseBytes;
import org.libdohj.core.AuxPoWNetworkParameters;
import static org.libdohj.core.Utils.scryptDigest;

/**
* <p>A block is a group of transactions, and is one of the fundamental data structures of the Bitcoin system.
Expand Down Expand Up @@ -172,8 +170,8 @@ public long getChainID() {

/**
* Return flags from block version of an AuxPoW-enabled chain.
*
* @return flags as a bitset.
*
* @return flags as a bitset.
*/
public BitSet getVersionFlags() {
final BitSet bitset = new BitSet(BYTE_BITS);
Expand Down Expand Up @@ -207,7 +205,9 @@ public static long getBaseVersion(final long rawVersion) {
@Override
public long getVersion() {
// TODO: Can we cache the individual parts on parse?
if (this.params instanceof AltcoinNetworkParameters) {
if(this.params instanceof AbstractLitecoinParams) {
return super.getVersion();
}else if (this.params instanceof AltcoinNetworkParameters) {
// AuxPoW networks use the higher block version bits for flags and
// chain ID.
return getBaseVersion(super.getVersion());
Expand Down