Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvocationTransaction: incorrect size calculation #652

Closed
dauTT opened this issue Mar 22, 2019 · 0 comments
Closed

InvocationTransaction: incorrect size calculation #652

dauTT opened this issue Mar 22, 2019 · 0 comments

Comments

@dauTT
Copy link

dauTT commented Mar 22, 2019

The following invocation transaction has size 219:

public void Test()
        {
            // taken from mainnet c4bb9b638da2e5f4a88ffcc4cb1d4f6693e7f19b7f78d242068254a6c77721f9
            // https://neoscan.io/transaction/C4BB9B638DA2E5F4A88FFCC4CB1D4F6693E7F19B7F78D242068254A6C77721F9

            String s = "d1015904802b530b14d5a682e81b8a840cc44b3b360cbd0f1ee6f50efd14235a717ed7ed18a43de47499c3d05b8d4a4bcf3a53c1087472616e7366657267fb1c540417067c270dee32f21023aa8b9b71abcef166fc47646b02d3f92300000000000000000120235a717ed7ed18a43de47499c3d05b8d4a4bcf3a0000014140b9234cad658c4d512bca453908a0df1c2beda49c544ec735bb492b81b4d0974ac8d66046061b3d0ce823e27c71fef1ee6a8f2fa369198ac74acedd045901d7222321030ab39b99d8675cd9bd90aaec37cba964297cc817078d33e508ab11f1d245c068ac";
            InvocationTransaction tx = (InvocationTransaction)Transaction.DeserializeFrom(s.HexToBytes());

            System.Console.WriteLine(tx.Size); // 219
            System.Console.WriteLine(tx.Version); // 1

        }

219 breaks down as follow:

//Size invocation transaction = Size base transaction + Size Script  
public override int Size => base.Size + Script.GetVarSize();  

//Size base transaction
public virtual int Size => sizeof(TransactionType) + sizeof(byte) + Attributes.GetVarSize() + Inputs.GetVarSize() + Outputs.GetVarSize() + Witnesses.GetVarSize();

Size invocation link
Size base transaction link

image

Looking at the serialization method of the invocation transactions:
https://github.com/CityOfZion/neo-python/blob/master/neo/Core/TX/InvocationTransaction.py#L74

image
we believe that 8 bytes should be added to the size calculation of the invocation transaction wheneve version >=1. In summary for the above transaction we woul expect it to have size
227 = 219+8
(ref: neo-go #185)

Thacryba pushed a commit to simplitech/neo that referenced this issue Feb 17, 2020
* Update api.md

- Add "Need to open the wallet" to the Comment column for `sendfrom`

* Update api.md

- Adds "Need to open the wallet" to the Comment Column for `getwalletheight`

* Update zh-cn/node/cli/2.9.0/api.md

update the Chinese version accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant