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

fix(jsonrpc): ensure toJsonHex returns valid hex for empty byte arrays #6225

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

cranycrane
Copy link

What does this PR do?
This PR fixes the toJsonHex method to return "0x00" instead of "0x" when the input byte array is empty or null. This ensures that all returned hex values follow a valid format.

Why are these changes required?
Previously, when an empty byte array (new byte[0]) was passed, the method returned "0x", which is not a valid hex representation. This could cause issues with JSON-RPC clients that expect an even-length hex string. The fix ensures compatibility and proper formatting, which causes error, when parsing incorrect hex string.

This PR has been tested by:
✅ Unit Tests
✅ Manual Testing

Follow up
No additional changes are required at this time. However, it may be beneficial to audit other methods returning hex strings to ensure consistency across the project.

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

Successfully merging this pull request may close these issues.

1 participant