Skip to content

Commit 1337c72

Browse files
committed
wallet, rpc: Remove watchonly from RPCs
Descriptor wallets don't have a conception of watchonly within a wallet, so remove all of these options and results from the RPCs
1 parent e81d95d commit 1337c72

14 files changed

+130
-237
lines changed

src/wallet/rpc/addresses.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ RPCHelpMan getaddressinfo()
380380
{RPCResult::Type::STR, "address", "The bitcoin address validated."},
381381
{RPCResult::Type::STR_HEX, "scriptPubKey", "The hex-encoded output script generated by the address."},
382382
{RPCResult::Type::BOOL, "ismine", "If the address is yours."},
383-
{RPCResult::Type::BOOL, "iswatchonly", "If the address is watchonly."},
383+
{RPCResult::Type::BOOL, "iswatchonly", "(DEPRECATED) Always false."},
384384
{RPCResult::Type::BOOL, "solvable", "If we know how to spend coins sent to this address, ignoring the possible lack of private keys."},
385385
{RPCResult::Type::STR, "desc", /*optional=*/true, "A descriptor for spending coins sent to this address (only when solvable)."},
386386
{RPCResult::Type::STR, "parent_desc", /*optional=*/true, "The descriptor used to derive this address if this is a descriptor wallet"},
@@ -402,7 +402,7 @@ RPCHelpMan getaddressinfo()
402402
{RPCResult::Type::OBJ, "embedded", /*optional=*/true, "Information about the address embedded in P2SH or P2WSH, if relevant and known.",
403403
{
404404
{RPCResult::Type::ELISION, "", "Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)\n"
405-
"and relation to the wallet (ismine, iswatchonly)."},
405+
"and relation to the wallet (ismine)."},
406406
}},
407407
{RPCResult::Type::BOOL, "iscompressed", /*optional=*/true, "If the pubkey is compressed."},
408408
{RPCResult::Type::NUM_TIME, "timestamp", /*optional=*/true, "The creation time of the key, if available, expressed in " + UNIX_EPOCH_TIME + "."},
@@ -475,7 +475,7 @@ RPCHelpMan getaddressinfo()
475475
}
476476
}
477477

478-
ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY));
478+
ret.pushKV("iswatchonly", false);
479479

480480
UniValue detail = DescribeWalletAddress(*pwallet, dest);
481481
ret.pushKVs(std::move(detail));

src/wallet/rpc/spend.cpp

Lines changed: 98 additions & 118 deletions
Large diffs are not rendered by default.

src/wallet/rpc/transactions.cpp

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ struct tallyitem
6868
CAmount nAmount{0};
6969
int nConf{std::numeric_limits<int>::max()};
7070
std::vector<Txid> txids;
71-
bool fIsWatchonly{false};
7271
tallyitem() = default;
7372
};
7473

@@ -86,10 +85,6 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons
8685

8786
isminefilter filter = ISMINE_SPENDABLE;
8887

89-
if (ParseIncludeWatchonly(params[2], wallet)) {
90-
filter |= ISMINE_WATCH_ONLY;
91-
}
92-
9388
std::optional<CTxDestination> filtered_address{std::nullopt};
9489
if (!by_label && !params[3].isNull() && !params[3].get_str().empty()) {
9590
if (!IsValidDestinationString(params[3].get_str())) {
@@ -129,8 +124,6 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons
129124
item.nAmount += txout.nValue;
130125
item.nConf = std::min(item.nConf, nDepth);
131126
item.txids.push_back(wtx.GetHash());
132-
if (mine & ISMINE_WATCH_ONLY)
133-
item.fIsWatchonly = true;
134127
}
135128
}
136129

@@ -147,21 +140,17 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons
147140

148141
CAmount nAmount = 0;
149142
int nConf = std::numeric_limits<int>::max();
150-
bool fIsWatchonly = false;
151143
if (it != mapTally.end()) {
152144
nAmount = (*it).second.nAmount;
153145
nConf = (*it).second.nConf;
154-
fIsWatchonly = (*it).second.fIsWatchonly;
155146
}
156147

