Skip to content

Commit

Permalink
Limit input count in transaction (iotaledger#1143)
Browse files Browse the repository at this point in the history
Co-authored-by: Hans Moog <[email protected]>
  • Loading branch information
jonastheis and Hans Moog authored Mar 29, 2021
1 parent 04581b3 commit 48f8f0a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/ledgerstate/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ import (
const (
// UTXOInputType is the type of an Input that references an UTXO Output.
UTXOInputType InputType = iota

// MinInputCount defines the minimum amount of Inputs in a Transaction.
MinInputCount = 1

// MaxInputCount defines the maximum amount of Inputs in a Transaction.
MaxInputCount = 127
)

// InputType represents the type of an Input.
Expand Down Expand Up @@ -161,6 +167,14 @@ func InputsFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (inputs Inputs,
err = xerrors.Errorf("failed to parse inputs count (%v): %w", err, cerrors.ErrParseBytesFailed)
return
}
if inputsCount < MinInputCount {
err = xerrors.Errorf("amount of Inputs (%d) failed to reach MinInputCount (%d): %w", inputsCount, MinInputCount, cerrors.ErrParseBytesFailed)
return
}
if inputsCount > MaxInputCount {
err = xerrors.Errorf("amount of Inputs (%d) exceeds MaxInputCount (%d): %w", inputsCount, MaxInputCount, cerrors.ErrParseBytesFailed)
return
}

var previousInput Input
parsedInputs := make([]Input, inputsCount)
Expand Down

0 comments on commit 48f8f0a

Please sign in to comment.