neodix42 / ton4j

Java libraries for interacting with TON blockchain.
GNU General Public License v3.0
28 stars 10 forks source link

fix CellSlice.getFreeBits #8

Closed arc0035 closed 1 month ago

arc0035 commented 1 month ago

Hi, Currently CellSlice.getFreeBits() has different meanings from that in tonweb.

In ton4j, CellSlice.getFreeBits() will return the USED bits length while in tonweb CellSlice.getFreeBits() returns the UNUSED bits length.

This would lead to misparsing of transaction message payloads. If we have a payload like this which represents a text encoded comment "114514":

00000000000000000000000000000000001100010011000100110100001101010011000100110100

Then after read the first 4 bytes, becomes:

001100010011000100110100001101010011000100110100

Then if we call getFreeBits it yields (80 - 48) = 32 bits, but what we want it the remaining 48 bits, causing only parsing "1145" instead of "114514"