Harden Marshal/Unmarshal logic for Change.SpentChildren.
This commit is contained in:
parent
b06df3d750
commit
0241e18f42
1 changed files with 3 additions and 2 deletions
|
@ -78,9 +78,10 @@ func (c *Change) Marshal(enc *bytes.Buffer) error {
|
||||||
binary.BigEndian.PutUint32(temp[:4], uint32(len(c.SpentChildren)))
|
binary.BigEndian.PutUint32(temp[:4], uint32(len(c.SpentChildren)))
|
||||||
enc.Write(temp[:4])
|
enc.Write(temp[:4])
|
||||||
for key := range c.SpentChildren {
|
for key := range c.SpentChildren {
|
||||||
binary.BigEndian.PutUint16(temp[:2], uint16(len(key))) // technically limited to 255; not sure we trust it
|
keySize := uint16(len(key))
|
||||||
|
binary.BigEndian.PutUint16(temp[:2], keySize) // technically limited to 255; not sure we trust it
|
||||||
enc.Write(temp[:2])
|
enc.Write(temp[:2])
|
||||||
enc.WriteString(key)
|
enc.WriteString(key[:keySize])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binary.BigEndian.PutUint32(temp[:4], 0)
|
binary.BigEndian.PutUint32(temp[:4], 0)
|
||||||
|
|
Loading…
Reference in a new issue