Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(connect): enable taproot in connect discovery #16917

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

martykan
Copy link
Member

Description

Taproot accounts have been commented out in Connect discovery.
Now we shouldn't have any blockers, so this PR enables them.

@martykan martykan added the connect Connect API related (ie. fee calculation) label Feb 11, 2025
@martykan martykan marked this pull request as ready for review February 11, 2025 11:26
Copy link

coderabbitai bot commented Feb 11, 2025

Walkthrough

This pull request updates the discovery process in the API by modifying the logic in the Discovery class. The change specifically targets the handling of discovery types by incorporating the taproot/p2tr type. Previously commented code for including the taproot type has been uncommented and modified so that when the coinInfo.taproot condition is true, the taproot discovery type is added to the discovery types array. Aside from this adjustment for taproot support, the remainder of the processing logic remains unchanged, with no alterations made to the declarations of exported or public entities.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 65583b2 and 1fd29d4.

📒 Files selected for processing (1)
  • packages/connect/src/api/common/Discovery.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: methods / core_in_popup
  • GitHub Check: run_android_e2e_tests
🔇 Additional comments (3)
packages/connect/src/api/common/Discovery.ts (3)

61-92: Well-structured integration of Taproot discovery.

The implementation maintains a clear progression of address types from newest (bech32) to oldest (legacy), with Taproot appropriately positioned between native SegWit and wrapped SegWit. This ordering aligns with the natural evolution of Bitcoin address types.


73-79: LGTM! Taproot implementation follows best practices.

The implementation correctly:

  • Uses BIP86 purpose (86) for Taproot derivation
  • Checks for taproot support via coinInfo.taproot
  • Maintains proper ordering of discovery types

Let's verify that the taproot implementation aligns with BIP86 specification:

✅ Verification successful

🌐 Web query:

What is the correct derivation path purpose for Bitcoin Taproot (BIP86)?

💡 Result:

The correct derivation path purpose for Bitcoin Taproot (BIP86) is 86', which appears as the first level in hierarchical deterministic (HD) wallet paths. This standardized format ensures compatibility across wallets generating Taproot addresses[1][3][4][7].

Key Details

  • Structure: BIP86 uses m/86'/coin_type'/account'/change/address_index where:

    • m = master key
    • 86' = hardened purpose field (BIP86)
    • 0' = Bitcoin mainnet coin type
    • Subsequent levels control accounts and addresses[3][4]
  • Implementation Examples:

    • First Taproot address: m/86'/0'/0'/0/0
    • Fifth address in account 3: m/86'/0'/2'/0/4
    • Change address: m/86'/0'/0'/1/0[4][7]
  • Security: The apostrophe (') denotes hardened derivation at purpose/coin/account levels, preventing public key exposure from compromising parent keys[1][3].

This standardized approach allows wallets like Ledger and Leather to generate interoperable Taproot addresses while maintaining backward compatibility with BIP32/BIP44 systems[5][7].

Citations:


LGTM! Taproot discovery implementation verified.

  • Confirmed that the correct derivation path purpose for Bitcoin Taproot is 86' (with the hardened notation), and passing the integer 86 to getDescriptor is consistent with how other discovery types are handled.
  • The conditional check on coinInfo.taproot and subsequent binding of the purpose value are correctly implemented.

74-74: Implementation aligns with PR objectives.

The conditional check on coinInfo.taproot provides a clean way to enable/disable Taproot support, meeting the PR's goal of enabling Taproot accounts in Connect discovery.

Let's verify that the taproot feature flag is properly defined:

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Description: Check if coinInfo.taproot is properly defined in the type definitions

# Search for taproot in type definitions
rg -A 5 "interface.*CoinInfo" | rg -A 5 "taproot"

Length of output: 49


Let's perform a deeper search for the taproot property inside any CoinInfo type/interface definitions. We can run a slightly broader search with additional context to see if any such definition exists within the repository:

If this script still returns no output, it would be best to manually verify that the coinInfo.taproot flag is correctly defined in the type definitions (or elsewhere if defined dynamically) to ensure full type safety and alignment with the PR objectives.

Please run the above script and check for the presence of the taproot property in the CoinInfo definition. If it isn’t defined, a manual review might be necessary to decide whether to add the property definition.


🏁 Script executed:

[run_scripts]
#!/bin/bash
# Search for the definition of CoinInfo and see if it contains a taproot property
rg "interface\s+CoinInfo" -A 25 | grep -i taproot

Length of output: 173


Taproot flag usage meets discovery objectives, but its type definition wasn’t found.

The implementation enables Taproot discovery based on the coinInfo.taproot flag, aligning with the PR objective. However, our searches did not reveal any explicit declaration of the taproot property within the CoinInfo type/interface. Please manually verify that this property is defined (or intentionally left dynamic) in the type definitions to ensure complete type-safety and consistency with the rest of the codebase.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@martykan martykan merged commit b1ea07e into develop Feb 12, 2025
56 of 57 checks passed
@martykan martykan deleted the chore/enable-taproot-in-connect-discovery branch February 12, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connect Connect API related (ie. fee calculation)
Projects
Status: 🤝 Needs QA
Development

Successfully merging this pull request may close these issues.

2 participants