Commit 4254029
fix(sdk-coin-trx): emit canonical AccountCreate raw_data_hex
AccountCreateContract's enum value is 0 — the proto3 default for the
outer Transaction.Contract.type field. The SDK's protobuf encoder
included this default-valued tag in the wire format (2-byte `0800`
inside the contract envelope), but TRON's node re-serializes raw_data
from broadcast JSON following strict proto3 semantics and omits
default-valued fields. The canonical raw_data_hex is therefore 2 bytes
shorter, with a different sha256 (txID).
For TSS wallets this manifested as a SIGERROR on broadcast:
Validate signature error: <sig> is signed by <random T...> but it is
not contained of permission
The TSS signature was valid for sha256(SDK_raw_data_hex), but TRON
validated it against sha256(canonical_raw_data_hex). With a mismatched
digest, ECDSA recovery returns an unrelated pubkey whose TRON address
is not in the wallet's permission set. Hot-wallet flows didn't trip
this because they sign-then-recover locally against the same buggy
bytes the SDK emits.
Other contract builders (Transfer=1, FreezeBalanceV2=11, VoteWitness=4,
DelegateResource=57, ...) all have non-default enum values, so their
SDK output matches TRON's canonical encoding by accident. AccountCreate
was uniquely affected. See the analogous proto3-default guard already
present in freezeBalanceTxBuilder.ts for the inner `resource: BANDWIDTH=0`
field.
Fix: drop the explicit `type` field from the txContract object in
getAccountCreateTxRawDataHex so the encoder omits it, matching the
canonical wire format TRON computes from the broadcast JSON. Includes
a regression test that asserts raw_data_hex does not include the
proto3-default tag and uses the canonical contract framing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ceb10dc commit 4254029
2 files changed
Lines changed: 38 additions & 3 deletions
File tree
- modules/sdk-coin-trx
- src/lib
- test/unit/transactionBuilder
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
| |||
148 | 146 | | |
149 | 147 | | |
150 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
151 | 155 | | |
152 | | - | |
153 | 156 | | |
154 | 157 | | |
155 | 158 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
118 | 150 | | |
119 | 151 | | |
120 | 152 | | |
| |||
0 commit comments