fix(sdk-coin-trx): accept hex-form TRON addresses in tx builders - #9649
Merged
Conversation
## Problem TRC-20 withdrawals to hex-form TRON destinations (0x... / 41...) failed at POST /api/v2/trx:usdt/.../tx/build with an HTTP 500 "... is not a valid base58 address" (COINS-1575). The addresses are valid — hex and base58 are alternative encodings of the same 21-byte TRON address — but the builders only accepted base58 form and surfaced the client-input error as a 500. ## Goal Accept every valid representation of a TRON address in all transaction builders while still rejecting genuinely invalid addresses with the same error. ## Fix - validateAddress accepts base58 or hex form (tronweb's isAddressValid only recognizes base58) - getHexAddressFromBase58Address canonicalizes hex-form input to base58 before decoding, so every consumption path (token transfer, account create, contract call, resource management, vote) handles both forms - error message unchanged ## Testing Unit tests: hex-form (0x and 41) recipients produce byte-identical transaction data to the base58 form of the same address; genuinely invalid addresses still throw the same error. Tests that asserted hex-form rejection were updated to the new contract. Ticket: COINS-1575 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Contributor
|
|
prajwalu142
marked this pull request as ready for review
September 4, 2026 03:32
abhishekagrawal080
approved these changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TRC-20 withdrawals to hex-form TRON destinations (
0x.../41...) failed atPOST /api/v2/trx:usdt/.../tx/buildwith an HTTP 500... is not a valid base58 address(COINS-1575). The addresses are valid — hex and base58 are alternative encodings of the same 21-byte TRON address — but the builders only accepted base58 form and surfaced the client-input error as a 500.Goal
Accept every valid representation of a TRON address in all transaction builders while still rejecting genuinely invalid addresses with the same error.
Fix
validateAddressaccepts base58 or hex form (tronweb'sisAddressValidonly recognizes base58)getHexAddressFromBase58Addresscanonicalizes hex-form input to base58 before decoding, so every consumption path (token transfer, account create, contract call, resource management, vote) handles both formsTesting
Unit tests: hex-form (
0xand41) recipients produce byte-identical transaction data to the base58 form of the same address; genuinely invalid addresses still throw the same error. Tests that asserted hex-form rejection were updated to the new contract.Ticket: COINS-1575
🤖 Generated with Claude Code