Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
justinvforvendetta committed Aug 19, 2024
1 parent 8fd4276 commit f844fea
Show file tree
Hide file tree
Showing 109 changed files with 21,173 additions and 20,078 deletions.
4 changes: 2 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ configurations {
unitTestRuntime.extendsFrom unitTestCompile
}

compileJava {
compileJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}

dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])

api 'com.google.guava:guava:18.0' //TODO ToStringHelper update for updating to 19.0+
api 'com.google.guava:guava:19.0' //TODO ToStringHelper update for updating to 19.0+
api 'com.google.code.findbugs:jsr305:3.0.2'
api 'com.madgag.spongycastle:core:1.58.0.0'
api 'com.lambdaworks:scrypt:1.4.0'
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/com/vergepay/core/CoreUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.vergepay.core;

import com.vergepay.core.wallet.AbstractAddress;
import com.google.common.base.Joiner;

import org.bitcoinj.crypto.MnemonicCode;
Expand Down
149 changes: 75 additions & 74 deletions core/src/main/java/com/vergepay/core/Preconditions.java

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions core/src/main/java/com/vergepay/core/coins/BitcoinMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
* @author John L. Jegutanis
*/
public class BitcoinMain extends BitFamily {
private static final BitcoinMain instance = new BitcoinMain();

private BitcoinMain() {
id = "bitcoin.main";

addressHeader = 0;
p2shHeader = 5;
acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
spendableCoinbaseDepth = 100;
dumpedPrivateKeyHeader = 128;

Expand All @@ -27,7 +29,6 @@ private BitcoinMain() {
signedMessageHeader = toBytes("Bitcoin Signed Message:\n");
}

private static final BitcoinMain instance = new BitcoinMain();
public static synchronized CoinType get() {
return instance;
}
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/com/vergepay/core/coins/BitcoinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
* @author John L. Jegutanis
*/
public class BitcoinTest extends BitFamily {
private static final BitcoinTest instance = new BitcoinTest();

private BitcoinTest() {
id = "bitcoin.test";

addressHeader = 111;
p2shHeader = 196;
acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
spendableCoinbaseDepth = 100;
dumpedPrivateKeyHeader = 239;

Expand All @@ -27,7 +29,6 @@ private BitcoinTest() {
signedMessageHeader = toBytes("Bitcoin Signed Message:\n");
}

private static final BitcoinTest instance = new BitcoinTest();
public static synchronized CoinType get() {
return instance;
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/com/vergepay/core/coins/BurstMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
public class BurstMain extends NxtFamily {

private static final BurstMain instance = new BurstMain();

private BurstMain() {
id = "burst.main";

Expand All @@ -21,7 +23,6 @@ private BurstMain() {
feePolicy = FeePolicy.FLAT_FEE;
}

private static final BurstMain instance = new BurstMain();
public static synchronized CoinType get() {
return instance;
}
Expand Down
20 changes: 10 additions & 10 deletions core/src/main/java/com/vergepay/core/coins/CoinID.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.vergepay.core.coins;

import com.google.common.collect.ImmutableList;
import com.vergepay.core.exceptions.AddressMalformedException;
import com.vergepay.core.util.GenericUtils;
import com.google.common.collect.ImmutableList;

import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.params.Networks;
Expand Down Expand Up @@ -79,15 +79,6 @@ public enum CoinID {
this.type = type;
}

@Override
public String toString() {
return type.getId();
}

public CoinType getCoinType() {
return type;
}

public static List<CoinType> getSupportedCoins() {
return types;
}
Expand Down Expand Up @@ -134,4 +125,13 @@ public static CoinType typeFromSymbol(String symbol) {
throw new IllegalArgumentException("Unsupported coin symbol: " + symbol);
}
}

@Override
public String toString() {
return type.getId();
}

public CoinType getCoinType() {
return type;
}
}
28 changes: 12 additions & 16 deletions core/src/main/java/com/vergepay/core/coins/CoinType.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.vergepay.core.coins;


import com.vergepay.core.coins.families.Families;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.Charsets;
import com.vergepay.core.exceptions.AddressMalformedException;
import com.vergepay.core.messages.MessageFactory;
import com.vergepay.core.util.MonetaryFormat;
import com.vergepay.core.wallet.AbstractAddress;
import com.google.common.base.Charsets;

import org.bitcoinj.core.Coin;
import org.bitcoinj.core.NetworkParameters;
Expand All @@ -19,16 +20,14 @@

import javax.annotation.Nullable;

import static com.google.common.base.Preconditions.checkNotNull;

/**
* @author John L. Jegutanis
*/
abstract public class CoinType extends NetworkParameters implements ValueType, Serializable {
private static final long serialVersionUID = 1L;

private static final String BIP_44_KEY_PATH = "44H/%dH/%dH";

private static FeeProvider feeProvider = null;
protected String name;
protected String symbol;
protected String uriScheme;
Expand All @@ -41,12 +40,17 @@ abstract public class CoinType extends NetworkParameters implements ValueType, S
protected SoftDustPolicy softDustPolicy;
protected FeePolicy feePolicy = FeePolicy.FEE_PER_KB;
protected byte[] signedMessageHeader;

private transient MonetaryFormat friendlyFormat;
private transient MonetaryFormat plainFormat;
private transient Value oneCoin;

private static FeeProvider feeProvider = null;
protected static byte[] toBytes(String str) {
return str.getBytes(Charsets.UTF_8);
}

public static void setFeeProvider(FeeProvider feeProvider) {
CoinType.feeProvider = feeProvider;
}

@Override
public String getName() {
Expand Down Expand Up @@ -121,17 +125,13 @@ public MessageFactory getMessagesFactory() {
return null;
}

protected static byte[] toBytes(String str) {
return str.getBytes(Charsets.UTF_8);
}

public List<ChildNumber> getBip44Path(int account) {
String path = String.format(BIP_44_KEY_PATH, bip44Index, account);
return HDUtils.parsePath(path);
}

/**
Return an address prefix like NXT- or BURST-, otherwise and empty string
* Return an address prefix like NXT- or BURST-, otherwise and empty string
*/
public String getAddressPrefix() {
return checkNotNull(addressPrefix, "A coin failed to set the address prefix");
Expand Down Expand Up @@ -223,10 +223,6 @@ public boolean equals(ValueType obj) {
return super.equals(obj);
}

public static void setFeeProvider(FeeProvider feeProvider) {
CoinType.feeProvider = feeProvider;
}

public interface FeeProvider {
Value getFeeValue(CoinType type);
}
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/com/vergepay/core/coins/FiatType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.vergepay.core.coins;

import com.vergepay.core.coins.families.Families;
import com.vergepay.core.util.Currencies;
import com.vergepay.core.util.MonetaryFormat;

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/com/vergepay/core/coins/FiatValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import org.bitcoinj.utils.Fiat;

import static com.google.common.base.Preconditions.checkArgument;

/**
* @author John L. Jegutanis
*/
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/com/vergepay/core/coins/LitecoinMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
* @author John L. Jegutanis
*/
public class LitecoinMain extends BitFamily {
private static final LitecoinMain instance = new LitecoinMain();

private LitecoinMain() {
id = "litecoin.main";

addressHeader = 48;
p2shHeader = 5;
acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
spendableCoinbaseDepth = 100;
dumpedPrivateKeyHeader = 176;

Expand All @@ -27,7 +29,6 @@ private LitecoinMain() {
signedMessageHeader = toBytes("Litecoin Signed Message:\n");
}

private static final LitecoinMain instance = new LitecoinMain();
public static synchronized CoinType get() {
return instance;
}
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/com/vergepay/core/coins/LitecoinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
* @author John L. Jegutanis
*/
public class LitecoinTest extends BitFamily {
private static final LitecoinTest instance = new LitecoinTest();

private LitecoinTest() {
id = "litecoin.test";

addressHeader = 111;
p2shHeader = 196;
acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
spendableCoinbaseDepth = 100;
dumpedPrivateKeyHeader = 239;

Expand All @@ -27,7 +29,6 @@ private LitecoinTest() {
signedMessageHeader = toBytes("Litecoin Signed Message:\n");
}

private static final LitecoinTest instance = new LitecoinTest();
public static synchronized CoinType get() {
return instance;
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/com/vergepay/core/coins/NxtMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
public class NxtMain extends NxtFamily {

private static final NxtMain instance = new NxtMain();

private NxtMain() {
id = "nxt.main";

Expand All @@ -21,7 +23,6 @@ private NxtMain() {
feePolicy = FeePolicy.FLAT_FEE;
}

private static final NxtMain instance = new NxtMain();
public static synchronized CoinType get() {
return instance;
}
Expand Down
Loading

0 comments on commit f844fea

Please sign in to comment.