diff --git a/pkg/core/transaction/invocation.go b/pkg/core/transaction/invocation.go index f07233cfe..2a0a73fcd 100644 --- a/pkg/core/transaction/invocation.go +++ b/pkg/core/transaction/invocation.go @@ -14,6 +14,7 @@ type InvocationTX struct { // Gas cost of the smart contract. Gas util.Fixed8 + Version uint8 } // NewInvocationTX returns a new invocation transaction. @@ -35,7 +36,11 @@ func NewInvocationTX(script []byte) *Transaction { func (tx *InvocationTX) DecodeBinary(r io.Reader) error { br := util.BinReader{R: r} tx.Script = br.ReadBytes() - br.ReadLE(&tx.Gas) + if (tx.Version >= 1) { + br.ReadLE(&tx.Gas) + } else { + tx.Gas = util.Fixed8FromInt64(0) + } return br.Err } @@ -43,6 +48,8 @@ func (tx *InvocationTX) DecodeBinary(r io.Reader) error { func (tx *InvocationTX) EncodeBinary(w io.Writer) error { bw := util.BinWriter{W: w} bw.WriteBytes(tx.Script) - bw.WriteLE(tx.Gas) + if (tx.Version >= 1) { + bw.WriteLE(tx.Gas) + } return bw.Err } diff --git a/pkg/core/transaction/transaction.go b/pkg/core/transaction/transaction.go index d2e242b3e..3c2332373 100644 --- a/pkg/core/transaction/transaction.go +++ b/pkg/core/transaction/transaction.go @@ -136,7 +136,7 @@ func (t *Transaction) DecodeBinary(r io.Reader) error { func (t *Transaction) decodeData(r io.Reader) error { switch t.Type { case InvocationType: - t.Data = &InvocationTX{} + t.Data = &InvocationTX{Version: t.Version} return t.Data.(*InvocationTX).DecodeBinary(r) case MinerType: t.Data = &MinerTX{} diff --git a/pkg/rpc/server_test.go b/pkg/rpc/server_test.go index c389142b7..03b18acd7 100644 --- a/pkg/rpc/server_test.go +++ b/pkg/rpc/server_test.go @@ -224,12 +224,11 @@ var testRpcCases = []tc{ expectedResult: `{"jsonrpc":"2.0","result":true,"id":1}`, }, - /* Good case: TODO: uncomment this test case once https://github.com/CityOfZion/neo-go/issues/173 is fixed! { rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "sendrawtransaction", "params": ["d1001b00046e616d6567d3d8602814a429a91afdbaa3914884a1c90c733101201cc9c05cefffe6cdd7b182816a9152ec218d2ec000000141403387ef7940a5764259621e655b3c621a6aafd869a611ad64adcc364d8dd1edf84e00a7f8b11b630a377eaef02791d1c289d711c08b7ad04ff0d6c9caca22cfe6232103cbb45da6072c14761c9da545749d9cfd863f860c351066d16df480602a2024c6ac"] }`, method: "sendrawtransaction_2", expectedResult: `{"jsonrpc":"2.0","result":true,"id":1}`, - },*/ + }, // Bad case, incorrect raw transaction {