Skip to content

fix: protx_register_common_wrapper to include Prepare action for wallet unlock checks#7069

Merged
PastaPastaPasta merged 2 commits into
dashpay:developfrom
PastaPastaPasta:fix/reg-prep-unlock
Dec 19, 2025
Merged

fix: protx_register_common_wrapper to include Prepare action for wallet unlock checks#7069
PastaPastaPasta merged 2 commits into
dashpay:developfrom
PastaPastaPasta:fix/reg-prep-unlock

Conversation

@PastaPastaPasta
Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Commands such as

protx register_prepare_evo b3b36f52bbc960edfe66867e0621a52bd5ac08011390959b3455d65aaec6893b 1 1.1.1.1:19999 yNGcrezN6NrRgf1DUuPP6pYsko3K9AdgHt 9889874ec1df289931886afee957c802bf0e751a6ec8461ac774f5affdabf06e7aa0c47ff94399e1d2ad597318733b8c yRkYwCNcXZQ3SfNp8hPP7sJHTdPMFna92y 8 yNfsHUoAysATEzxn5ZYD526Cw8AK8UTBdY eaa200ff6b7dde61ac4f943218307bcc249ea37b 36656 1443 yMm632VcVkZwndDvTVphmABvA6vWWMjxDh

may fail if the wallet isn't unlocked with GetKey: DecryptHDChain failed where it should fail with Error: Please enter the wallet passphrase with walletpassphrase first

What was done?

include prepare in checking that wallet is unlocked

How Has This Been Tested?

Breaking Changes

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@PastaPastaPasta PastaPastaPasta added this to the 23.1 milestone Dec 16, 2025
knst
knst previously approved these changes Dec 16, 2025
Copy link
Copy Markdown
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

utACK c6cfe44 (assuming CI succeed)

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 16, 2025

Walkthrough

The change modifies protx_register_common_wrapper in src/rpc/evo.cpp so the wallet is unlocked unconditionally, including the ProTxRegisterAction::Prepare path; previously unlock occurred only for External and Fund actions. No other logic or error handling was changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file affected with a localized control flow change
  • Verify the Prepare path legitimately requires wallet unlock
  • Confirm no unintended side effects on External/Fund paths or downstream operations

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding the Prepare action to wallet unlock checks in protx_register_common_wrapper.
Description check ✅ Passed The description clearly explains the issue (incorrect error message when wallet is locked) and the fix (include prepare action in wallet unlock checks).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 c6cfe44 and d47951d.

📒 Files selected for processing (1)
  • src/rpc/evo.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/rpc/evo.cpp
⏰ 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). (1)
  • GitHub Check: Build slim container / Build container

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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)
src/rpc/evo.cpp (1)

686-688: LGTM! Fix correctly addresses the wallet unlock issue.

The addition of ProTxRegisterAction::Prepare ensures that wallet unlock is checked before calling FundSpecialTx at line 811, which requires wallet access to select coins and add fee inputs. This prevents the cryptic GetKey: DecryptHDChain failed error and provides users with the proper Error: Please enter the wallet passphrase with walletpassphrase first message.

Optional refactor:

Since the condition now checks all three values of the ProTxRegisterAction enum (External, Fund, Prepare), you could simplify this by unconditionally calling EnsureWalletIsUnlocked(*pwallet) and removing the if statement entirely. All actions require wallet access anyway.

Apply this diff to simplify:

-    if (action == ProTxRegisterAction::External || action == ProTxRegisterAction::Fund || action == ProTxRegisterAction::Prepare) {
-        EnsureWalletIsUnlocked(*pwallet);
-    }
+    EnsureWalletIsUnlocked(*pwallet);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 123ee5e and c6cfe44.

📒 Files selected for processing (1)
  • src/rpc/evo.cpp (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.{cpp,h,hpp,cc}

📄 CodeRabbit inference engine (CLAUDE.md)

Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1

Files:

  • src/rpc/evo.cpp
🧠 Learnings (5)
📓 Common learnings
Learnt from: kwvg
Repo: dashpay/dash PR: 6529
File: src/wallet/rpcwallet.cpp:3002-3003
Timestamp: 2025-02-14T15:19:17.218Z
Learning: The `GetWallet()` function calls in `src/wallet/rpcwallet.cpp` are properly validated with null checks that throw appropriate RPC errors, making additional validation unnecessary.
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/evo/**/*.{cpp,h} : Special transactions use payload serialization routines defined in src/evo/specialtx.h and must include appropriate special transaction types (ProRegTx, ProUpServTx, ProUpRegTx, ProUpRevTx)
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.
Learnt from: kwvg
Repo: dashpay/dash PR: 6665
File: src/evo/providertx.h:82-82
Timestamp: 2025-06-06T11:53:09.094Z
Learning: In ProTx serialization code (SERIALIZE_METHODS), version checks should use hardcoded maximum flags (/*is_basic_scheme_active=*/true, /*is_extended_addr=*/true) rather than deployment-based flags. This is because serialization code should be able to deserialize any structurally valid ProTx up to the maximum version the code knows how to handle, regardless of current consensus validity. Validation code, not serialization code, is responsible for checking whether a ProTx version is consensus-valid based on deployment status.
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{validation,txmempool}/**/*.{cpp,h} : Block validation and mempool handling must use extensions to Bitcoin Core mechanisms for special transaction validation and enhanced transaction relay
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/evo/**/*.{cpp,h} : Special transactions use payload serialization routines defined in src/evo/specialtx.h and must include appropriate special transaction types (ProRegTx, ProUpServTx, ProUpRegTx, ProUpRevTx)

Applied to files:

  • src/rpc/evo.cpp
📚 Learning: 2025-08-08T07:01:47.332Z
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.

Applied to files:

  • src/rpc/evo.cpp
📚 Learning: 2025-02-14T15:19:17.218Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6529
File: src/wallet/rpcwallet.cpp:3002-3003
Timestamp: 2025-02-14T15:19:17.218Z
Learning: The `GetWallet()` function calls in `src/wallet/rpcwallet.cpp` are properly validated with null checks that throw appropriate RPC errors, making additional validation unnecessary.

Applied to files:

  • src/rpc/evo.cpp
📚 Learning: 2025-06-06T11:53:09.094Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6665
File: src/evo/providertx.h:82-82
Timestamp: 2025-06-06T11:53:09.094Z
Learning: In ProTx serialization code (SERIALIZE_METHODS), version checks should use hardcoded maximum flags (/*is_basic_scheme_active=*/true, /*is_extended_addr=*/true) rather than deployment-based flags. This is because serialization code should be able to deserialize any structurally valid ProTx up to the maximum version the code knows how to handle, regardless of current consensus validity. Validation code, not serialization code, is responsible for checking whether a ProTx version is consensus-valid based on deployment status.

Applied to files:

  • src/rpc/evo.cpp

Comment thread src/rpc/evo.cpp Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 16, 2025

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Copy link
Copy Markdown

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK d47951d

Copy link
Copy Markdown
Collaborator

@kwvg kwvg left a comment

Choose a reason for hiding this comment

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

utACK d47951d

@PastaPastaPasta PastaPastaPasta merged commit 05f0066 into dashpay:develop Dec 19, 2025
40 of 42 checks passed
@PastaPastaPasta PastaPastaPasta deleted the fix/reg-prep-unlock branch December 19, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants