Skip to content

[sc-150250]: add native token name support to CoinInfo structure and related functions - #4831

Merged
sergei-boiko-trustwallet merged 2 commits into
masterfrom
feat/native-token-name
Jul 27, 2026
Merged

[sc-150250]: add native token name support to CoinInfo structure and related functions#4831
sergei-boiko-trustwallet merged 2 commits into
masterfrom
feat/native-token-name

Conversation

@sergei-boiko-trustwallet

Copy link
Copy Markdown
Contributor

This pull request adds support for a new nativeTokenName field for coins, updates the registry data to include this field for many coins, and updates the code generation and tests to use and validate this field. This makes it possible to distinguish the native token name from the coin or chain name, which is especially useful for chains that use the same token (like Ethereum-based L2s).

Registry and Data Model Updates:

  • Added a new nativeTokenName field to the coin registry data model (CoinItem in codegen-v2/src/registry.rs) and populated this field for many coins in registry.json.

API and Functionality:

  • Introduced a new public API function TWCoinTypeConfigurationGetNativeTokenName in the manifest and header files to retrieve the native token name for a coin.

Code Generation and Templates:

  • Updated code generation templates and logic to use the new nativeTokenName field, and to fall back to display name or name if not specified. This affects C++ code generation and test templates.

Tests:

  • Updated generated tests to check for the correct native token name using the new API and registry field.

These changes ensure that the native token name is consistently available and validated across the codebase and registry.

@octane-security-app

Copy link
Copy Markdown

Summary by Octane

New Contracts

No new contracts were added.

Updated Contracts

  • template_generator.rs: The smart contract now includes a "{NATIVE_TOKEN_NAME}" pattern that prioritizes the native token name, followed by the display name, and defaults to the coin name.
  • registry.rs: Added 'native_token_name' field to the CoinItem struct for enhanced token identification.
  • Coin.cpp: Added function to retrieve native token names for each coin type.

🔗 Commit Hash: 56969a5

@github-actions

Copy link
Copy Markdown

⚠️ Backward-compatibility check needed

This PR touches persistence-sensitive files: include/TrustWalletCore/TWCoinTypeConfiguration.h, registry.json.

Post a comment with one of:

  • [bc-check: Pass] — audit run, Verdict: SAFE. Must include audit output.
  • [bc-check: Mitigated] — audit found RISK or BLOCKER; you fixed it in code. Must include the post-fix audit output.
  • [bc-check: Risk-Accepted] — audit found RISK or BLOCKER; investigation confirms blast radius is effectively zero (no user data in the wild can trigger it). Must include audit output + explicit evidence (who confirmed it, what data or reasoning).
  • [bc-check: N/A] — scanner fired on a file with zero BC relevance (comment edit, test fixture, renamed variable). Invalid if the audit found a real risk.

Each token must be accompanied by >=60 chars of reasoning. The reasoning must be fresh — posted or edited at or after the HEAD commit.

Why audit evidence is required for Pass / Mitigated: humans don't reliably ask the right BC question on every PR. AI being in the loop is the whole point of this gate. The bot does not judge whether your reasoning is correct — reviewers do, like any other code review.

Things worth thinking about: could a previous version have written data this PR's new check would now reject? Was there a partial migration ("regenerate on next user action") that may not have completed for all users? Does this format live in iCloud / Google Drive backup, exported files, or sync payloads? See docs/bc-footguns.md for known cases.

Changed files (2)
  • include/TrustWalletCore/TWCoinTypeConfiguration.h
  • registry.json
Copy this audit prompt into Claude Code on this branch (or run the /bc-check skill) for a structured analysis you can paste into your sign-off
You are auditing a Trust Wallet Core PR against origin/master
for **backward-compatibility risk against persisted user data and wire formats**.
Find cases where this PR will reject, mis-parse, or mishandle inputs that older
versions of our software already wrote to disk, to backups, or onto the network.

**Trust Wallet Core domain context:**
- src/Keystore/ — JSON keystore files (user encrypted keys/mnemonics).
  These live in iCloud, Google Drive, and manual exports.
  A parse failure = wallet inaccessible = user cannot access funds.
