Therefore, in line 45, maxLen contains number of bytes, but actualLen is clearly number of bits, and very often number of bits is larger, causing this exception. It is also related to other mathematical operators with VarUInteger
Moreover, to me it seems that bit length anyway can increase when adding two numbers of the same bit length
On almost any addition (say
VarUInteger(1)+VarUInteger(1)
) an exception is thrown fromplus
in line45
https://github.com/andreypfau/ton-kotlin/blob/b1edc4b134e89ccf252149f27c85fd530377cebe/ton-kotlin-block/src/commonMain/kotlin/org/ton/block/VarUInteger.kt#L41-L47
This happens, because
VarUInteger
, when constructed, holds number's length in bytes: https://github.com/andreypfau/ton-kotlin/blob/b1edc4b134e89ccf252149f27c85fd530377cebe/ton-kotlin-block/src/commonMain/kotlin/org/ton/block/VarUInteger.kt#L26-L31Therefore, in line
45
,maxLen
contains number of bytes, butactualLen
is clearly number of bits, and very often number of bits is larger, causing this exception. It is also related to other mathematical operators withVarUInteger
Moreover, to me it seems that bit length anyway can increase when adding two numbers of the same bit length