157148
if (by_label) {
158149
tallyitem& _item = label_tally[label];
159150
_item.nAmount += nAmount;
160151
_item.nConf = std::min(_item.nConf, nConf);
161-
_item.fIsWatchonly = fIsWatchonly;
162152
} else {
163153
UniValue obj(UniValue::VOBJ);
164-
if (fIsWatchonly) obj.pushKV("involvesWatchonly", true);
165154
obj.pushKV("address", EncodeDestination(address));
166155
obj.pushKV("amount", ValueFromAmount(nAmount));
167156
obj.pushKV("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
@@ -190,8 +179,6 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons
190179
CAmount nAmount = entry.second.nAmount;
191180
int nConf = entry.second.nConf;
192181
UniValue obj(UniValue::VOBJ);
193-
if (entry.second.fIsWatchonly)
194-
obj.pushKV("involvesWatchonly", true);
195182
obj.pushKV("amount", ValueFromAmount(nAmount));
196183
obj.pushKV("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
197184
obj.pushKV("label", entry.first);
@@ -210,7 +197,7 @@ RPCHelpMan listreceivedbyaddress()
210197
{
211198
{"minconf", RPCArg::Type::NUM, RPCArg::Default{1}, "The minimum number of confirmations before payments are included."},
212199
{"include_empty", RPCArg::Type::BOOL, RPCArg::Default{false}, "Whether to include addresses that haven't received any payments."},
213-
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true for watch-only wallets, otherwise false"}, "Whether to include watch-only addresses (see 'importaddress')"},
200+
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::Default{false}, "(DEPRECATED) No longer used"},
214201
{"address_filter", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "If present and non-empty, only return information on this address."},
215202
{"include_immature_coinbase", RPCArg::Type::BOOL, RPCArg::Default{false}, "Include immature coinbase transactions."},
216203
},
@@ -219,7 +206,6 @@ RPCHelpMan listreceivedbyaddress()
219206
{
220207
{RPCResult::Type::OBJ, "", "",
221208
{
222-
{RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/true, "Only returns true if imported addresses were involved in transaction"},
223209
{RPCResult::Type::STR, "address", "The receiving address"},
224210
{RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURRENCY_UNIT + " received by the address"},
225211
{RPCResult::Type::NUM, "confirmations", "The number of confirmations of the most recent transaction included"},
@@ -264,15 +250,14 @@ RPCHelpMan listreceivedbylabel()
264250
{
265251
{"minconf", RPCArg::Type::NUM, RPCArg::Default{1}, "The minimum number of confirmations before payments are included."},
266252
{"include_empty", RPCArg::Type::BOOL, RPCArg::Default{false}, "Whether to include labels that haven't received any payments."},
267-
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true for watch-only wallets, otherwise false"}, "Whether to include watch-only addresses (see 'importaddress')"},
253+
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::Default{false}, "(DEPRECATED) No longer used"},
268254
{"include_immature_coinbase", RPCArg::Type::BOOL, RPCArg::Default{false}, "Include immature coinbase transactions."},
269255
},
270256
RPCResult{
271257
RPCResult::Type::ARR, "", "",
272258
{
273259
{RPCResult::Type::OBJ, "", "",
274260
{
275-
{RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/true, "Only returns true if imported addresses were involved in transaction"},
276261
{RPCResult::Type::STR_AMOUNT, "amount", "The total amount received by addresses with this label"},
277262
{RPCResult::Type::NUM, "confirmations", "The number of confirmations of the most recent transaction included"},
278263
{RPCResult::Type::STR, "label", "The label of the receiving address. The default label is \"\""},
@@ -332,17 +317,12 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM
332317

333318
CachedTxGetAmounts(wallet, wtx, listReceived, listSent, nFee, filter_ismine, include_change);
334319

335-
bool involvesWatchonly = CachedTxIsFromMe(wallet, wtx, ISMINE_WATCH_ONLY);
336-
337320
// Sent
338321
if (!filter_label.has_value())
339322
{
340323
for (const COutputEntry& s : listSent)
341324
{
342325
UniValue entry(UniValue::VOBJ);
343-
if (involvesWatchonly || (wallet.IsMine(s.destination) & ISMINE_WATCH_ONLY)) {
344-
entry.pushKV("involvesWatchonly", true);
345-
}
346326
MaybePushAddress(entry, s.destination);
347327
entry.pushKV("category", "send");
348328
entry.pushKV("amount", ValueFromAmount(-s.amount));
@@ -372,9 +352,6 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM
372352
continue;
373353
}
374354
UniValue entry(UniValue::VOBJ);
375-
if (involvesWatchonly || (wallet.IsMine(r.destination) & ISMINE_WATCH_ONLY)) {
376-
entry.pushKV("involvesWatchonly", true);
377-
}
378355
MaybePushAddress(entry, r.destination);
379356
PushParentDescriptors(wallet, wtx.tx->vout.at(r.vout).scriptPubKey, entry);
380357
if (wtx.IsCoinBase())
@@ -450,14 +427,13 @@ RPCHelpMan listtransactions()
450427
"with the specified label, or \"*\" to disable filtering and return all transactions."},
451428
{"count", RPCArg::Type::NUM, RPCArg::Default{10}, "The number of transactions to return"},
452429
{"skip", RPCArg::Type::NUM, RPCArg::Default{0}, "The number of transactions to skip"},
453-
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true for watch-only wallets, otherwise false"}, "Include transactions to watch-only addresses (see 'importaddress')"},
430+
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::Default{false}, "(DEPRECATED) No longer used"},
454431
},
455432
RPCResult{
456433
RPCResult::Type::ARR, "", "",
457434
{
458435
{RPCResult::Type::OBJ, "", "", Cat(Cat<std::vector<RPCResult>>(
459436
{
460-
{RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/true, "Only returns true if imported addresses were involved in transaction."},
461437
{RPCResult::Type::STR, "address", /*optional=*/true, "The bitcoin address of the transaction (not returned if the output does not have an address, e.g. OP_RETURN null data)."},
462438
{RPCResult::Type::STR, "category", "The transaction category.\n"
463439
"\"send\" Transactions sent.\n"
@@ -510,10 +486,6 @@ RPCHelpMan listtransactions()
510486
nFrom = request.params[2].getInt<int>();
511487
isminefilter filter = ISMINE_SPENDABLE;
512488

513-
if (ParseIncludeWatchonly(request.params[3], *pwallet)) {
514-
filter |= ISMINE_WATCH_ONLY;
515-
}
516-
517489
if (nCount < 0)
518490
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count");
519491
if (nFrom < 0)
@@ -559,7 +531,7 @@ RPCHelpMan listsinceblock()
559531
{
560532
{"blockhash", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "If set, the block hash to list transactions since, otherwise list all transactions."},
561533
{"target_confirmations", RPCArg::Type::NUM, RPCArg::Default{1}, "Return the nth block hash from the main chain. e.g. 1 would mean the best block hash. Note: this is not used as a filter, but only affects [lastblock] in the return value"},
562-
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true for watch-only wallets, otherwise false"}, "Include transactions to watch-only addresses (see 'importaddress')"},
534+
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::Default{false}, "(DEPRECATED) No longer used"},
563535
{"include_removed", RPCArg::Type::BOOL, RPCArg::Default{true}, "Show transactions that were removed due to a reorg in the \"removed\" array\n"
564536
"(not guaranteed to work on pruned nodes)"},
565537
{"include_change", RPCArg::Type::BOOL, RPCArg::Default{false}, "Also add entries for change outputs.\n"},
@@ -572,7 +544,6 @@ RPCHelpMan listsinceblock()
572544
{
573545
{RPCResult::Type::OBJ, "", "", Cat(Cat<std::vector<RPCResult>>(
574546
{
575-
{RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/true, "Only returns true if imported addresses were involved in transaction."},
576547
{RPCResult::Type::STR, "address", /*optional=*/true, "The bitcoin address of the transaction (not returned if the output does not have an address, e.g. OP_RETURN null data)."},
577548
{RPCResult::Type::STR, "category", "The transaction category.\n"
578549
"\"send\" Transactions sent.\n"
@@ -638,10 +609,6 @@ RPCHelpMan listsinceblock()
638609
}
639610
}
640611

641-
if (ParseIncludeWatchonly(request.params[2], wallet)) {
642-
filter |= ISMINE_WATCH_ONLY;
643-
}
644-
645612
bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
646613
bool include_change = (!request.params[4].isNull() && request.params[4].get_bool());
647614

@@ -701,8 +668,7 @@ RPCHelpMan gettransaction()
701668
"Get detailed information about in-wallet transaction <txid>\n",
702669
{
703670
{"txid", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction id"},
704-
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true for watch-only wallets, otherwise false"},
705-
"Whether to include watch-only addresses in balance calculation and details[]"},
671+
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::Default{false}, "(DEPRECATED) No longer used"},
706672
{"verbose", RPCArg::Type::BOOL, RPCArg::Default{false},
707673
"Whether to include a `decoded` field containing the decoded transaction (equivalent to RPC decoderawtransaction)"},
708674
},
@@ -719,7 +685,6 @@ RPCHelpMan gettransaction()
719685
{
720686
{RPCResult::Type::OBJ, "", "",
721687
{
722-
{RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/true, "Only returns true if imported addresses were involved in transaction."},
723688
{RPCResult::Type::STR, "address", /*optional=*/true, "The bitcoin address involved in the transaction."},
724689
{RPCResult::Type::STR, "category", "The transaction category.\n"
725690
"\"send\" Transactions sent.\n"
@@ -767,10 +732,6 @@ RPCHelpMan gettransaction()
767732

768733
isminefilter filter = ISMINE_SPENDABLE;
769734

770-
if (ParseIncludeWatchonly(request.params[1], *pwallet)) {
771-
filter |= ISMINE_WATCH_ONLY;
772-
}
773-
774735
bool verbose = request.params[2].isNull() ? false : request.params[2].get_bool();
775736

776737
UniValue entry(UniValue::VOBJ);

src/wallet/rpc/util.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,6 @@ bool GetAvoidReuseFlag(const CWallet& wallet, const UniValue& param) {
2929
return avoid_reuse;
3030
}
3131

32-
/** Used by RPC commands that have an include_watchonly parameter.
33-
* We default to true for watchonly wallets if include_watchonly isn't
34-
* explicitly set.
35-
*/
36-
bool ParseIncludeWatchonly(const UniValue& include_watchonly, const CWallet& wallet)
37-
{
38-
if (include_watchonly.isNull()) {
39-
// if include_watchonly isn't explicitly set, then check if we have a watchonly wallet
40-
return wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
41-
}
42-
43-
// otherwise return whatever include_watchonly was set to
44-
return include_watchonly.get_bool();
45-
}
46-
4732
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest& request, std::string& wallet_name)
4833
{
4934
if (request.URI.starts_with(WALLET_ENDPOINT_BASE)) {

src/wallet/rpc/util.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ void EnsureWalletIsUnlocked(const CWallet&);
4343
WalletContext& EnsureWalletContext(const std::any& context);
4444

4545
bool GetAvoidReuseFlag(const CWallet& wallet, const UniValue& param);
46-
bool ParseIncludeWatchonly(const UniValue& include_watchonly, const CWallet& wallet);
4746
std::string LabelFromValue(const UniValue& value);
4847
//! Fetch parent descriptors of this scriptPubKey.
4948
void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey, UniValue& entry);

src/wallet/rpc/wallet.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ RPCHelpMan simulaterawtransaction()
573573
},
574574
{"options", RPCArg::Type::OBJ_NAMED_PARAMS, RPCArg::Optional::OMITTED, "",
575575
{
576-
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true for watch-only wallets, otherwise false"}, "Whether to include watch-only addresses (see RPC importaddress)"},
576+
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::Default{false}, "(DEPRECATED) No longer used"},
577577
},
578578
},
579579
},
@@ -595,22 +595,7 @@ RPCHelpMan simulaterawtransaction()
595595

596596
LOCK(wallet.cs_wallet);
597597

598-
UniValue include_watchonly(UniValue::VNULL);
599-
if (request.params[1].isObject()) {
600-
UniValue options = request.params[1];
601-
RPCTypeCheckObj(options,
602-
{
603-
{"include_watchonly", UniValueType(UniValue::VBOOL)},
604-
},
605-
true, true);
606-
607-
include_watchonly = options["include_watchonly"];
608-
}
609-
610598
isminefilter filter = ISMINE_SPENDABLE;
611-
if (ParseIncludeWatchonly(include_watchonly, wallet)) {
612-
filter |= ISMINE_WATCH_ONLY;
613-
}
614599

615600
const auto& txs = request.params[0].get_array();
616601
CAmount changes{0};

test/functional/rpc_psbt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ def run_test(self):
828828

829829
# Test that psbts with p2pkh outputs are created properly
830830
p2pkh = self.nodes[0].getnewaddress(address_type='legacy')
831-
psbt = self.nodes[1].walletcreatefundedpsbt([], [{p2pkh : 1}], 0, {"includeWatching" : True}, True)
831+
psbt = self.nodes[1].walletcreatefundedpsbt(inputs=[], outputs=[{p2pkh : 1}], bip32derivs=True)
832832
self.nodes[0].decodepsbt(psbt['psbt'])
833833

834834
# Test decoding error: invalid base64

test/functional/wallet_balance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ def run_test(self):
8383
assert_equal(self.nodes[0].getbalance("*"), 50)
8484
assert_equal(self.nodes[0].getbalance("*", 1), 50)
8585
assert_equal(self.nodes[0].getbalance(minconf=1), 50)
86-
assert_equal(self.nodes[0].getbalance(minconf=0, include_watchonly=True), 50)
86+
assert_equal(self.nodes[0].getbalance(minconf=0), 50)
8787
assert_equal(self.nodes[0].getbalance("*", 1, True), 50)
88-
assert_equal(self.nodes[1].getbalance(minconf=0, include_watchonly=True), 50)
88+
assert_equal(self.nodes[1].getbalance(minconf=0), 50)
8989

9090
# Send 40 BTC from 0 to 1 and 60 BTC from 1 to 0.
9191
txs = create_transactions(self.nodes[0], self.nodes[1].getnewaddress(), 40, [Decimal('0.01')])

test/functional/wallet_basic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ def run_test(self):
532532
assert_equal(address_info['address'], "mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ")
533533
assert_equal(address_info["scriptPubKey"], "76a9144e3854046c7bd1594ac904e4793b6a45b36dea0988ac")
534534
assert not address_info["ismine"]
535-
assert not address_info["iswatchonly"]
536535
assert not address_info["isscript"]
537536
assert not address_info["ischange"]
538537

test/functional/wallet_fundrawtransaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ def test_all_watched_funds(self):
781781
self.nodes[3].loadwallet('wwatch')
782782
wwatch = self.nodes[3].get_wallet_rpc('wwatch')
783783
w3 = self.nodes[3].get_wallet_rpc(self.default_wallet_name)
784-
result = wwatch.fundrawtransaction(rawtx, includeWatching=True, changeAddress=w3.getrawchangeaddress(), subtractFeeFromOutputs=[0])
784+
result = wwatch.fundrawtransaction(rawtx, changeAddress=w3.getrawchangeaddress(), subtractFeeFromOutputs=[0])
785785
res_dec = self.nodes[0].decoderawtransaction(result["hex"])
786786
assert_equal(len(res_dec["vin"]), 1)
787787
assert res_dec["vin"][0]["txid"] == self.watchonly_utxo['txid']

0 commit comments

Comments
 (0)