Skip to content

Commit 8398b2e

Browse files
random-zebrafurszy
authored andcommitted
[BUG] Duplicated ReserveKey in CBudgetManager::SubmitFinalBudget()
1 parent 9c0d4b1 commit 8398b2e

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/masternode-budget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,15 @@ void CBudgetManager::SubmitFinalBudget()
198198

199199
if (!mapCollateralTxids.count(tempBudget.GetHash())) {
200200
CWalletTx wtx;
201-
if (!pwalletMain->GetBudgetFinalizationCollateralTX(wtx, tempBudget.GetHash(), false)) {
201+
// Get our change address
202+
CReserveKey keyChange(pwalletMain);
203+
if (!pwalletMain->GetBudgetFinalizationCollateralTX(wtx, tempBudget.GetHash(), keyChange, false)) {
202204
LogPrint(BCLog::MNBUDGET,"%s: Can't make collateral transaction\n", __func__);
203205
return;
204206
}
205207

206-
// Get our change address
207-
CReserveKey reservekey(pwalletMain);
208208
// Send the tx to the network. Do NOT use SwiftTx, locking might need too much time to propagate, especially for testnet
209-
const CWallet::CommitResult& res = pwalletMain->CommitTransaction(wtx, reservekey, g_connman.get(), "NO-ix");
209+
const CWallet::CommitResult& res = pwalletMain->CommitTransaction(wtx, keyChange, g_connman.get(), "NO-ix");
210210
if (res.status != CWallet::CommitStatus::OK)
211211
return;
212212
tx = (CTransaction)wtx;

src/wallet/wallet.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,11 +2343,8 @@ bool CWallet::GetBudgetSystemCollateralTX(CWalletTx& tx, uint256 hash, bool useI
23432343
return true;
23442344
}
23452345

2346-
bool CWallet::GetBudgetFinalizationCollateralTX(CWalletTx& tx, uint256 hash, bool useIX)
2346+
bool CWallet::GetBudgetFinalizationCollateralTX(CWalletTx& tx, uint256 hash, CReserveKey& keyChange, bool useIX)
23472347
{
2348-
// make our change address
2349-
CReserveKey reservekey(this);
2350-
23512348
CScript scriptChange;
23522349
scriptChange << OP_RETURN << ToByteVector(hash);
23532350

@@ -2358,7 +2355,7 @@ bool CWallet::GetBudgetFinalizationCollateralTX(CWalletTx& tx, uint256 hash, boo
23582355

23592356
CCoinControl* coinControl = NULL;
23602357
int nChangePosInOut = -1;
2361-
bool success = CreateTransaction(vecSend, tx, reservekey, nFeeRet, nChangePosInOut, strFail, coinControl, ALL_COINS, true, useIX, (CAmount)0);
2358+
bool success = CreateTransaction(vecSend, tx, keyChange, nFeeRet, nChangePosInOut, strFail, coinControl, ALL_COINS, true, useIX, (CAmount)0);
23622359
if (!success) {
23632360
LogPrintf("GetBudgetSystemCollateralTX: Error - %s\n", strFail);
23642361
return false;

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
602602
void DeleteLabel(const std::string& label);
603603

604604
bool GetBudgetSystemCollateralTX(CWalletTx& tx, uint256 hash, bool useIX);
605-
bool GetBudgetFinalizationCollateralTX(CWalletTx& tx, uint256 hash, bool useIX); // Only used for budget finalization
605+
bool GetBudgetFinalizationCollateralTX(CWalletTx& tx, uint256 hash, CReserveKey& keyChange, bool useIX); // Only used for budget finalization
606606

607607
bool IsUsed(const CTxDestination address) const;
608608

0 commit comments

Comments
 (0)