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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/qt/bitcoinaddressvalidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
#define BITCOIN_QT_BITCOINADDRESSVALIDATOR_H

#include <QValidator>

#ifdef ENABLE_WALLET
#include "../spark/sparkwallet.h"
#endif
Comment on lines +10 to +12
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


#include "../spark/state.h"

/** Base58 entry widget validator, checks for valid characters and
Expand Down
27 changes: 14 additions & 13 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1481,19 +1481,20 @@ void BitcoinGUI::resizeEvent(QResizeEvent* event) {

// Retrieve new dimensions from the resize event
int newWidth = event->size().width();
int newHeight = event->size().height();
int actionWidth = newWidth / 6;

// Set widths for each action dynamically
QWidget* overviewWidget = toolbar->widgetForAction(overviewAction);
QWidget* receiveWidget = toolbar->widgetForAction(receiveCoinsAction);
QWidget* historyWidget = toolbar->widgetForAction(historyAction);
QWidget* sendCoinsWidget = toolbar->widgetForAction(sendCoinsAction);
QWidget* masternodeWidget = toolbar->widgetForAction(masternodeAction);

overviewWidget->setMinimumWidth(actionWidth);
receiveWidget->setMinimumWidth(actionWidth);
historyWidget->setMinimumWidth(actionWidth);
sendCoinsWidget->setMinimumWidth(actionWidth);
masternodeWidget->setMinimumWidth(actionWidth);
if (toolbar) {
// Set widths for each action dynamically
QWidget* overviewWidget = overviewAction ? toolbar->widgetForAction(overviewAction) : nullptr;
QWidget* receiveWidget = receiveCoinsAction ? toolbar->widgetForAction(receiveCoinsAction) : nullptr;
QWidget* historyWidget = historyAction ? toolbar->widgetForAction(historyAction) : nullptr;
QWidget* sendCoinsWidget = sendCoinsAction ? toolbar->widgetForAction(sendCoinsAction) : nullptr;
QWidget* masternodeWidget = masternodeAction ? toolbar->widgetForAction(masternodeAction) : nullptr;

if (overviewWidget) overviewWidget->setMinimumWidth(actionWidth);
if (receiveWidget) receiveWidget->setMinimumWidth(actionWidth);
if (historyWidget) historyWidget->setMinimumWidth(actionWidth);
if (sendCoinsWidget) sendCoinsWidget->setMinimumWidth(actionWidth);
if (masternodeWidget) masternodeWidget->setMinimumWidth(actionWidth);
}
}
1 change: 1 addition & 0 deletions src/wallet/coincontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define BITCOIN_WALLET_COINCONTROL_H

#include "primitives/transaction.h"
#include "base58.h"

enum class CoinType
{
Expand Down
Loading