mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 01:36:24 +01:00
lnwire: enforce a max limit on an outpoint's index
This commit implements the constraint on an outpoint’s index as defined within the specification.
This commit is contained in:
parent
89f4b1185e
commit
f4e8aa21b8
1 changed files with 6 additions and 0 deletions
|
@ -191,6 +191,12 @@ func writeElement(w io.Writer, element interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if e.Index > math.MaxUint16 {
|
||||
return fmt.Errorf("index for outpoint (%v) is "+
|
||||
"greater than max index of %v", e.Index,
|
||||
math.MaxUint16)
|
||||
}
|
||||
|
||||
var idx [2]byte
|
||||
binary.BigEndian.PutUint16(idx[:], uint16(e.Index))
|
||||
if _, err := w.Write(idx[:]); err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue