forked from TrueCloudLab/neoneo-go
block: it's not a padding, but a witness count in the base
At least that's the interpretation C# codebase has, so be a bit more correct in error message.
This commit is contained in:
parent
b9a66c64e1
commit
0002b65238
1 changed files with 4 additions and 7 deletions
|
@ -3,7 +3,6 @@ package block
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||||
|
@ -84,11 +83,9 @@ func (b *Base) VerificationHash() util.Uint256 {
|
||||||
// DecodeBinary implements Serializable interface.
|
// DecodeBinary implements Serializable interface.
|
||||||
func (b *Base) DecodeBinary(br *io.BinReader) {
|
func (b *Base) DecodeBinary(br *io.BinReader) {
|
||||||
b.decodeHashableFields(br)
|
b.decodeHashableFields(br)
|
||||||
|
witnessCount := br.ReadVarUint()
|
||||||
padding := []byte{0}
|
if br.Err == nil && witnessCount != 1 {
|
||||||
br.ReadBytes(padding)
|
br.Err = errors.New("wrong witness count")
|
||||||
if padding[0] != 1 {
|
|
||||||
br.Err = fmt.Errorf("format error: padding must equal 1 got %d", padding)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +95,7 @@ func (b *Base) DecodeBinary(br *io.BinReader) {
|
||||||
// EncodeBinary implements Serializable interface
|
// EncodeBinary implements Serializable interface
|
||||||
func (b *Base) EncodeBinary(bw *io.BinWriter) {
|
func (b *Base) EncodeBinary(bw *io.BinWriter) {
|
||||||
b.encodeHashableFields(bw)
|
b.encodeHashableFields(bw)
|
||||||
bw.WriteBytes([]byte{1})
|
bw.WriteVarUint(1)
|
||||||
b.Script.EncodeBinary(bw)
|
b.Script.EncodeBinary(bw)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue