MCPcopy Create free account
hub / github.com/ElementsProject/elements / CommitTransaction

Function CommitTransaction

src/wallet/feebumper.cpp:268–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<bilingual_str>& errors, uint256& bumped_txid)
269{
270 LOCK(wallet.cs_wallet);
271 if (!errors.empty()) {
272 return Result::MISC_ERROR;
273 }
274 auto it = txid.IsNull() ? wallet.mapWallet.end() : wallet.mapWallet.find(txid);
275 if (it == wallet.mapWallet.end()) {
276 errors.push_back(Untranslated("Invalid or non-wallet transaction id"));
277 return Result::MISC_ERROR;
278 }
279 const CWalletTx& oldWtx = it->second;
280
281 // make sure the transaction still has no descendants and hasn't been mined in the meantime
282 Result result = PreconditionChecks(wallet, oldWtx, errors);
283 if (result != Result::OK) {
284 return result;
285 }
286
287 // commit/broadcast the tx
288 CTransactionRef tx = MakeTransactionRef(std::move(mtx));
289 mapValue_t mapValue = oldWtx.mapValue;
290 mapValue["replaces_txid"] = oldWtx.GetHash().ToString();
291 // wipe blinding details to not store old information
292 mapValue["blindingdata"] = "";
293 // TODO CA: store new blinding data to remember otherwise unblindable outputs
294
295 wallet.CommitTransaction(tx, std::move(mapValue), oldWtx.vOrderForm);
296
297 // mark the original tx as bumped
298 bumped_txid = tx->GetHash();
299 if (!wallet.MarkReplaced(oldWtx.GetHash(), bumped_txid)) {
300 errors.push_back(Untranslated("Created new bumpfee transaction but could not mark the original transaction as replaced"));
301 }
302 return Result::OK;
303}
304
305} // namespace feebumper
306} // namespace wallet

Callers 2

commitBumpTransactionMethod · 0.85
bumpfee_helperFunction · 0.85

Calls 11

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

Tested by

no test coverage detected