Skip to content

feat(thorchain): allow any denom in ThorchainMsgSend with validation#237

Open
BitHighlander wants to merge 4 commits into
developfrom
feat/thorchain-any-denom-clean
Open

feat(thorchain): allow any denom in ThorchainMsgSend with validation#237
BitHighlander wants to merge 4 commits into
developfrom
feat/thorchain-any-denom-clean

Conversation

@BitHighlander
Copy link
Copy Markdown
Owner

Summary

Three-commit series enabling TCY, RUJIRA, and other native THORChain assets:

  1. Any-denom: Add optional denom field to ThorchainMsgSend proto. Defaults to rune when absent for backwards compat. Bumps deps/device-protocol.
  2. Charset validation: Reject denoms with characters outside [A-Z0-9.-/] to prevent display spoofing.
  3. Display separation: Show amount and asset on separate confirmation screens.

Test plan

  • CI green (includes new unit test vectors)
  • TCY send signs correctly
  • RUNE send still works (no denom field — backwards compat)

Previously the send path hardcoded "rune" as the coin denom in both the
JSON signing payload and the on-device confirmation screen. This blocked
signing of any other native THORChain L1 asset.

Changes:
- deps/device-protocol: add optional string denom = 11 to ThorchainMsgSend
- messages-thorchain.options: add ThorchainMsgSend.denom max_size:69
- thorchain.h/c: add denom param to thorchain_signTxUpdateMsgSend;
  default to "rune" when absent (backward compat); split JSON write
  to avoid fixed 64-byte buffer overflow on long denoms
- fsm_msg_thorchain.h: display actual denom in confirmation, pass
  through to signing, update final confirm text to "THORChain transaction"
- thorchain.cpp: update existing call, add DefaultDenom/TCY/Rujira tests
- Add thorchain_isValidDenom() rejecting chars that need JSON escaping;
  valid set is [a-z0-9./\-], empty string rejected (caller uses "rune")
- Use tendermint_sha256UpdateEscaped for the denom write in MsgSend as
  defense-in-depth (validation is the primary guard)
- Register thorchain.cpp in CMakeLists.txt — it was never compiled, so
  all prior expected values were unvalidated placeholder text
- Replace wrong address/signature expected values with vectors derived
  from the actual trezor-crypto library (standalone C verification tool)
- Add ThorchainSignTxDefaultDenom: empty denom → same sig as explicit "rune"
- Add ThorchainDenomValidation: unit-tests thorchain_isValidDenom directly
- Add ThorchainSignTxInvalidDenom: quote-injection attempt returns false
…screens

High: amount_str[32] could not hold amount + long denom suffix, causing
bn_format_uint64 to silently return 0 and show a blank confirmation while
the full denom was still signed. Fixed by passing NULL suffix so amount_str
holds only the numeric part, then showing denom on its own "Asset" screen.

Low: untrusted denom was formatted and shown before thorchain_isValidDenom
ran in the signing layer. Moved explicit isValidDenom check to the top of
the send path so invalid strings are rejected before any UI is touched.
deps/device-protocol → 8ef74da (feat(ripple): memo + THORChain routing)
deps/python-keepkey  → bf870e6 (7.14.2: XRP memo + EVM depositWithExpiry + msg-signing)
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.

1 participant