Skip to content

fix: handle serializedTxHex format in TSS verifyTransaction#8416

Merged
bhuvanr159 merged 1 commit intomasterfrom
CHALO-380-signing-fix-on-sdk
Apr 7, 2026
Merged

fix: handle serializedTxHex format in TSS verifyTransaction#8416
bhuvanr159 merged 1 commit intomasterfrom
CHALO-380-signing-fix-on-sdk

Conversation

@bhuvanr159
Copy link
Copy Markdown
Contributor

TICKET: CHALO-380

Summary

  • Issue: TRX MPC wallet withdrawals were failing with UtilsError: Number of contracts is greater than 1.

  • Root cause: verifyTransaction is called twice during the TSS signing flow:

    1. From prebuildAndSignTransaction (wallet.ts:2480) — txHex is serializedTxHex, a full JSON string ({"txID":"...","raw_data":{...},"raw_data_hex":"..."})
    2. From ECDSA signing flow (ecdsa.ts:761) — txHex is signableHex, raw protobuf hex bytes

    The TSS branch only handled case 2 (protobuf hex). When case 1 passed a JSON string, the protobuf decoder produced garbage data and threw the error.

  • Fix: Detect the format by attempting JSON.parse(txHex) — if it succeeds, extract raw_data_hex from the parsed JSON; if it fails, treat txHex as raw protobuf hex. This mirrors the pattern used by the builder's own getTxReceipt() method in wrappedBuilder.ts.

Test plan

  • Added unit tests for serializedTxHex (JSON string) path — validates success and amount-mismatch failure
  • Existing unit tests for signableHex (protobuf) path still pass
  • All 115 TRX unit tests pass (nx run @bitgo/sdk-coin-trx:unit-test)
  • TypeScript compilation clean (tsc --noEmit)
  • Manual test: TRX MPC wallet withdrawal on testnet

@bhuvanr159 bhuvanr159 requested a review from a team as a code owner April 7, 2026 08:52
@bhuvanr159 bhuvanr159 force-pushed the CHALO-380-signing-fix-on-sdk branch from 0184108 to 8f153a8 Compare April 7, 2026 09:09
@bhuvanr159 bhuvanr159 force-pushed the CHALO-380-signing-fix-on-sdk branch from 8f153a8 to d56758e Compare April 7, 2026 09:47
@bhuvanr159 bhuvanr159 force-pushed the CHALO-380-signing-fix-on-sdk branch from d56758e to 4a4f747 Compare April 7, 2026 10:36
@bhuvanr159 bhuvanr159 merged commit 52ee286 into master Apr 7, 2026
21 checks passed
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.

2 participants