From ca1466e628570c7e837ee5ae919f18a6b9a84aca Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 11 Jul 2012 02:39:57 +0200 Subject: [PATCH] Make isCoinBase() equivalent to the reference one. --- core/src/main/java/com/google/bitcoin/core/Transaction.java | 2 +- .../main/java/com/google/bitcoin/core/TransactionInput.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/Transaction.java b/core/src/main/java/com/google/bitcoin/core/Transaction.java index e069f558..25e5535f 100644 --- a/core/src/main/java/com/google/bitcoin/core/Transaction.java +++ b/core/src/main/java/com/google/bitcoin/core/Transaction.java @@ -518,7 +518,7 @@ public class Transaction extends ChildMessage implements Serializable { */ public boolean isCoinBase() { maybeParse(); - return inputs.get(0).isCoinBase(); + return inputs.size() == 1 && inputs.get(0).isCoinBase(); } /** diff --git a/core/src/main/java/com/google/bitcoin/core/TransactionInput.java b/core/src/main/java/com/google/bitcoin/core/TransactionInput.java index d7d81dad..a197760c 100644 --- a/core/src/main/java/com/google/bitcoin/core/TransactionInput.java +++ b/core/src/main/java/com/google/bitcoin/core/TransactionInput.java @@ -59,7 +59,7 @@ public class TransactionInput extends ChildMessage implements Serializable { TransactionInput(NetworkParameters params, Transaction parentTransaction, byte[] scriptBytes) { super(params); this.scriptBytes = scriptBytes; - this.outpoint = new TransactionOutPoint(params, -1, (Transaction)null); + this.outpoint = new TransactionOutPoint(params, NO_SEQUENCE, (Transaction)null); this.sequence = NO_SEQUENCE; this.parentTransaction = parentTransaction; @@ -148,7 +148,8 @@ public class TransactionInput extends ChildMessage implements Serializable { */ public boolean isCoinBase() { maybeParse(); - return outpoint.getHash().equals(Sha256Hash.ZERO_HASH); + return outpoint.getHash().equals(Sha256Hash.ZERO_HASH) && + outpoint.getIndex() == NO_SEQUENCE; } /**