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

Method CommitTransaction

src/wallet/wallet.cpp:3069–3115  ·  view source on GitHub ↗

* Call after CreateTransaction unless you want to abort */

Source from the content-addressed store, hash-verified

3067 * Call after CreateTransaction unless you want to abort
3068 */
3069bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm, std::string fromAccount, CReserveKey& reservekey, CConnman* connman, CValidationState& state)
3070{
3071 {
3072 LOCK2(cs_main, cs_wallet);
3073
3074 CWalletTx wtxNew(this, std::move(tx));
3075 wtxNew.mapValue = std::move(mapValue);
3076 wtxNew.vOrderForm = std::move(orderForm);
3077 wtxNew.strFromAccount = std::move(fromAccount);
3078 wtxNew.fTimeReceivedIsTxTime = true;
3079 wtxNew.fFromMe = true;
3080
3081 WalletLogPrintf("CommitTransaction:\n%s", wtxNew.tx->ToString()); /* Continued */
3082 {
3083 // Take key pair from key pool so it won't be used again
3084 reservekey.KeepKey();
3085
3086 // Add tx to wallet, because if it has change it's also ours,
3087 // otherwise just for transaction history.
3088 AddToWallet(wtxNew);
3089
3090 // Notify that old coins are spent
3091 for (const CTxIn& txin : wtxNew.tx->vin)
3092 {
3093 CWalletTx &coin = mapWallet.at(txin.prevout.hash);
3094 coin.BindWallet(this);
3095 NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED);
3096 }
3097 }
3098
3099 // Get the inserted-CWalletTx from mapWallet so that the
3100 // fInMempool flag is cached properly
3101 CWalletTx& wtx = mapWallet.at(wtxNew.GetHash());
3102
3103 if (fBroadcastTransactions)
3104 {
3105 // Broadcast
3106 if (!wtx.AcceptToMemoryPool(maxTxFee, state)) {
3107 WalletLogPrintf("CommitTransaction(): Transaction cannot be broadcast immediately, %s\n", FormatStateMessage(state));
3108 // TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure.
3109 } else {
3110 wtx.RelayWalletTransaction(connman);
3111 }
3112 }
3113 }
3114 return true;
3115}
3116
3117void CWallet::ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& entries) {
3118 WalletBatch batch(*database);

Callers 5

SendMoneyFunction · 0.80
sendmanyFunction · 0.80
CommitTransactionFunction · 0.80
commitMethod · 0.80

Calls 8

FormatStateMessageFunction · 0.85
KeepKeyMethod · 0.80
BindWalletMethod · 0.80
AcceptToMemoryPoolMethod · 0.80
NotifyTransactionChangedFunction · 0.50
ToStringMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected