MCPcopy Create free account
hub / github.com/LUX-Core/lux / CommitTransaction

Method CommitTransaction

src/wallet.cpp:3148–3194  ·  view source on GitHub ↗

* Call after CreateTransaction unless you want to abort */

Source from the content-addressed store, hash-verified

3146 * Call after CreateTransaction unless you want to abort
3147 */
3148bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, std::string strCommand)
3149{
3150 {
3151 LOCK2(cs_main, cs_wallet);
3152# if defined(DEBUG_DUMP_STAKING_INFO)&&defined(DEBUG_DUMP_CommitTransaction)
3153 DEBUG_DUMP_CommitTransaction();
3154# endif
3155 {
3156 // This is only to keep the database open to defeat the auto-flush for the
3157 // duration of this scope. This is the only place where this optimization
3158 // maybe makes sense; please don't do it anywhere else.
3159 CWalletDB* pwalletdb = fFileBacked ? new CWalletDB(strWalletFile, "r") : NULL;
3160
3161 // Take key pair from key pool so it won't be used again
3162 reservekey.KeepKey();
3163
3164 // Add tx to wallet, because if it has change it's also ours,
3165 // otherwise just for transaction history.
3166 AddToWallet(wtxNew);
3167
3168 // Notify that old coins are spent
3169 set<uint256> updated_hahes;
3170 for (const CTxIn& txin : wtxNew.vin) {
3171 // notify only once
3172 if (updated_hahes.find(txin.prevout.hash) != updated_hahes.end()) continue;
3173
3174 CWalletTx& coin = mapWallet[txin.prevout.hash];
3175 coin.BindWallet(this);
3176 NotifyTransactionChanged(this, txin.prevout.hash, CT_UPDATED);
3177 updated_hahes.insert(txin.prevout.hash);
3178 }
3179 if (fFileBacked)
3180 delete pwalletdb;
3181 }
3182
3183 if (fBroadcastTransactions) {
3184 // Broadcast
3185 if (!wtxNew.AcceptToMemoryPool(false)) {
3186 // This must not fail. The transaction has already been signed and recorded.
3187 LogPrintf("CommitTransaction() : Error: Transaction not valid %s\n", strCommand.c_str());
3188 return false;
3189 }
3190 wtxNew.RelayWalletTransaction(strCommand);
3191 }
3192 }
3193 return true;
3194}
3195
3196bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool overrideEstimatedFeeRate, int& nChangePosInOut, std::string& strFailReason,
3197 bool lockUnspents, const std::set<int>& setSubtractFeeFromOutputs, CCoinControl* coinControl)

Callers 9

SendMoneyFunction · 0.80
sendmanyFunction · 0.80
createcontractFunction · 0.80
sendtocontractFunction · 0.80
MakeCollateralAmountsMethod · 0.80
CreateDenominatedMethod · 0.80
SendMoneyFunction · 0.80
sendCoinsMethod · 0.80

Calls 7

KeepKeyMethod · 0.80
BindWalletMethod · 0.80
AcceptToMemoryPoolMethod · 0.80
NotifyTransactionChangedFunction · 0.50
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected