-
-
Notifications
You must be signed in to change notification settings - Fork 365
Crash on Non HD wallets fix #1709
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
Conversation
WalkthroughAdds defensive null-checks and UI gating for Spark wallet presence across three Qt UI flows: anonymize button enabling (overviewpage.cpp), automint notification display (walletview.cpp), and receive-coins address-type handling (receivecoinsdialog.cpp), hiding Spark-specific controls when wallet or sparkWallet is absent. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/qt/overviewpage.cpp(1 hunks)src/qt/walletview.cpp(1 hunks)
⏰ 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-arm64-apple-darwin
- GitHub Check: build-guix-x86_64-apple-darwin
- GitHub Check: build-guix-x86_64-w64-mingw32
- GitHub Check: build-guix-x86_64-linux-gnu
- GitHub Check: build-mac-cmake
- GitHub Check: build-guix-aarch64-linux-gnu
- GitHub Check: build-windows-cmake
- GitHub Check: build-linux-cmake
- GitHub Check: build-guix-x86_64-apple-darwin
- GitHub Check: build-guix-aarch64-linux-gnu
- GitHub Check: build-guix-arm64-apple-darwin
- GitHub Check: build-guix-x86_64-w64-mingw32
- GitHub Check: build-windows-cmake
- GitHub Check: build-mac-cmake
- GitHub Check: build-guix-x86_64-linux-gnu
- GitHub Check: build-linux-cmake
|
Tested. Crashes when generating Spark address in Receive tab (should show error/warning instead). |
|
Working as expected. |
aleflm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than two minor issues I raised. Everything looks good to me.
src/qt/receivecoinsdialog.cpp
Outdated
| void ReceiveCoinsDialog::displayCheckBox(int idx) | ||
| { | ||
| if(idx==0){ | ||
| if(ui->addressTypeCombobox->currentText() == "Spark"){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause issues with Localization.
Something like this (roughly) might be better:
// Only works if "Spark" is translated exactly the same way here as in the .ui file
if(ui->addressTypeCombobox->currentText() == tr("Spark")){
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, fixed
|
|
||
| auto wallet = _model->getWallet(); | ||
| if (!wallet || !wallet->sparkWallet) { | ||
| ui->addressTypeCombobox->removeItem(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes item 0 is always “Spark”. Is this a correct assumption? ( I am not sure, just asking ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, item 0 at this point is always "Spark"
There was a problem hiding this 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 (2)
src/qt/receivecoinsdialog.cpp (2)
125-130: Defensive null-checks prevent crash on non-HD wallets.The guard correctly removes Spark functionality when
sparkWalletis unavailable, addressing the crash reported in issue #1530.💡 Optional: Make item removal more maintainable
Instead of hardcoding
removeItem(0), find the Spark item by its associated data value to protect against future reordering:- ui->addressTypeCombobox->removeItem(0); + int sparkIndex = ui->addressTypeCombobox->findData(Spark); + if (sparkIndex != -1) { + ui->addressTypeCombobox->removeItem(sparkIndex); + }This decouples the removal logic from the item order defined in the constructor.
337-337: Localization-aware text comparison is correct.Using
tr("Spark")properly addresses the localization concern raised in earlier reviews.💡 Optional: Use data-based comparison for robustness
Instead of comparing translated strings, compare the item's data value:
- if(ui->addressTypeCombobox->currentText() == tr("Spark")){ + if(ui->addressTypeCombobox->currentData().toInt() == Spark){This eliminates dependency on string matching and translation consistency, making the code more robust against translation variations or typos.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/qt/receivecoinsdialog.cpp(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/qt/receivecoinsdialog.cpp (1)
src/qt/bitcoin.cpp (1)
wallet(241-241)
⏰ 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-linux-cmake
- GitHub Check: build-guix-x86_64-w64-mingw32
- GitHub Check: build-guix-x86_64-apple-darwin
- GitHub Check: build-guix-x86_64-linux-gnu
- GitHub Check: build-mac-cmake
- GitHub Check: build-windows-cmake
- GitHub Check: build-guix-aarch64-linux-gnu
- GitHub Check: build-guix-arm64-apple-darwin
- GitHub Check: build-guix-x86_64-apple-darwin
- GitHub Check: build-guix-arm64-apple-darwin
- GitHub Check: build-linux-cmake
- GitHub Check: build-guix-x86_64-linux-gnu
- GitHub Check: build-windows-cmake
- GitHub Check: build-guix-aarch64-linux-gnu
- GitHub Check: build-guix-x86_64-w64-mingw32
- GitHub Check: build-mac-cmake
Fix for issue #1530