|
23 | 23 | #include <script/standard.h> |
24 | 24 | #include <util/message.h> |
25 | 25 | #include <util/strencodings.h> |
| 26 | +#include <wallet/wallet.h> |
26 | 27 |
|
27 | 28 | #include <univalue.h> |
28 | 29 |
|
@@ -557,32 +558,8 @@ void GovernanceList::voteForProposal(vote_outcome_enum_t outcome) |
557 | 558 | // Create vote |
558 | 559 | CGovernanceVote vote(dmn->collateralOutpoint, proposalHash, VOTE_SIGNAL_FUNDING, outcome); |
559 | 560 |
|
560 | | - // Sign vote |
561 | | - bool signSuccess = false; |
562 | | - |
563 | | - // Special implementation for testnet (same as RPC SignVote) |
564 | | - if (Params().NetworkIDString() == CBaseChainParams::TESTNET) { |
565 | | - // Testnet uses SignSpecialTxPayload |
566 | | - std::vector<unsigned char> vchSig; |
567 | | - if (walletModel->wallet().signSpecialTxPayload(vote.GetSignatureHash(), votingKeyID, vchSig)) { |
568 | | - vote.SetSignature(vchSig); |
569 | | - signSuccess = true; |
570 | | - } |
571 | | - } else { |
572 | | - // Other networks use SignMessage |
573 | | - std::string strMessage = vote.GetSignatureString(); |
574 | | - std::string signature; |
575 | | - SigningResult result = walletModel->wallet().signMessage(strMessage, PKHash(votingKeyID), signature); |
576 | | - if (result == SigningResult::OK) { |
577 | | - const auto decoded = DecodeBase64(signature); |
578 | | - if (decoded) { |
579 | | - vote.SetSignature(std::vector<unsigned char>(decoded->begin(), decoded->end())); |
580 | | - signSuccess = true; |
581 | | - } |
582 | | - } |
583 | | - } |
584 | | - |
585 | | - if (!signSuccess) { |
| 561 | + // Sign vote using shared helper function |
| 562 | + if (!SignGovernanceVote(*walletModel->wallet().wallet(), votingKeyID, vote)) { |
586 | 563 | nFailed++; |
587 | 564 | failedMessages.append( |
588 | 565 | tr("Failed to sign vote for masternode %1").arg(QString::fromStdString(proTxHash.ToString()))); |
|
0 commit comments