From 9585729398ae2c7cc5439b6243b116eb1fcf2030 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 29 Aug 2012 22:07:09 -0400 Subject: [PATCH] Remove redundant TransactionOutput constructor --- core/src/main/java/com/google/bitcoin/core/Block.java | 2 +- .../com/google/bitcoin/core/NetworkParameters.java | 2 +- .../java/com/google/bitcoin/core/Transaction.java | 2 +- .../com/google/bitcoin/core/TransactionOutput.java | 11 ----------- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/Block.java b/core/src/main/java/com/google/bitcoin/core/Block.java index d989d8112..8794ec012 100644 --- a/core/src/main/java/com/google/bitcoin/core/Block.java +++ b/core/src/main/java/com/google/bitcoin/core/Block.java @@ -892,7 +892,7 @@ public class Block extends Message { // Here we will do things a bit differently so a new address isn't needed every time. We'll put a simple // counter in the scriptSig so every transaction has a different hash. coinbase.addInput(new TransactionInput(params, coinbase, new byte[]{(byte) txCounter++, (byte) 1})); - coinbase.addOutput(new TransactionOutput(params, coinbase, Script.createOutputScript(pubKeyTo), value)); + coinbase.addOutput(new TransactionOutput(params, coinbase, value, Script.createOutputScript(pubKeyTo))); transactions.add(coinbase); coinbase.setParent(this); coinbase.length = coinbase.bitcoinSerialize().length; diff --git a/core/src/main/java/com/google/bitcoin/core/NetworkParameters.java b/core/src/main/java/com/google/bitcoin/core/NetworkParameters.java index e9c226795..7425ffa4c 100644 --- a/core/src/main/java/com/google/bitcoin/core/NetworkParameters.java +++ b/core/src/main/java/com/google/bitcoin/core/NetworkParameters.java @@ -150,7 +150,7 @@ public class NetworkParameters implements Serializable { Script.writeBytes(scriptPubKeyBytes, Hex.decode ("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f")); scriptPubKeyBytes.write(Script.OP_CHECKSIG); - t.addOutput(new TransactionOutput(n, t, scriptPubKeyBytes.toByteArray(), Utils.toNanoCoins(50, 0))); + t.addOutput(new TransactionOutput(n, t, Utils.toNanoCoins(50, 0), scriptPubKeyBytes.toByteArray())); } catch (Exception e) { // Cannot happen. throw new RuntimeException(e); 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 912c5a866..25d6dd003 100644 --- a/core/src/main/java/com/google/bitcoin/core/Transaction.java +++ b/core/src/main/java/com/google/bitcoin/core/Transaction.java @@ -152,7 +152,7 @@ public class Transaction extends ChildMessage implements Serializable { this.inputs = new ArrayList(tx.getInputs()); this.outputs = new ArrayList(tx.getOutputs().size()); for (StoredTransactionOutput output : tx.getOutputs()) { - this.outputs.add(new TransactionOutput(params, this, output.getScriptBytes(), output.getValue())); + this.outputs.add(new TransactionOutput(params, this, output.getValue(), output.getScriptBytes())); } } diff --git a/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java b/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java index d101e838e..2337ebe81 100644 --- a/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java +++ b/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java @@ -111,17 +111,6 @@ public class TransactionOutput extends ChildMessage implements Serializable { length = 8 + VarInt.sizeOf(scriptBytes.length) + scriptBytes.length; } - /** - * Used only in creation of the genesis blocks and in unit tests. - */ - TransactionOutput(NetworkParameters params, Transaction parent, byte[] scriptBytes, BigInteger value) { - super(params); - this.scriptBytes = scriptBytes; - this.value = value; - parentTransaction = parent; - availableForSpending = true; - } - public Script getScriptPubKey() throws ScriptException { if (scriptPubKey == null) { maybeParse();