Skip to content

Commit cde33d3

Browse files
committed
[Refactor] CreateTransaction(): use bit flags
This will allow to add flags for RBF and other features
1 parent 595f939 commit cde33d3

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/wallet/wallet.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC
18331833

18341834
CReserveKey reservekey(this);
18351835
CWalletTx wtx;
1836-
if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosRet, strFailReason, &coinControl, false))
1836+
if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosRet, strFailReason, &coinControl, CREATE_TX_DONT_SIGN))
18371837
return false;
18381838

18391839
if (nChangePosRet != -1)
@@ -1859,7 +1859,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC
18591859
}
18601860

18611861
bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet,
1862-
int& nChangePosRet, std::string& strFailReason, const CCoinControl* coinControl, bool sign)
1862+
int& nChangePosRet, std::string& strFailReason, const CCoinControl* coinControl, unsigned int flags)
18631863
{
18641864
CAmount nValue = 0;
18651865
unsigned int nSubtractFeeFromAmount = 0;
@@ -2077,7 +2077,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
20772077
bool signSuccess;
20782078
const CScript& scriptPubKey = coin.first->vout[coin.second].scriptPubKey;
20792079
CScript& scriptSigRes = txNew.vin[nIn].scriptSig;
2080-
if (sign)
2080+
if (!(flags & CREATE_TX_DONT_SIGN))
20812081
signSuccess = ProduceSignature(TransactionSignatureCreator(this, &txNewConst, nIn, SIGHASH_ALL), scriptPubKey, scriptSigRes);
20822082
else
20832083
signSuccess = ProduceSignature(DummySignatureCreator(this), scriptPubKey, scriptSigRes);
@@ -2093,7 +2093,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
20932093
unsigned int nBytes = ::GetSerializeSize(txNew, SER_NETWORK, PROTOCOL_VERSION);
20942094

20952095
// Remove scriptSigs if we used dummy signatures for fee calculation
2096-
if (!sign) {
2096+
if (flags & CREATE_TX_DONT_SIGN) {
20972097
BOOST_FOREACH (CTxIn& vin, txNew.vin)
20982098
vin.scriptSig = CScript();
20992099
}

src/wallet/wallet.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ class CWalletKey
446446
};
447447

448448

449+
enum CreateTransactionFlags {
450+
CREATE_TX_DEFAULT = 0,
451+
CREATE_TX_DONT_SIGN = (1U << 0)
452+
};
449453

450454
/**
451455
* A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,
@@ -660,7 +664,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
660664
* selected by SelectCoins(); Also create the change output, when needed
661665
*/
662666
bool CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, int& nChangePosRet,
663-
std::string& strFailReason, const CCoinControl *coinControl = NULL, bool sign = true);
667+
std::string& strFailReason, const CCoinControl *coinControl = NULL, unsigned int flags = CREATE_TX_DEFAULT);
664668
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
665669

666670
bool AddAccountingEntry(const CAccountingEntry&, CWalletDB & pwalletdb);

0 commit comments

Comments
 (0)