TransactionInput: remove serializer from constructor

This commit is contained in:
Andreas Schildbach 2023-03-30 15:06:41 +02:00
parent 8091384ff6
commit c1a32f6585
2 changed files with 5 additions and 16 deletions

View file

@ -694,7 +694,7 @@ public class Transaction extends Message {
int numInputs = numInputsVarInt.intValue();
inputs = new ArrayList<>(Math.min((int) numInputs, Utils.MAX_INITIAL_ARRAY_LENGTH));
for (long i = 0; i < numInputs; i++) {
TransactionInput input = new TransactionInput(params, this, payload.slice(), serializer);
TransactionInput input = new TransactionInput(params, this, payload.slice());
inputs.add(input);
// intentionally read again, due to the slice above
Buffers.skipBytes(payload, TransactionOutPoint.MESSAGE_LENGTH);
@ -709,7 +709,7 @@ public class Transaction extends Message {
int numOutputs = numOutputsVarInt.intValue();
outputs = new ArrayList<>(Math.min((int) numOutputs, Utils.MAX_INITIAL_ARRAY_LENGTH));
for (long i = 0; i < numOutputs; i++) {
TransactionOutput output = new TransactionOutput(params, this, payload.slice(), serializer);
TransactionOutput output = new TransactionOutput(params, this, payload.slice());
outputs.add(output);
// intentionally read again, due to the slice above
Buffers.skipBytes(payload, 8); // value

View file

@ -131,6 +131,9 @@ public class TransactionInput extends Message {
/**
* Deserializes an input message. This is usually part of a transaction message.
* @param params NetworkParameters object.
* @param payload Bitcoin protocol formatted byte array containing message content.
* @throws ProtocolException
*/
public TransactionInput(NetworkParameters params, @Nullable Transaction parentTransaction, ByteBuffer payload) throws ProtocolException {
super(params, payload);
@ -138,20 +141,6 @@ public class TransactionInput extends Message {
this.value = null;
}
/**
* Deserializes an input message. This is usually part of a transaction message.
* @param params NetworkParameters object.
* @param payload Bitcoin protocol formatted byte array containing message content.
* @param serializer the serializer to use for this message.
* @throws ProtocolException
*/
public TransactionInput(NetworkParameters params, Transaction parentTransaction, ByteBuffer payload, MessageSerializer serializer)
throws ProtocolException {
super(params, payload, serializer);
setParent(parentTransaction);
this.value = null;
}
/**
* Gets the index of this input in the parent transaction, or throws if this input is freestanding. Iterates
* over the parents list to discover this.