From 27b3054df48cfab91312a75eb5da5c16216225c3 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 3 Jul 2020 17:40:03 +0300 Subject: [PATCH] transaction: set feePerByte on tx construction --- pkg/core/transaction/transaction.go | 1 + pkg/rpc/client/rpc_test.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/core/transaction/transaction.go b/pkg/core/transaction/transaction.go index 9bb6825d4..657300fe9 100644 --- a/pkg/core/transaction/transaction.go +++ b/pkg/core/transaction/transaction.go @@ -275,6 +275,7 @@ func NewTransactionFromBytes(network netmode.Magic, b []byte) (*Transaction, err if r.Err != nil { return nil, r.Err } + tx.feePerByte = tx.NetworkFee / int64(len(b)) return tx, nil } diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 93741e7b0..71b1ae334 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -498,7 +498,12 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ if err != nil { panic(err) } - return c.GetRawTransactionVerbose(hash) + out, err := c.GetRawTransactionVerbose(hash) + if err != nil { + return nil, err + } + out.Transaction.FeePerByte() // set fee per byte + return out, nil }, serverResponse: txMoveNeoVerbose, result: func(c *Client) interface{} {