Skip to content

Commit edfe1ee

Browse files
refactor(governance): avoid recursion in wallet unlock handling
1 parent 24240a6 commit edfe1ee

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/qt/governancelist.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -536,17 +536,14 @@ void GovernanceList::voteForProposal(vote_outcome_enum_t outcome)
536536

537537
const uint256 proposalHash(uint256S(proposal->hash().toStdString()));
538538

539-
// Check if wallet is locked and unlock if needed
540-
WalletModel::EncryptionStatus encStatus = walletModel->getEncryptionStatus();
541-
if (encStatus == WalletModel::Locked || encStatus == WalletModel::UnlockedForMixingOnly) {
542-
WalletModel::UnlockContext ctx(walletModel->requestUnlock());
543-
if (!ctx.isValid()) {
544-
// Unlock cancelled
545-
return;
546-
}
547-
// Recursively call the function now that wallet is unlocked
548-
return voteForProposal(outcome);
549-
} // UnlockContext goes out of scope here, but we've already made the recursive call
539+
// Request unlock if needed and keep context alive for the voting operation
540+
WalletModel::UnlockContext ctx(walletModel->requestUnlock());
541+
if (!ctx.isValid()) {
542+
// Unlock cancelled or failed
543+
QMessageBox::warning(this, tr("Voting Failed"),
544+
tr("Unable to unlock wallet."));
545+
return;
546+
}
550547

551548
int nSuccessful = 0;
552549
int nFailed = 0;

0 commit comments

Comments
 (0)