Skip to content
Bitcoin Roots

v29.4-roots.3 · Commit 28: [PATCH 28/30] fix(wallet): secure asynchronous sweep cancellation

src/wallet/rpc/spend.cpp

Before: src/wallet/rpc/spend.cpp · After: src/wallet/rpc/spend.cpp

File metadata
index a20946e2b434d26aa228846d364e25aaa9bb22ee..bcdfb41efc83770cb8d57cde508b3b15d61b5819 100644

Download original patch · Release notes

Diff rows 1–18 of 18. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

src/wallet/rpc/spend.cpp CHANGED
@@ -5,6 +5,7 @@
5
5
  #include <common/messages.h>
6
6
  #include <consensus/validation.h>
7
7
  #include <core_io.h>
8
+ #include <interfaces/wallet.h>
8
9
  #include <key_io.h>
9
10
  #include <node/types.h>
10
11
  #include <policy/policy.h>
@@ -99,9 +100,10 @@ RPCHelpMan sweepprivkeys()
99
100
  case interfaces::ScanResult::UNAVAILABLE: throw JSONRPCError(RPC_MISC_ERROR, "UTXO scan unavailable");
100
101
  }
101
102
  const bool broadcast{!request.params[2].isNull() && request.params[2].get_bool()};
103
+ interfaces::SweepAuthorization authorization;
102
104
  auto swept{CreateSweepTransaction(*pwallet, provider, coins, destination_script, broadcast ? SweepBroadcastFn{[&](const CTransactionRef& tx, std::string& error) {
103
105
  return pwallet->chain().broadcastTransaction(tx, pwallet->m_default_max_tx_fee, /*relay=*/true, error);
104
- }} : SweepBroadcastFn{})};
106
+ }} : SweepBroadcastFn{}, authorization)};
105
107
  if (!swept) {
106
108
  const std::string error{util::ErrorString(swept).original};
107
109
  const int code{error == "No spendable UTXOs found" || error == "Fee exceeds swept value" ? RPC_WALLET_INSUFFICIENT_FUNDS :