Skip to content

fix(go): preserve uint64 ids during json unmarshal#138

Merged
codeZe-us merged 3 commits intoBoxkit-Labs:mainfrom
Obiajulu-gif:fix-go-json-uint64-unmarshal-clean
Mar 29, 2026
Merged

fix(go): preserve uint64 ids during json unmarshal#138
codeZe-us merged 3 commits intoBoxkit-Labs:mainfrom
Obiajulu-gif:fix-go-json-uint64-unmarshal-clean

Conversation

@Obiajulu-gif
Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and fixes to the address and routing logic in the core Go package, with a focus on better handling of muxed accounts, improved error handling, and enhanced support for large routing IDs. The most significant changes include refactoring muxed account encoding/decoding, updating the detection of address kinds, improving the robustness of routing ID parsing and JSON unmarshalling, and adding comprehensive tests for edge cases.

Muxed Account Handling:

  • Refactored muxed.DecodeMuxed and muxed.EncodeMuxed to use the updated strkey.MuxedAccount API for safer and more accurate muxed account processing, including stricter validation of muxed account IDs. [1] [2]

Address Detection and Parsing:

  • Updated the Detect function to use more precise checks for muxed accounts and contracts, aligning with the latest strkey methods.
  • Introduced the ParseResult and AddressError types to standardize address parsing results and error reporting.

Routing Logic and Error Handling:

  • Improved ExtractRouting to handle errors from muxed account decoding gracefully, return appropriate error codes, and consistently process optional memo values. Routing IDs are now always wrapped in the RoutingID type. [1] [2] [3] [4]
  • Added a helper function stringValue to safely dereference optional string pointers.

Routing ID Robustness:

  • Implemented a custom UnmarshalJSON method for RoutingID to correctly handle both quoted and unquoted uint64 values, reject invalid or out-of-range numbers, and preserve the full uint64 range.
  • Added thorough tests for RoutingID JSON unmarshalling, covering valid, edge, and invalid cases.

Dependency and Tooling Updates:

  • Upgraded Go version to 1.22, updated the github.com/stellar/go dependency, and added indirect dependencies for improved build compatibility.
  • Fixed a bug in the initialization of uint64Max in memo.go for correct big integer comparison.

These changes collectively improve the reliability and maintainability of address and routing handling, especially for muxed accounts and large routing IDs.

Closes #82

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 25, 2026

@Obiajulu-gif Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@codeZe-us codeZe-us self-requested a review March 26, 2026 08:45
Copy link
Copy Markdown
Contributor

@codeZe-us codeZe-us left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Obiajulu-gif PR reviewed, this is okay

@codeZe-us
Copy link
Copy Markdown
Contributor

@Obiajulu-gif fix conflict in your branch

@codeZe-us
Copy link
Copy Markdown
Contributor

@Obiajulu-gif please resolve conflicts

@Obiajulu-gif
Copy link
Copy Markdown
Contributor Author

@codeZe-us i have fix the conflict

@codeZe-us codeZe-us merged commit 78ec5a2 into Boxkit-Labs:main Mar 29, 2026
1 check failed
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.

Implement custom JSON unmarshaler for uint64 IDs to avoid float64 precision loss

2 participants