-
Notifications
You must be signed in to change notification settings - Fork 38
Fix memo parsing for strings starting with 0x #2080
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
Fix memo parsing for strings starting with 0x #2080
Conversation
- Modified interpret_memo_string to only decode hex if result is valid memo size (≤512 bytes) - Added unit tests for plain text, valid hex, Ethereum addresses, invalid hex, and oversized memos - Fixes zingolabs#2075 where Ethereum addresses in memos caused transaction failures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Timi16 thanks for looking into this. I will post in the issue #2075 to get more info as i'm struggling to understand under which conditions this bug occurs, i cant reproduce it myself. Please see this issue for more context. The changes you have made are to the parsing of an Arbitrary memo - starting with 0xFF byte as stated in zip302 - which are used internally by zingo and are not displayed to the user or intended to be human-readable. Therefore, this code needs to remain unchanged. I assume the issue we are trying to solve is when the ethereum address is inputted by the user as text. In this case, the first byte will be <= 0xF4 resulting is a memo of Text variant where the remaining 511 bytes will be parsed to a string. This string should be able to contain any valid UTF-8 and its not clear to me why any text memo starting with "0x" will be treated differently. my tests support this, here is an example:
txid: cfd5f064237370c7d60131bdbe86a4950d206d995c06991f415a2f6bfbdd485f
datetime: 2026-01-14 06:31:03 UTC
status: confirmed
blockheight: 3204220
kind: send-to-self
value: 0
fee: 10000
zec price: not available
orchard notes:
{
value: 100000
spend status: unspent
output index: 0
memo: 0xtest
}
5f9b9af to
066414b
Compare
Oscar-Pepper
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work. thanks for your contribution!
|
hi @Timi16 I have pushed a commit instead of requesting changes. I hope this is ok, otherwise I can PR into your branch if you prefer. please review my commit and if all ok we can merge. |
Yes you can all is Okay thank you |
I Thank the Zingolib team for there support |
When a memo string starts with
0x(like an Ethereum address), the current code attempts to decode it as hexadecimal. For valid hex strings like Ethereum addresses, the decode succeeds but produces data that causes transaction failures during scanning.Changes
interpret_memo_stringinzingolib/src/wallet/utils.rsto only use hex-decoded data if it's a valid memo size (≤512 bytes)Testing
Added unit tests in
zingolib/src/wallet/utils.rs:test_interpret_memo_string_plain_texttest_interpret_memo_string_valid_hextest_interpret_memo_string_ethereum_addresstest_interpret_memo_string_invalid_hextest_interpret_memo_string_too_long