diff --git a/core/src/main/java/com/dogecoin/dogecoinj/core/ECKey.java b/core/src/main/java/com/dogecoin/dogecoinj/core/ECKey.java index e5e9c5af..dc2b6516 100644 --- a/core/src/main/java/com/dogecoin/dogecoinj/core/ECKey.java +++ b/core/src/main/java/com/dogecoin/dogecoinj/core/ECKey.java @@ -112,8 +112,8 @@ public class ECKey implements EncryptableItem, Serializable { } }; - /** The parameters of the secp256k1 curve that Bitcoin uses. */ - public static final X9ECParameters CURVE_PARAMS = CustomNamedCurves.getByName("secp256k1"); + // The parameters of the secp256k1 curve that Bitcoin uses. + private static final X9ECParameters CURVE_PARAMS = CustomNamedCurves.getByName("secp256k1"); /** The parameters of the secp256k1 curve that Bitcoin uses. */ public static final ECDomainParameters CURVE; @@ -495,6 +495,14 @@ public class ECKey implements EncryptableItem, Serializable { this.s = s; } + /** + * Returns true if the S component is "low", that means it is below {@link ECKey#HALF_CURVE_ORDER}. See BIP62. + */ + public boolean isCanonical() { + return s.compareTo(HALF_CURVE_ORDER) <= 0; + } + /** * Will automatically adjust the S component to be less than or equal to half the curve order, if necessary. * This is required because for every signature (r,s) the signature (r, -s (mod N)) is a valid signature of @@ -503,7 +511,7 @@ public class ECKey implements EncryptableItem, Serializable { * considered legal and the other will be banned. */ public ECDSASignature toCanonicalised() { - if (s.compareTo(HALF_CURVE_ORDER) > 0) { + if (!isCanonical()) { // The order of the curve is the number of valid points that exist on that curve. If S is in the upper // half of the number of valid points, then bring it back to the lower half. Otherwise, imagine that // N = 10 @@ -1204,6 +1212,8 @@ public class ECKey implements EncryptableItem, Serializable { builder.append(address.toString()); builder.append(" hash160:"); builder.append(Utils.HEX.encode(getPubKeyHash())); + if (creationTimeSeconds > 0) + builder.append(" creationTimeSeconds:").append(creationTimeSeconds); builder.append("\n"); if (includePrivateKeys) { builder.append(" "); diff --git a/core/src/main/java/com/dogecoin/dogecoinj/core/TransactionBroadcast.java b/core/src/main/java/com/dogecoin/dogecoinj/core/TransactionBroadcast.java index 541c91c1..c43d3571 100644 --- a/core/src/main/java/com/dogecoin/dogecoinj/core/TransactionBroadcast.java +++ b/core/src/main/java/com/dogecoin/dogecoinj/core/TransactionBroadcast.java @@ -103,7 +103,7 @@ public class TransactionBroadcast { List peers = peerGroup.getConnectedPeers(); // snapshots // We intern the tx here so we are using a canonical version of the object (as it's unfortunately mutable). // TODO: Once confidence state is moved out of Transaction we can kill off this step. - pinnedTx = context != null ? context.getConfidenceTable().intern(tx) : pinnedTx; + pinnedTx = context != null ? context.getConfidenceTable().intern(tx) : tx; // Prepare to send the transaction by adding a listener that'll be called when confidence changes. // Only bother with this if we might actually hear back: if (minConnections > 1) diff --git a/core/src/main/java/com/dogecoin/dogecoinj/core/TransactionInput.java b/core/src/main/java/com/dogecoin/dogecoinj/core/TransactionInput.java index 264064ff..6000fe64 100644 --- a/core/src/main/java/com/dogecoin/dogecoinj/core/TransactionInput.java +++ b/core/src/main/java/com/dogecoin/dogecoinj/core/TransactionInput.java @@ -60,7 +60,7 @@ public class TransactionInput extends ChildMessage implements Serializable { transient private WeakReference