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

Function CommitTransaction

src/wallet/feebumper.cpp:352–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350}
351
352Result CommitTransaction(CWallet& wallet, const Txid& txid, CMutableTransaction&& mtx, std::vector<bilingual_str>& errors, Txid& bumped_txid)
353{
354 LOCK(wallet.cs_wallet);
355 if (!errors.empty()) {
356 return Result::MISC_ERROR;
357 }
358 auto it = txid.IsNull() ? wallet.mapWallet.end() : wallet.mapWallet.find(txid);
359 if (it == wallet.mapWallet.end()) {
360 errors.emplace_back(Untranslated("Invalid or non-wallet transaction id"));
361 return Result::MISC_ERROR;
362 }
363 const CWalletTx& oldWtx = it->second;
364
365 // make sure the transaction still has no descendants and hasn't been mined in the meantime
366 Result result = PreconditionChecks(wallet, oldWtx, /* require_mine=*/ false, errors);
367 if (result != Result::OK) {
368 return result;
369 }
370
371 // commit/broadcast the tx
372 CTransactionRef tx = MakeTransactionRef(std::move(mtx));
373 mapValue_t mapValue = oldWtx.mapValue;
374 mapValue["replaces_txid"] = oldWtx.GetHash().ToString();
375
376 wallet.CommitTransaction(tx, std::move(mapValue), oldWtx.vOrderForm);
377
378 // mark the original tx as bumped
379 bumped_txid = tx->GetHash();
380 if (!wallet.MarkReplaced(oldWtx.GetHash(), bumped_txid)) {
381 errors.emplace_back(Untranslated("Created new bumpfee transaction but could not mark the original transaction as replaced"));
382 }
383 return Result::OK;
384}
385
386} // namespace feebumper
387} // namespace wallet

Callers 2

commitBumpTransactionMethod · 0.85
bumpfee_helperFunction · 0.85

Calls 11

UntranslatedFunction · 0.85
MakeTransactionRefFunction · 0.85
findMethod · 0.80
CommitTransactionMethod · 0.80
MarkReplacedMethod · 0.80
emptyMethod · 0.45
IsNullMethod · 0.45
endMethod · 0.45
emplace_backMethod · 0.45
ToStringMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected