Skip to content

Add Zano alias resolution to send flow#9393

Merged
omurovch merged 2 commits into
version/0.50from
zano-aliases
Jul 16, 2026
Merged

Add Zano alias resolution to send flow#9393
omurovch merged 2 commits into
version/0.50from
zano-aliases

Conversation

@omurovch

@omurovch omurovch commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added support for resolving Zano aliases to blockchain addresses.
    • Zano aliases can now be entered with an optional leading @.
    • Recognized aliases are validated, resolved through the network, and reused for faster subsequent lookups.
  • Bug Fixes

    • Invalid, malformed, unavailable, or unsuccessful alias responses are handled safely without producing an address.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Zano alias normalization and JSON-RPC address resolution, caches resolved addresses through a new address handler, and wires that handler into Zano address parsing with coverage for valid and invalid inputs.

Changes

Zano alias support

Layer / File(s) Summary
Alias RPC resolution and response parsing
walletkit/src/main/java/io/horizontalsystems/walletkit/core/address/ZanoAliasResolver.kt, walletkit/src/test/.../ZanoAliasTest.kt
ZanoAliasResolver sends JSON-RPC requests to the current Zano node and extracts successful alias addresses; tests cover error, missing, empty, and malformed responses.
Alias validation and cached address handling
walletkit/src/main/java/io/horizontalsystems/walletkit/modules/address/IAddressHandler.kt, walletkit/src/test/.../ZanoAliasTest.kt
AddressHandlerZanoAlias normalizes supported aliases, resolves uncached values, caches resulting addresses, and validates accepted and rejected alias formats.
Address handler registration and entry-flow wiring
walletkit/src/main/java/io/horizontalsystems/walletkit/modules/address/AddressHandlerFactory.kt, walletkit/src/main/java/io/horizontalsystems/walletkit/modules/enteraddress/EnterAddressViewModel.kt
Zano receives an alias handler in the domain handler factory and conditionally includes it in the address parser chain.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant EnterAddressViewModel
  participant AddressParserChain
  participant AddressHandlerZanoAlias
  participant ZanoAliasResolver
  participant ZanoNode
  EnterAddressViewModel->>AddressParserChain: create Zano parser chain
  AddressParserChain->>AddressHandlerZanoAlias: isSupported(alias)
  AddressHandlerZanoAlias->>ZanoAliasResolver: resolve(normalized alias)
  ZanoAliasResolver->>ZanoNode: JSON-RPC alias lookup
  ZanoNode-->>ZanoAliasResolver: alias response
  ZanoAliasResolver-->>AddressHandlerZanoAlias: address or null
  AddressHandlerZanoAlias-->>AddressParserChain: support result and cached address
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding Zano alias resolution to the send flow.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch zano-aliases

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@omurovch
omurovch merged commit f49bd4a into version/0.50 Jul 16, 2026
1 of 2 checks passed
@omurovch
omurovch deleted the zano-aliases branch July 16, 2026 12:05

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
walletkit/src/main/java/io/horizontalsystems/walletkit/core/address/ZanoAliasResolver.kt (1)

38-46: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoff

Synchronous network call can cause thread starvation.

This executes a blocking network request. When called from a coroutine on Dispatchers.Default (as it is via EnterAddressViewModel -> AddressParserChain), it blocks a CPU-bound thread, which can lead to thread starvation.

Consider refactoring the IAddressHandler contract to support suspend functions for address resolution, allowing this to use await() or withContext(Dispatchers.IO).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@walletkit/src/main/java/io/horizontalsystems/walletkit/core/address/ZanoAliasResolver.kt`
around lines 38 - 46, Refactor the IAddressHandler address-resolution contract
and its implementations, including ZanoAliasResolver, to use suspend functions.
Update AddressParserChain and EnterAddressViewModel call sites to propagate
suspension, and execute the blocking OkHttp request in ZanoAliasResolver with
withContext(Dispatchers.IO) (or an equivalent async await approach) so
Dispatchers.Default is not blocked.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@walletkit/src/main/java/io/horizontalsystems/walletkit/modules/address/IAddressHandler.kt`:
- Line 366: Replace the mutableMapOf-backed cache in the address handler with a
ConcurrentHashMap, preserving the existing String-to-Address cache behavior and
access patterns.

---

Nitpick comments:
In
`@walletkit/src/main/java/io/horizontalsystems/walletkit/core/address/ZanoAliasResolver.kt`:
- Around line 38-46: Refactor the IAddressHandler address-resolution contract
and its implementations, including ZanoAliasResolver, to use suspend functions.
Update AddressParserChain and EnterAddressViewModel call sites to propagate
suspension, and execute the blocking OkHttp request in ZanoAliasResolver with
withContext(Dispatchers.IO) (or an equivalent async await approach) so
Dispatchers.Default is not blocked.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 63a60ee3-9464-44b7-9908-852adea4e127

📥 Commits

Reviewing files that changed from the base of the PR and between 4b32556 and f49bd4a.

📒 Files selected for processing (5)
  • walletkit/src/main/java/io/horizontalsystems/walletkit/core/address/ZanoAliasResolver.kt
  • walletkit/src/main/java/io/horizontalsystems/walletkit/modules/address/AddressHandlerFactory.kt
  • walletkit/src/main/java/io/horizontalsystems/walletkit/modules/address/IAddressHandler.kt
  • walletkit/src/main/java/io/horizontalsystems/walletkit/modules/enteraddress/EnterAddressViewModel.kt
  • walletkit/src/test/java/io/horizontalsystems/walletkit/modules/address/ZanoAliasTest.kt


class AddressHandlerZanoAlias(private val resolver: ZanoAliasResolver) : IAddressHandler {
override val blockchainType = BlockchainType.Zano
private val cache = mutableMapOf<String, Address>()

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Data race on non-thread-safe map.

Since isSupported makes a blocking network call that doesn't cooperatively check for coroutine cancellation, typing quickly can spawn multiple coroutines that block simultaneously. When these network calls complete, they will write to this map concurrently from different threads on Dispatchers.Default, which can cause a ConcurrentModificationException or corrupt the map.

Use a ConcurrentHashMap to ensure thread safety.

🛠️ Proposed fix to ensure thread safety
-    private val cache = mutableMapOf<String, Address>()
+    private val cache = java.util.concurrent.ConcurrentHashMap<String, Address>()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private val cache = mutableMapOf<String, Address>()
private val cache = java.util.concurrent.ConcurrentHashMap<String, Address>()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@walletkit/src/main/java/io/horizontalsystems/walletkit/modules/address/IAddressHandler.kt`
at line 366, Replace the mutableMapOf-backed cache in the address handler with a
ConcurrentHashMap, preserving the existing String-to-Address cache behavior and
access patterns.

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