| 266 | } |
| 267 | |
| 268 | Result 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 |
no test coverage detected