transaction: don't overwrite error and witnesses length check
ReadArray() can return some error and we shouldn't overwrite it. At the same time limiting ReadArray() to the number of Signers can make it return wrong error if the number of witnesses actually is bigger than the number of signers, so use MaxAttributes.
This commit is contained in:
parent
d487b54612
commit
d2732a71d8
1 changed files with 2 additions and 2 deletions
|
@ -148,8 +148,8 @@ func (t *Transaction) decodeBinaryNoSize(br *io.BinReader) {
|
||||||
if br.Err != nil {
|
if br.Err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
br.ReadArray(&t.Scripts, len(t.Signers))
|
br.ReadArray(&t.Scripts, MaxAttributes)
|
||||||
if len(t.Signers) != len(t.Scripts) {
|
if br.Err == nil && len(t.Signers) != len(t.Scripts) {
|
||||||
br.Err = fmt.Errorf("%w: %d vs %d", ErrInvalidWitnessNum, len(t.Signers), len(t.Scripts))
|
br.Err = fmt.Errorf("%w: %d vs %d", ErrInvalidWitnessNum, len(t.Signers), len(t.Scripts))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue