Skip to content

Conversation

@pankcuf
Copy link
Contributor

@pankcuf pankcuf commented Mar 24, 2025

This pull request introduces a new feature for supporting CoinJoin paths in the Dash project. The major changes include adding new constants, modifying existing enums, and adding new methods and tests to handle the CoinJoin functionality.

New feature for CoinJoin paths:

  • dash/src/dip9.rs: Added new constants FEATURE_PURPOSE_COINJOIN, COINJOIN_PATH_MAINNET, and COINJOIN_PATH_TESTNET to define CoinJoin paths for both mainnet and testnet. [1] [2]
  • dash/src/dip9.rs: Updated the DerivationPathReference enum to include a new variant CoinJoin.

Modifications to existing files:

  • dash/src/bip32.rs: Updated the imports to include the new CoinJoin paths and added a new method coinjoin_path in the DerivationPath implementation to generate CoinJoin paths based on the network and account. [1] [2]

Testing:

  • dash/src/bip32.rs: Added a new test test_coinjoin_path to verify the correctness of the CoinJoin path generation.

Version bump:

  • Cargo.toml: Updated the package version from 0.38.0 to 0.38.1 to reflect the new feature addition.

Summary by CodeRabbit

  • Chores

    • Updated the package version to 0.39.1.
  • New Features

    • Introduced coinjoin transaction support to enhance wallet functionality, allowing more precise handling of transaction paths across different networks.
    • Added a new method for generating coinjoin paths based on network and account.
    • Introduced new constants for CoinJoin transaction paths on mainnet and testnet.
    • Added a new variant for CoinJoin in the derivation path reference.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2025

Walkthrough

The pull request updates the workspace version in the Cargo.toml file and introduces a new feature to generate coinjoin paths. A new method coinjoin_path is added to the DerivationPath implementation in dash/src/bip32.rs along with corresponding unit tests. The dash/src/dip9.rs file is also updated to include a new enum variant CoinJoin and constants for coinjoin derivation paths on both mainnet and testnet.

Changes

File(s) Change Summary
Cargo.toml Updated version from "0.38.0" to "0.39.1" in the [workspace.package] section.
dash/src/bip32.rs Added pub fn coinjoin_path(network: Network, account: u32) -> Self method and its unit test #[test] fn test_coinjoin_path(); consolidated imports for related constants.
dash/src/dip9.rs Introduced CoinJoin variant in DerivationPathReference, added constant FEATURE_PURPOSE_COINJOIN, and defined COINJOIN_PATH_MAINNET & COINJOIN_PATH_TESTNET for coinjoin transactions.

Sequence Diagram(s)

sequenceDiagram
    participant C as Caller
    participant D as DerivationPath
    participant DIP9 as DIP9 Constants
    C->>D: call coinjoin_path(network, account)
    D->>D: Check network type
    alt Network is Dash
        D->>D: Use COINJOIN_PATH_MAINNET (from DIP9)
    else Other Network
        D->>D: Use COINJOIN_PATH_TESTNET (from DIP9)
    end
    D->>D: Extend path with hardened account index
    D-->>C: Return updated derivation path
Loading

Suggested reviewers

  • QuantumExplorer

Poem

Hop, hop, I scurry with glee,
A version update and a new method for me.
Coinjoin paths now gracefully chase,
Through dashed codes, setting the pace.
With constants shining in the code's night,
A rabbit's tune brings joyful light!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
dash/src/bip32.rs (1)

492-503: New coinjoin_path method looks good but lacks documentation.

The implementation correctly handles different networks and follows the same design pattern as other derivation path methods. It builds a path based on the network type and appends the hardened account index.

However, adding documentation comments to describe the purpose and usage of this method would improve maintainability.

+    /// Returns a derivation path for CoinJoin operations
+    /// 
+    /// The path follows the pattern m/9'/5'/4'/account' for mainnet and
+    /// m/9'/1'/4'/account' for testnet networks where account is hardened.
     pub fn coinjoin_path(
         network: Network,
         account: u32,
     ) -> Self {
         let mut root_derivation_path: DerivationPath = match network {
             Network::Dash => COINJOIN_PATH_MAINNET,
             _ => COINJOIN_PATH_TESTNET,
         }
         .into();
         root_derivation_path.0.extend(&[ChildNumber::Hardened { index: account }]);
         root_derivation_path
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee911aa and 9a9d680.

📒 Files selected for processing (2)
  • dash/src/bip32.rs (3 hunks)
  • dash/src/dip9.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • dash/src/dip9.rs
🔇 Additional comments (2)
dash/src/bip32.rs (2)

39-39: Import statement updated to include coinjoin path constants.

The import statement has been modified to include the new COINJOIN_PATH_MAINNET and COINJOIN_PATH_TESTNET constants from dip9.rs. This is aligned with the PR objective to support CoinJoin derivation paths.


2069-2076: Test coverage for coinjoin_path is sufficient.

The test validates the generation of CoinJoin paths for both mainnet and testnet networks with different account indices, ensuring that the paths are correctly constructed. It follows the same pattern as other derivation path tests in this file.

Copy link
Member

@QuantumExplorer QuantumExplorer left a comment

Choose a reason for hiding this comment

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

@QuantumExplorer QuantumExplorer merged commit 4f0f9b9 into master Mar 25, 2025
2 of 17 checks passed
@QuantumExplorer QuantumExplorer deleted the feat/coinjoin-derivation-path branch October 20, 2025 08:25
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.

3 participants