Skip to content
This repository has been archived by the owner on Jan 26, 2023. It is now read-only.

Wrong handling of Binary comments (BinaryMessage.ts) #12

Open
nns2009 opened this issue May 2, 2022 · 1 comment
Open

Wrong handling of Binary comments (BinaryMessage.ts) #12

nns2009 opened this issue May 2, 2022 · 1 comment

Comments

@nns2009
Copy link

nns2009 commented May 2, 2022

In: https://github.com/tonwhales/ton/blob/master/src/messages/BinaryMessage.ts
binary comments are not handled according to guidelines: https://ton.org/docs/#/howto/smart-contract-guidelines

If op is zero, then the message is a "simple transfer message with comment". The comment is contained in the remainder of the message body (without any query_id field, i.e., starting from the fifth byte). If it does not begin with the byte 0xff, the comment is a text one; ... On the other hand, if the comment begins with the byte 0xff, the remainder is a "binary comment"

In other words, need bytes 0x00000000FF before writing buffer

Suggested fix:

writeTo(cell: Cell) {
    cell.bits.writeUint(0, 32);
    cell.bits.writeUint(0xFF, 8);
    cell.bits.writeBuffer(this.payload);
}

Another issue is handling big binary comments which don't into one cell.
The case of big messages is handled in for text comments in CommentMessage.ts, but not for binary comments.

@ex3ndr
Copy link
Contributor

ex3ndr commented Jul 5, 2022

Hello! Thank you for your contribution, but in our library BinaryMessage does not a "binary comment" from original whitepaper, but a simple wrapper on top of a buffer and simply a convenient way to write a buffer using messages.

Also we haven't seen binary comments in practice. We are looking to improve this part in next releases.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants