Skip to content

Conversation

@levonpetrosyan93
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2026

Walkthrough

The getAddress() method in sparkwallet.cpp now uses the requested index to generate a fallback address when the requested address index is not already cached, instead of using the last known diversifier. This alters the address selection behavior for out-of-range or uncached address requests.

Changes

Cohort / File(s) Summary
Address index fallback logic
src/spark/sparkwallet.cpp
Modified getAddress() to return spark::Address(viewKey, i) using the requested index i as the fallback instead of using lastDiversifier, changing how missing addresses are generated

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • psolstice
  • aleflm

Poem

🐰 A diversifier's fate took a turn,
No more reaching back to what we'd learned,
The index itself now leads the way,
Fresh addresses bloom where we ask them to play!
Spark wallet adapts with a hop and a bound,
Better fallback logic has been found! ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is completely empty, missing the mandatory 'PR intention' section that should explain what the PR does and what issue it solves. Add a PR description with at least the mandatory 'PR intention' section explaining the bug being fixed and how the change resolves it.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main bug fix in the changeset: correcting the wrong address returned by getAddress() in the spark wallet, which directly addresses the getsparkcoinaddr output issue.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch addr_bug_fixed

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68681e7 and 1ad0b90.

📒 Files selected for processing (1)
  • src/spark/sparkwallet.cpp
🧰 Additional context used
🧬 Code graph analysis (1)
src/spark/sparkwallet.cpp (1)
src/libspark/keys.cpp (3)
  • Address (143-143)
  • Address (145-147)
  • Address (149-156)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: build-guix-aarch64-linux-gnu
  • GitHub Check: build-linux-cmake
  • GitHub Check: build-guix-x86_64-apple-darwin
  • GitHub Check: build-windows-cmake
  • GitHub Check: build-mac-cmake
  • GitHub Check: build-guix-x86_64-linux-gnu
  • GitHub Check: build-guix-arm64-apple-darwin
  • GitHub Check: build-guix-x86_64-w64-mingw32
  • GitHub Check: build-guix-x86_64-apple-darwin
  • GitHub Check: build-mac-cmake
  • GitHub Check: build-windows-cmake
  • GitHub Check: build-guix-arm64-apple-darwin
  • GitHub Check: build-guix-x86_64-linux-gnu
  • GitHub Check: build-guix-aarch64-linux-gnu
  • GitHub Check: build-linux-cmake
  • GitHub Check: build-guix-x86_64-w64-mingw32
🔇 Additional comments (1)
src/spark/sparkwallet.cpp (1)

277-282: Critical bug fix: Address derivation now uses requested index instead of last diversifier.

The previous code returned an address generated with lastDiversifier when the address wasn't cached, instead of returning the address for the requested index i. This caused:

  • isAddressMine() (line 310) to incorrectly verify addresses
  • getMyCoinAddress() (line 587) to return wrong addresses for coins

The fix is correct—getAddress(i) now properly returns the address at index i, which aligns with the deterministic address derivation from IncomingViewKey. The method appropriately maintains read-only semantics without caching or modifying lastDiversifier.


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 and usage tips.

@coderabbitai coderabbitai bot requested review from aleflm and psolstice January 3, 2026 00:27
@reubenyap reubenyap merged commit 4b1ae53 into master Jan 6, 2026
29 of 30 checks passed
@reubenyap reubenyap deleted the addr_bug_fixed branch January 6, 2026 09:31
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.

5 participants