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

Fix build and run issues with --disable-wallet configuration #1492

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

levoncrypto
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Oct 27, 2024

Walkthrough

The changes in this pull request involve updates across three files: bitcoinaddressvalidator.h, bitcoingui.cpp, and coincontrol.h. The bitcoinaddressvalidator.h file introduces conditional compilation for wallet functionality. The bitcoingui.cpp file modifies the resizeEvent method to include null checks for toolbar action widgets, enhancing robustness. Lastly, coincontrol.h adds an include directive for base58.h, without altering existing functionality or interfaces.

Changes

File Path Change Summary
src/qt/bitcoinaddressvalidator.h Added #ifdef ENABLE_WALLET directive for conditional inclusion of sparkwallet.h.
src/qt/bitcoingui.cpp Modified resizeEvent method to include null checks for toolbar action widgets; removed commented-out code.
src/wallet/coincontrol.h Added #include "base58.h" directive; no changes to existing functionality or interfaces.

Possibly related PRs

  • Qt scaling fix #1437: The changes in the main PR regarding conditional compilation in bitcoinaddressvalidator.h are not directly related to the UI scaling fixes in the retrieved PR, which focuses on resizeEvent methods in various UI components.

Poem

In the code where rabbits play,
Wallets hop in, come what may.
Null checks guard the GUI's dance,
While base58 takes a chance.
Clean and neat, the changes flow,
A tidy burrow, watch it grow! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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.

@levoncrypto levoncrypto removed the request for review from firstcryptoman October 27, 2024 12:24
Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9fecae3 and 60a9ef9.

📒 Files selected for processing (3)
  • src/qt/bitcoinaddressvalidator.h (1 hunks)
  • src/qt/bitcoingui.cpp (1 hunks)
  • src/wallet/coincontrol.h (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/wallet/coincontrol.h
🔇 Additional comments (2)
src/qt/bitcoinaddressvalidator.h (1)

14-14: Verify if spark/state.h requires conditional compilation.

The unconditional inclusion of "../spark/state.h" might need to be wrapped with ENABLE_WALLET if it contains wallet-specific functionality.

Let's check the contents and dependencies of state.h:

#!/bin/bash
# Search for wallet-specific includes or dependencies in state.h
rg -l "wallet" -- "**/spark/state.h"

# Check if state.h is included in other wallet-disabled contexts
rg -l "state\.h" -- "**/spark/**/*.h" "**/spark/**/*.cpp" | xargs rg "ENABLE_WALLET"
src/qt/bitcoingui.cpp (1)

1486-1499: LGTM! Good defensive programming practice.

The changes add proper null checks before accessing toolbar action widgets, which prevents potential crashes in --disable-wallet mode. The implementation correctly:

  1. Checks each action widget's existence before accessing it
  2. Maintains the same width calculation logic
  3. Safely handles cases where actions may not be available

Comment on lines +10 to +12
#ifdef ENABLE_WALLET
#include "../spark/sparkwallet.h"
#endif
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Let me analyze the results. The search shows that validateSparkAddress is used extensively throughout the codebase, particularly in wallet-related functionality:

  1. It's used in src/wallet/wallet.cpp for address book operations
  2. It's used in src/qt/walletmodel.cpp for transaction validation and address book management
  3. It's used in src/qt/transactiondesc.cpp for transaction descriptions
  4. It's used in src/qt/sendcoinsentry.cpp and src/qt/sendcoinsdialog.cpp for sending coins
  5. It's used in src/qt/addresstablemodel.cpp for address validation

All these usages are in wallet-related code that is already properly guarded with ENABLE_WALLET. The function is clearly part of the wallet functionality and should be conditionally compiled.

Wrap validateSparkAddress method with ENABLE_WALLET to ensure proper compilation when wallet is disabled.

The validateSparkAddress method is used exclusively within wallet-related code paths and depends on wallet functionality. It should be conditionally compiled to maintain consistency with the --disable-wallet build configuration.

🔗 Analysis chain

Consider wrapping validateSparkAddress method with ENABLE_WALLET.

While the conditional inclusion of sparkwallet.h is correct, the validateSparkAddress method in BitcoinAddressCheckValidator might also need to be conditionally compiled if it depends on wallet functionality. This would ensure complete isolation of wallet-related code when building with --disable-wallet.

Let's verify if validateSparkAddress uses any wallet-specific functionality:

Consider wrapping the method declaration with ENABLE_WALLET:

 class BitcoinAddressCheckValidator : public QValidator
 {
     Q_OBJECT
 
 public:
     explicit BitcoinAddressCheckValidator(QObject *parent);
 
     State validate(QString &input, int &pos) const;
 
+#ifdef ENABLE_WALLET
     bool validateSparkAddress(const std::string& address) const;
+#endif
 };
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for validateSparkAddress implementation and its dependencies
ast-grep --pattern 'bool BitcoinAddressCheckValidator::validateSparkAddress($_) { $$$ }'

# Search for any references to wallet-specific types or functions within validateSparkAddress
rg -A 5 "validateSparkAddress.*\{" 

Length of output: 15300

@levonpetrosyan93 levonpetrosyan93 merged commit c03c847 into master Nov 29, 2024
11 checks passed
@levonpetrosyan93 levonpetrosyan93 deleted the disable_wallet_fix branch November 29, 2024 12:14
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