- src/proto/*.proto — Protobuf SigningInput/SigningOutput wire formats.
  Field numbers are permanent; reuse or removal silently corrupts binary data.
- include/TrustWalletCore/TW*.h — Public C ABI.
  Removing/renaming TW* functions or changing enum values breaks compiled bindings.
- registry.json — coin metadata (SLIP44, derivation path, curve, address encoding).
  Changing any of these re-derives different addresses for all existing wallets.

Do NOT trust the PR description's framing.
'Just a security fix' / 'stricter validation' is exactly the framing that hides this class of bug.
Read docs/bc-footguns.md first.

Walk these 5 steps. Cite file:line and commit SHA everywhere:

1. Classify: tightening validation? Parsing change? Exception type change?
   Removing 'if missing use default'? Moving validation into a constructor?
2. Historical baseline. For each tightened rule:
   - Could a prior version have PRODUCED data that violates the new rule? (cite SHA)
   - Was there a partial migration that may not have completed for all users?
   - Does the format ever leave the device (backup, export, sync)?
3. Concrete failure scenarios: old version -> action -> where stored -> code path
   (file:line) -> user symptom -> blast radius. No hand-waving.
4. Red-flag checklist (yes/no + file:line evidence):
   - New throw on a read/load/decode/import path?
   - Removed an 'if missing use default' branch?
   - New length/range/enum check on a >1-year-old field?
   - Constructor changed from lenient parse to parse+validate?
   - Changed which exception type a public API throws?
   - Format ever in backup/export/sync?
   - Prior PR shipped a 'regenerate on next user action' partial migration? (cite SHA)
   - Proto: field number reused or removed? Enum value renumbered/removed?
   - Keystore: JSON key renamed/removed/made required without default fallback?
   - Registry: slip44, curve, or address-encoding field changed?
5. Mitigations: accept legacy at read + normalize on write (preferred);
   gate strict check behind 'newly created' flag; one-time migration with clear UX;
   or apply tightening to write paths only.

Output a markdown report: Verdict (SAFE/RISK/BLOCKER) at top, then steps 1-5,
then a 'Suggested PR comment' block ([bc-check: Pass|Mitigated|N/A] + reasoning),
then a 'Suggested addition to docs/bc-footguns.md' block (or 'none').

Merge is blocked by verify-bc-check-comment until a tagged comment is posted.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends Trust Wallet Core’s coin metadata model by introducing a nativeTokenName field, exposing it via a new public C API (TWCoinTypeConfigurationGetNativeTokenName), and propagating the field through registry data, code generation (legacy + codegen-v2), and generated coin-type tests. This enables distinguishing a chain/coin display name from the chain’s native token name (notably for L2s using ETH).

Changes:

  • Added nativeTokenName to the internal CoinInfo structure and exposed it via TWCoinTypeConfigurationGetNativeTokenName.
  • Updated registry + code generators (Ruby + codegen-v2) to populate nativeTokenName with override + fallback (nativeTokenName → displayName → name).
  • Updated interface and per-coin chain tests to validate nativeTokenName values.

Reviewed changes

Copilot reviewed 176 out of 177 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/interface/TWCoinTypeTests.cpp Adds interface-level tests for native token name defaulting/override.
tests/chains/ZkSyncV2/TWCoinTypeTests.cpp Asserts native token name for zkSync Era.
tests/chains/ZkLinkNova/TWCoinTypeTests.cpp Asserts native token name for zkLink Nova.
tests/chains/Zilliqa/TWCoinTypeTests.cpp Asserts native token name for Zilliqa.
tests/chains/ZetaEVM/TWCoinTypeTests.cpp Asserts native token name for Zeta EVM.
tests/chains/ZenEON/TWCoinTypeTests.cpp Asserts native token name for Zen EON.
tests/chains/Zen/TWCoinTypeTests.cpp Asserts native token name for Zen (Horizen).
tests/chains/Zelcash/TWCoinTypeTests.cpp Asserts native token name for Flux (Zelcash).
tests/chains/Zcash/TWCoinTypeTests.cpp Asserts native token name for Zcash.
tests/chains/XRP/TWCoinTypeTests.cpp Asserts native token name for XRP.
tests/chains/xDai/TWCoinTypeTests.cpp Asserts native token name for xDai/Gnosis Chain.
tests/chains/WAX/TWCoinTypeTests.cpp Asserts native token name for WAX.
tests/chains/Waves/TWCoinTypeTests.cpp Asserts native token name for Waves.
tests/chains/Wanchain/TWCoinTypeTests.cpp Asserts native token name for Wanchain.
tests/chains/Viction/TWCoinTypeTests.cpp Asserts native token name for Viction.
tests/chains/Viacoin/TWCoinTypeTests.cpp Asserts native token name for Viacoin.
tests/chains/Verge/TWCoinTypeTests.cpp Asserts native token name for Verge.
tests/chains/VeChain/TWCoinTypeTests.cpp Asserts native token name for VeChain.
tests/chains/Tron/TWCoinTypeTests.cpp Asserts native token name for Tron.
tests/chains/ThunderToken/TWCoinTypeTests.cpp Asserts native token name for ThunderCore.
tests/chains/ThetaFuel/TWCoinTypeTests.cpp Asserts native token name for Theta Fuel.
tests/chains/Theta/TWCoinTypeTests.cpp Asserts native token name for Theta.
tests/chains/TheOpenNetwork/TWCoinTypeTests.cpp Asserts native token name for TON (“Gram”).
tests/chains/Tezos/TWCoinTypeTests.cpp Asserts native token name for Tezos.
tests/chains/TBinance/TWCoinTypeTests.cpp Asserts native token name for Binance testnet coin type.
tests/chains/Syscoin/TWCoinTypeTests.cpp Asserts native token name for Syscoin.
tests/chains/Sui/TWCoinTypeTests.cpp Asserts native token name for Sui.
tests/chains/Stratis/TWCoinTypeTests.cpp Asserts native token name for Stratis.
tests/chains/Stellar/TWCoinTypeTests.cpp Asserts native token name for Stellar.
tests/chains/Sonic/TWCoinTypeTests.cpp Asserts native token name for Sonic.
tests/chains/Solana/TWCoinTypeTests.cpp Asserts native token name for Solana.
tests/chains/SmartBitcoinCash/TWCoinTypeTests.cpp Asserts native token name for SmartBCH.
tests/chains/SeiEVM/TWCoinTypeTests.cpp Asserts native token name for Sei EVM.
tests/chains/Scroll/TWCoinTypeTests.cpp Asserts native token name for Scroll (Ethereum).
tests/chains/Rootstock/TWCoinTypeTests.cpp Asserts native token name for Rootstock.
tests/chains/Ronin/TWCoinTypeTests.cpp Asserts native token name for Ronin.
tests/chains/RobinhoodChain/TWCoinTypeTests.cpp Asserts native token name for Robinhood Chain (Ethereum).
tests/chains/Ravencoin/TWCoinTypeTests.cpp Asserts native token name for Ravencoin.
tests/chains/Qtum/TWCoinTypeTests.cpp Asserts native token name for Qtum.
tests/chains/Polymesh/TWCoinTypeTests.cpp Asserts native token name for Polymesh.
tests/chains/PolygonZkEvm/TWCoinTypeTests.cpp Asserts native token name for Polygon zkEVM (Ethereum).
tests/chains/Polygon/TWCoinTypeTests.cpp Asserts native token name for Polygon.
tests/chains/Polkadot/TWCoinTypeTests.cpp Asserts native token name for Polkadot.
tests/chains/POANetwork/TWCoinTypeTests.cpp Asserts native token name for POA Network.
tests/chains/Plasma/TWCoinTypeTests.cpp Asserts native token name for Plasma.
tests/chains/Pivx/TWCoinTypeTests.cpp Asserts native token name for Pivx.
tests/chains/Pactus/CoinTypeTests.cpp Asserts native token name for Pactus.
tests/chains/Optimism/TWCoinTypeTests.cpp Asserts native token name for Optimism (Ethereum).
tests/chains/OpBNBtestnet/TWCoinTypeTests.cpp Asserts native token name for OpBNB testnet (BNB).
tests/chains/Ontology/TWCoinTypeTests.cpp Asserts native token name for Ontology.
tests/chains/OKXChain/TWCoinTypeTests.cpp Asserts native token name for OKX Chain.
tests/chains/Oasis/TWCoinTypeTests.cpp Asserts native token name for Oasis.
tests/chains/NULS/TWCoinTypeTests.cpp Asserts native token name for NULS.
tests/chains/Nimiq/TWCoinTypeTests.cpp Asserts native token name for Nimiq.
tests/chains/Nervos/TWCoinTypeTests.cpp Asserts native token name for Nervos (“Nervos Network”).
tests/chains/Neon/TWCoinTypeTests.cpp Asserts native token name for Neon.
tests/chains/NEO/TWCoinTypeTests.cpp Asserts native token name for NEO.
tests/chains/Nebulas/TWCoinTypeTests.cpp Asserts native token name for Nebulas.
tests/chains/Nebl/TWCoinTypeTests.cpp Asserts native token name for Nebl (“Neblio”).
tests/chains/NEAR/TWCoinTypeTests.cpp Asserts native token name for NEAR.
tests/chains/NativeZetaChain/TWCoinTypeTests.cpp Asserts native token name for NativeZetaChain (“ZetaChain”).
tests/chains/Nano/TWCoinTypeTests.cpp Asserts native token name for Nano.
tests/chains/MultiversX/TWCoinTypeTests.cpp Asserts native token name for MultiversX.
tests/chains/Moonriver/TWCoinTypeTests.cpp Asserts native token name for Moonriver.
tests/chains/Moonbeam/TWCoinTypeTests.cpp Asserts native token name for Moonbeam.
tests/chains/Monad/TWCoinTypeTests.cpp Asserts native token name for Monad.
tests/chains/Monacoin/TWCoinTypeTests.cpp Asserts native token name for Monacoin.
tests/chains/Metis/TWCoinTypeTests.cpp Asserts native token name for Metis.
tests/chains/Meter/TWCoinTypeTests.cpp Asserts native token name for Meter.
tests/chains/Merlin/TWCoinTypeTests.cpp Asserts native token name for Merlin.
tests/chains/MegaETH/TWCoinTypeTests.cpp Asserts native token name for MegaETH.
tests/chains/Mantle/TWCoinTypeTests.cpp Asserts native token name for Mantle.
tests/chains/MantaPacific/TWCoinTypeTests.cpp Asserts native token name for Manta Pacific (Ethereum).
tests/chains/Litecoin/TWCoinTypeTests.cpp Asserts native token name for Litecoin.
tests/chains/Linea/TWCoinTypeTests.cpp Asserts native token name for Linea (Ethereum).
tests/chains/Lightlink/TWCoinTypeTests.cpp Asserts native token name for Lightlink Phoenix.
tests/chains/Kusama/TWCoinTypeTests.cpp Asserts native token name for Kusama.
tests/chains/KuCoinCommunityChain/TWCoinTypeTests.cpp Asserts native token name for KCC (“KuCoin Token”).
tests/chains/Komodo/TWCoinTypeTests.cpp Asserts native token name for Komodo.
tests/chains/Klaytn/TWCoinTypeTests.cpp Asserts native token name for Kaia.
tests/chains/Kin/TWCoinTypeTests.cpp Asserts native token name for Kin.
tests/chains/KavaEvm/TWCoinTypeTests.cpp Asserts native token name for KavaEvm (“Kava”).
tests/chains/IoTeX/TWCoinTypeTests.cpp Asserts native token name for IoTeX.
tests/chains/IOST/TWCoinTypeTests.cpp Asserts native token name for IOST.
tests/chains/InternetComputer/TWCoinTypeTests.cpp Asserts native token name for Internet Computer.
tests/chains/ICON/TWCoinTypeTests.cpp Asserts native token name for ICON.
tests/chains/HyperEVM/TWCoinTypeTests.cpp Asserts native token name for HyperEVM (“Hyperliquid”).
tests/chains/Hedera/TWCoinTypeTests.cpp Asserts native token name for Hedera.
tests/chains/Harmony/TWCoinTypeTests.cpp Asserts native token name for Harmony.
tests/chains/Groestlcoin/TWCoinTypeTests.cpp Asserts native token name for Groestlcoin.
tests/chains/Greenfield/TWCoinTypeTests.cpp Asserts native token name for Greenfield (BNB).
tests/chains/GoChain/TWCoinTypeTests.cpp Asserts native token name for GoChain.
tests/chains/Firo/TWCoinTypeTests.cpp Asserts native token name for Firo.
tests/chains/FIO/TWCoinTypeTests.cpp Asserts native token name for FIO.
tests/chains/Filecoin/TWCoinTypeTests.cpp Asserts native token name for Filecoin.
tests/chains/Fantom/TWCoinTypeTests.cpp Asserts native token name for Fantom.
tests/chains/Evmos/TWCoinTypeTests.cpp Asserts native token name for Evmos.
tests/chains/Everscale/TWCoinTypeTests.cpp Asserts native token name for Everscale.
tests/chains/EthereumClassic/TWCoinTypeTests.cpp Asserts native token name for Ethereum Classic.
tests/chains/Ethereum/TWCoinTypeTests.cpp Asserts native token name for Ethereum.
tests/chains/EOS/TWCoinTypeTests.cpp Asserts native token name for EOS.
tests/chains/ECO/TWCoinTypeTests.cpp Asserts native token name for Huobi ECO Chain.
tests/chains/ECash/TWCoinTypeTests.cpp Asserts native token name for eCash.
tests/chains/Dydx/TWCoinTypeTests.cpp Asserts native token name for dYdX.
tests/chains/Dogecoin/TWCoinTypeTests.cpp Asserts native token name for Dogecoin.
tests/chains/DigiByte/TWCoinTypeTests.cpp Asserts native token name for DigiByte.
tests/chains/Decred/TWCoinTypeTests.cpp Asserts native token name for Decred.
tests/chains/Dash/TWCoinTypeTests.cpp Asserts native token name for Dash.
tests/chains/Cronos/TWCoinTypeTests.cpp Asserts native token name for Cronos Chain.
tests/chains/Cosmos/Umee/TWCoinTypeTests.cpp Asserts native token name for Umee.
tests/chains/Cosmos/TWCoinTypeTests.cpp Asserts native token name for Cosmos Hub (“Cosmos”).
tests/chains/Cosmos/Tia/TWCoinTypeTests.cpp Asserts native token name for Celestia.
tests/chains/Cosmos/THORChain/TWCoinTypeTests.cpp Asserts native token name for THORChain.
tests/chains/Cosmos/TerraV2/TWCoinTypeTests.cpp Asserts native token name for Terra v2.
tests/chains/Cosmos/Terra/TWCoinTypeTests.cpp Asserts native token name for Terra Classic.
tests/chains/Cosmos/Stride/TWCoinTypeTests.cpp Asserts native token name for Stride.
tests/chains/Cosmos/Sommelier/TWCoinTypeTests.cpp Asserts native token name for Sommelier.
tests/chains/Cosmos/Sei/TWCoinTypeTests.cpp Asserts native token name for Sei.
tests/chains/Cosmos/Secret/TWCoinTypeTests.cpp Asserts native token name for Secret Network.
tests/chains/Cosmos/Quasar/TWCoinTypeTests.cpp Asserts native token name for Quasar.
tests/chains/Cosmos/Persistence/TWCoinTypeTests.cpp Asserts native token name for Persistence.
tests/chains/Cosmos/Osmosis/TWCoinTypeTests.cpp Asserts native token name for Osmosis.
tests/chains/Cosmos/Noble/TWCoinTypeTests.cpp Asserts native token name for Noble.
tests/chains/Cosmos/Neutron/TWCoinTypeTests.cpp Asserts native token name for Neutron.
tests/chains/Cosmos/NativeInjective/TWCoinTypeTests.cpp Asserts native token name for Native Injective (“Injective”).
tests/chains/Cosmos/NativeEvmos/TWCoinTypeTests.cpp Asserts native token name for Native Evmos (“Evmos”).
tests/chains/Cosmos/NativeCanto/TWCoinTypeTests.cpp Asserts native token name for Native Canto (“Canto”).
tests/chains/Cosmos/Mars/TWCoinTypeTests.cpp Asserts native token name for Mars Hub.
tests/chains/Cosmos/Kujira/TWCoinTypeTests.cpp Asserts native token name for Kujira.
tests/chains/Cosmos/Kava/TWCoinTypeTests.cpp Asserts native token name for Kava.
tests/chains/Cosmos/Juno/TWCoinTypeTests.cpp Asserts native token name for Juno.
tests/chains/Cosmos/FetchAI/TWCoinTypeTests.cpp Asserts native token name for FetchAI (“Fetch.ai”).
tests/chains/Cosmos/CryptoOrg/TWCoinTypeTests.cpp Asserts native token name for Crypto.org (“Cronos”).
tests/chains/Cosmos/Crescent/TWCoinTypeTests.cpp Asserts native token name for Crescent.
tests/chains/Cosmos/Coreum/TWCoinTypeTests.cpp Asserts native token name for Coreum.
tests/chains/Cosmos/Comdex/TWCoinTypeTests.cpp Asserts native token name for Comdex.
tests/chains/Cosmos/Bluzelle/TWCoinTypeTests.cpp Asserts native token name for Bluzelle.
tests/chains/Cosmos/BandChain/TWCoinTypeTests.cpp Asserts native token name for BandChain (“Band Protocol”).
tests/chains/Cosmos/Axelar/TWCoinTypeTests.cpp Asserts native token name for Axelar.
tests/chains/Cosmos/Akash/TWCoinTypeTests.cpp Asserts native token name for Akash.
tests/chains/Cosmos/Agoric/TWCoinTypeTests.cpp Asserts native token name for Agoric.
tests/chains/ConfluxeSpace/TWCoinTypeTests.cpp Asserts native token name for Conflux eSpace (“Conflux”).
tests/chains/Celo/TWCoinTypeTests.cpp Asserts native token name for Celo.
tests/chains/Cardano/TWCoinTypeTests.cpp Asserts native token name for Cardano.
tests/chains/Callisto/TWCoinTypeTests.cpp Asserts native token name for Callisto (“Callisto Network”).
tests/chains/BounceBit/TWCoinTypeTests.cpp Asserts native token name for BounceBit.
tests/chains/Boba/TWCoinTypeTests.cpp Asserts native token name for Boba.
tests/chains/Blast/TWCoinTypeTests.cpp Asserts native token name for Blast (Ethereum).
tests/chains/BitcoinGold/TWCoinTypeTests.cpp Asserts native token name for Bitcoin Gold.
tests/chains/BitcoinDiamond/TWCoinTypeTests.cpp Asserts native token name for Bitcoin Diamond.
tests/chains/BitcoinCash/TWCoinTypeTests.cpp Asserts native token name for Bitcoin Cash.
tests/chains/Bitcoin/TWCoinTypeTests.cpp Asserts native token name for Bitcoin.
tests/chains/BinanceSmartChain/TWCoinTypeTests.cpp Asserts native token name for BNB Smart Chain + legacy (BNB).
tests/chains/Binance/TWCoinTypeTests.cpp Asserts native token name for BNB Beacon Chain (BNB).
tests/chains/Base/TWCoinTypeTests.cpp Asserts native token name for Base (Ethereum).
tests/chains/Avalanche/TWCoinTypeTests.cpp Asserts native token name for Avalanche C-Chain (“Avalanche”).
tests/chains/Aurora/TWCoinTypeTests.cpp Asserts native token name for Aurora (Ethereum).
tests/chains/ArbitrumNova/TWCoinTypeTests.cpp Asserts native token name for Arbitrum Nova (Ethereum).
tests/chains/Arbitrum/TWCoinTypeTests.cpp Asserts native token name for Arbitrum (Ethereum).
tests/chains/Aptos/TWCoinTypeTests.cpp Asserts native token name for Aptos.
tests/chains/Algorand/TWCoinTypeTests.cpp Asserts native token name for Algorand.
tests/chains/Aion/TWCoinTypeTests.cpp Asserts native token name for Aion.
tests/chains/Aeternity/TWCoinTypeTests.cpp Asserts native token name for Aeternity.
tests/chains/AcalaEVM/TWCoinTypeTests.cpp Asserts native token name for Acala EVM (“Acala”).
tests/chains/Acala/TWCoinTypeTests.cpp Asserts native token name for Acala.
src/Coin.h Extends CoinInfo with nativeTokenName.
src/Coin.cpp Adds TWCoinTypeConfigurationGetNativeTokenName implementation.
registry.json Adds nativeTokenName entries for many coins.
include/TrustWalletCore/TWCoinTypeConfiguration.h Adds public C API declaration + docs for native token name.
codegen/lib/templates/TWCoinTypeTests.cpp.erb Updates legacy test template to validate native token name.
codegen/lib/templates/CoinInfoData.cpp.erb Updates legacy coin info template to emit native token name field.
codegen/lib/coin_test_gen.rb Adds Ruby helper for nativeTokenName fallback generation.
codegen/bin/coins Adds Ruby helper for nativeTokenName fallback generation.
codegen-v2/src/registry.rs Extends CoinItem with nativeTokenName registry field.
codegen-v2/src/codegen/template_generator.rs Adds {NATIVE_TOKEN_NAME} substitution with fallback chain.
codegen-v2/src/codegen/cpp/templates/TWCoinTypeTests.cpp Updates codegen-v2 C++ tests template to assert native token name.
codegen-v2/manifest/TWCoinTypeConfiguration.yaml Exposes TWCoinTypeConfigurationGetNativeTokenName in the API manifest for bindings/codegen.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/interface/TWCoinTypeTests.cpp
@github-actions

Copy link
Copy Markdown

Binary size comparison

➡️ aarch64-apple-ios:

- 14.31 MB
+ 14.31 MB 	 +2 KB

➡️ aarch64-apple-ios-sim:

- 14.31 MB
+ 14.31 MB 	 +2 KB

➡️ aarch64-linux-android:

- 18.73 MB
+ 18.73 MB 	 +1 KB

➡️ armv7-linux-androideabi:

- 16.17 MB
+ 16.17 MB 	 +1 KB

➡️ wasm32-unknown-emscripten:

- 13.66 MB
+ 13.66 MB 	 +1 KB

@sergei-boiko-trustwallet

sergei-boiko-trustwallet commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

[bc-check: Pass]

BC-risk audit — feat/native-token-name → master @ 56969a5 — 2026-07-27T08:47:25Z

Verdict: SAFE

This PR adds a new optional nativeTokenName field end-to-end (registry.jsonCoinInfo struct → new TWCoinTypeConfigurationGetNativeTokenName C ABI getter → codegen templates/tests), and it is purely additive at every layer. Confirmed via diff inspection: zero modifications to existing registry.json
keys (slip44, curve, derivation, address-encoding all untouched — 44 insertions, 0 deletions/edits), zero changes to the TWCoinType enum, zero changes to any existing C ABI function's signature or error behavior, and zero touches to any .proto, Keystore, PrivateKey/PublicKey, or HDWallet file. CoinInfo
(which gained the new struct field) is an internal-only type never exposed via include/TrustWalletCore/, and is rebuilt fresh at compile time, so the field-order change has no runtime cross-version implications. No mitigation needed.

@octane-security-app

Copy link
Copy Markdown

Overview

Vulnerabilities found: 3                                                                                
Severity breakdown: 2 Low, 1 Informational
Warnings found: 1                                                                                

Detailed findings

codegen-v2/src/codegen/template_generator.rs

  • Unbounded replacement cloning with {NATIVE_TOKEN_NAME} fallback in codegen-v2 TemplateGenerator causes CI memory DoS. See more
  • Unescaped nativeTokenName placeholder in codegen-v2 test generation causes code injection in generated C++ tests. See more

include/TrustWalletCore/TWCoinTypeConfiguration.h

  • Ambiguous nativeTokenName exposure in TWCoinTypeConfigurationGetNativeTokenName causes host app chain-authorization/budget bypass. See more

Warnings

include/TrustWalletCore/TWCoinTypeConfiguration.h

  • Ambiguous TWString ownership in TWCoinTypeConfigurationGetNativeTokenName causes DoS via memory leak. See more

🔗 Commit Hash: 56969a5
🛡️ Octane Dashboard: All vulnerabilities

@sonarqubecloud

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@BSCSecChef BSCSecChef left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@sergei-boiko-trustwallet
sergei-boiko-trustwallet merged commit 12f09ab into master Jul 27, 2026
18 of 20 checks passed
@sergei-boiko-trustwallet
sergei-boiko-trustwallet deleted the feat/native-token-name branch July 27, 2026 12:54
@sergei-boiko-trustwallet sergei-boiko-trustwallet changed the title feat: add native token name support to CoinInfo structure and related functions [sc-150250]: add native token name support to CoinInfo structure and related functions Jul 28, 2026
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.

4 participants