mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 09:20:04 +01:00
Transaction: remove the input and output re-reading
We needed this to correctly determine the message length, but that requirement is gone.
This commit is contained in:
parent
1fef4e2cdb
commit
7d31021663
1 changed files with 2 additions and 14 deletions
|
@ -642,13 +642,7 @@ public class Transaction extends BaseMessage {
|
|||
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 = TransactionInput.read(payload.slice(), this);
|
||||
inputs.add(input);
|
||||
// intentionally read again, due to the slice above
|
||||
Buffers.skipBytes(payload, TransactionOutPoint.BYTES);
|
||||
VarInt scriptLenVarInt = VarInt.read(payload);
|
||||
int scriptLen = scriptLenVarInt.intValue();
|
||||
Buffers.skipBytes(payload, scriptLen + 4);
|
||||
inputs.add(TransactionInput.read(payload, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -658,13 +652,7 @@ public class Transaction extends BaseMessage {
|
|||
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 = TransactionOutput.read(payload.slice(), this);
|
||||
outputs.add(output);
|
||||
// intentionally read again, due to the slice above
|
||||
Buffers.skipBytes(payload, 8); // value
|
||||
VarInt scriptLenVarInt = VarInt.read(payload);
|
||||
int scriptLen = scriptLenVarInt.intValue();
|
||||
Buffers.skipBytes(payload, scriptLen);
|
||||
outputs.add(TransactionOutput.read(payload, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue