MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / CommitTransaction

Method CommitTransaction

src/wallet/wallet.cpp:2016–2063  ·  view source on GitHub ↗

* Call after CreateTransaction unless you want to abort */

Source from the content-addressed store, hash-verified

2014 * Call after CreateTransaction unless you want to abort
2015 */
2016bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
2017{
2018 {
2019 LOCK2(cs_main, cs_wallet);
2020 LogPrintf("CommitTransaction:\n%s", wtxNew.ToString());
2021 {
2022 // This is only to keep the database open to defeat the auto-flush for the
2023 // duration of this scope. This is the only place where this optimization
2024 // maybe makes sense; please don't do it anywhere else.
2025 CWalletDB* pwalletdb = fFileBacked ? new CWalletDB(strWalletFile,"r+") : NULL;
2026
2027 // Take key pair from key pool so it won't be used again
2028 reservekey.KeepKey();
2029
2030 // Add tx to wallet, because if it has change it's also ours,
2031 // otherwise just for transaction history.
2032 AddToWallet(wtxNew, false, pwalletdb);
2033
2034 // Notify that old coins are spent
2035 set<CWalletTx*> setCoins;
2036 BOOST_FOREACH(const CTxIn& txin, wtxNew.vin)
2037 {
2038 CWalletTx &coin = mapWallet[txin.prevout.hash];
2039 coin.BindWallet(this);
2040 NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED);
2041 }
2042
2043 if (fFileBacked)
2044 delete pwalletdb;
2045 }
2046
2047 // Track how many getdata requests our transaction gets
2048 mapRequestCount[wtxNew.GetHash()] = 0;
2049
2050 if (fBroadcastTransactions)
2051 {
2052 // Broadcast
2053 if (!wtxNew.AcceptToMemoryPool(false))
2054 {
2055 // This must not fail. The transaction has already been signed and recorded.
2056 LogPrintf("CommitTransaction(): Error: Transaction not valid");
2057 return false;
2058 }
2059 wtxNew.RelayWalletTransaction();
2060 }
2061 }
2062 return true;
2063}
2064
2065CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool)
2066{

Callers 3

SendMoneyFunction · 0.80
sendmanyFunction · 0.80
sendCoinsMethod · 0.80

Calls 5

KeepKeyMethod · 0.80
AcceptToMemoryPoolMethod · 0.80
ToStringMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected