diff --git a/pkg/proto/transactions_with_proofs.go b/pkg/proto/transactions_with_proofs.go index 8bface6f26..5836d84fd8 100644 --- a/pkg/proto/transactions_with_proofs.go +++ b/pkg/proto/transactions_with_proofs.go @@ -51,6 +51,8 @@ const ( maxArguments = 22 maxFunctionNameBytes = 255 maxInvokeScriptWithProofsBytes = 5 * 1024 + + topRideVersion = 5 ) // IssueWithProofs is a transaction to issue new asset, second version. @@ -184,9 +186,8 @@ func validContentType(t byte) bool { return t >= 1 && t <= 3 } -// version in range [0, 5) -func validStdVersion(v byte) bool { - return v < 5 +func validScriptVersion(v byte) bool { + return v <= topRideVersion } func (tx *IssueWithProofs) Validate() (Transaction, error) { @@ -198,10 +199,9 @@ func (tx *IssueWithProofs) Validate() (Transaction, error) { return tx, err } if tx.NonEmptyScript() { - if !validStdVersion(tx.Script[0]) { + if !validScriptVersion(tx.Script[0]) { return tx, errors.Errorf("Invalid version of script: %d", tx.Script[0]) } - if tx.Script[0] == 0 { // version byte if len(tx.Script) <= 2 { return tx, errors.Errorf("Illegal length of script: %d", len(tx.Script)) @@ -209,12 +209,10 @@ func (tx *IssueWithProofs) Validate() (Transaction, error) { if !validContentType(tx.Script[1]) { return tx, errors.Errorf("Invalid content type of script: %d", tx.Script[1]) } - if tx.Script[2] > 4 { // 4 is current max script version + if !validScriptVersion(tx.Script[2]) { return tx, errors.Errorf("Invalid version of script: %d", tx.Script[2]) } - } - if !tx.Script.IsValidChecksum() { return tx, errors.Errorf("Invalid checksum: %+v", []byte(tx.Script)) } @@ -3152,7 +3150,7 @@ func (tx *DataWithProofs) bodyUnmarshalBinary(data []byte) error { if err != nil { return errors.Errorf("failed to extract type of data entry") } - switch DataValueType(t) { + switch t { case DataInteger: var ie IntegerDataEntry err = ie.UnmarshalBinary(data) @@ -4281,7 +4279,7 @@ func (tx *InvokeScriptWithProofs) Clone() *InvokeScriptWithProofs { return out } -//NewUnsignedSetAssetScriptWithProofs creates new unsigned SetAssetScriptWithProofs transaction. +//NewUnsignedInvokeScriptWithProofs creates new unsigned InvokeScriptWithProofs transaction. func NewUnsignedInvokeScriptWithProofs(v, chain byte, senderPK crypto.PublicKey, scriptRecipient Recipient, call FunctionCall, payments ScriptPayments, feeAsset OptionalAsset, fee, timestamp uint64) *InvokeScriptWithProofs { return &InvokeScriptWithProofs{ Type: InvokeScriptTransaction, @@ -4756,7 +4754,7 @@ func (tx *UpdateAssetInfoWithProofs) MarshalBinary() ([]byte, error) { return nil, errors.New("binary format is not defined for UpdateAssetInfoTransaction") } -func (tx *UpdateAssetInfoWithProofs) UnmarshalBinary(data []byte, scheme Scheme) error { +func (tx *UpdateAssetInfoWithProofs) UnmarshalBinary(_ []byte, _ Scheme) error { return errors.New("binary format is not defined for UpdateAssetInfoTransaction") }