Skip to content

Commit 258cdc2

Browse files
committed
refactor: move and rename GetBudgetSystemCollateralTX() to spend.cpp
Need to move last `CreateTransaction` usage away from `wallet.cpp` so that circular dependencies can be resolved in an upcoming commit. `GetBudgetSystemCollateralTX()` is not a getter, it *generates* a transaction, renaming to `GenBudgetSystemCollateralTx()`.
1 parent e03fdff commit 258cdc2

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

src/rpc/governance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static RPCHelpMan gobject_prepare()
218218

219219
CTransactionRef tx;
220220

221-
if (!wallet->GetBudgetSystemCollateralTX(tx, govobj.GetHash(), govobj.GetMinCollateralFee(), outpoint)) {
221+
if (!wallet->GenBudgetSystemCollateralTx(tx, govobj.GetHash(), govobj.GetMinCollateralFee(), outpoint)) {
222222
std::string err = "Error making collateral transaction for governance object. Please check your wallet balance and make sure your wallet is unlocked.";
223223
if (!request.params[5].isNull() && !request.params[6].isNull()) {
224224
err += "Please verify your specified output is valid and is enough for the combined proposal fee and transaction fee.";

src/wallet/spend.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,3 +1059,28 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
10591059

10601060
return true;
10611061
}
1062+
1063+
bool CWallet::GenBudgetSystemCollateralTx(CTransactionRef& tx, uint256 hash, CAmount amount, const COutPoint& outpoint)
1064+
{
1065+
CScript scriptChange;
1066+
scriptChange << OP_RETURN << ToByteVector(hash);
1067+
1068+
CAmount nFeeRet = 0;
1069+
int nChangePosRet = -1;
1070+
bilingual_str error;
1071+
std::vector< CRecipient > vecSend;
1072+
vecSend.push_back((CRecipient){scriptChange, amount, false});
1073+
1074+
CCoinControl coinControl;
1075+
if (!outpoint.IsNull()) {
1076+
coinControl.Select(outpoint);
1077+
}
1078+
FeeCalculation fee_calc_out;
1079+
bool success = CreateTransaction(vecSend, tx, nFeeRet, nChangePosRet, error, coinControl, fee_calc_out);
1080+
if(!success){
1081+
WalletLogPrintf("CWallet::GenBudgetSystemCollateralTx -- Error: %s\n", error.original);
1082+
return false;
1083+
}
1084+
1085+
return true;
1086+
}

src/wallet/wallet.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,31 +2043,6 @@ bool CWallet::SignSpecialTxPayload(const uint256& hash, const CKeyID& keyid, std
20432043
return false;
20442044
}
20452045

2046-
bool CWallet::GetBudgetSystemCollateralTX(CTransactionRef& tx, uint256 hash, CAmount amount, const COutPoint& outpoint)
2047-
{
2048-
CScript scriptChange;
2049-
scriptChange << OP_RETURN << ToByteVector(hash);
2050-
2051-
CAmount nFeeRet = 0;
2052-
int nChangePosRet = -1;
2053-
bilingual_str error;
2054-
std::vector< CRecipient > vecSend;
2055-
vecSend.push_back((CRecipient){scriptChange, amount, false});
2056-
2057-
CCoinControl coinControl;
2058-
if (!outpoint.IsNull()) {
2059-
coinControl.Select(outpoint);
2060-
}
2061-
FeeCalculation fee_calc_out;
2062-
bool success = CreateTransaction(vecSend, tx, nFeeRet, nChangePosRet, error, coinControl, fee_calc_out);
2063-
if(!success){
2064-
WalletLogPrintf("CWallet::GetBudgetSystemCollateralTX -- Error: %s\n", error.original);
2065-
return false;
2066-
}
2067-
2068-
return true;
2069-
}
2070-
20712046
void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm)
20722047
{
20732048
LOCK(cs_wallet);

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
674674
float GetAverageAnonymizedRounds() const;
675675
CAmount GetNormalizedAnonymizedBalance() const;
676676

677-
bool GetBudgetSystemCollateralTX(CTransactionRef& tx, uint256 hash, CAmount amount, const COutPoint& outpoint=COutPoint()/*defaults null*/);
677+
bool GenBudgetSystemCollateralTx(CTransactionRef& tx, uint256 hash, CAmount amount, const COutPoint& outpoint=COutPoint()/*defaults null*/);
678678
CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const;
679679

680680
/**

0 commit comments

Comments
 (0)