Skip to content

Commit 09add84

Browse files
committed
Merge bitcoin/bitcoin#32618: wallet: Remove ISMINE_WATCHONLY and watchonly from RPCs
b1a8ac0 doc: Release note for removed watchonly parameters and results (Ava Chow) 1571086 wallet: Remove ISMINE_WATCH_ONLY (Ava Chow) 4439bf4 wallet, spend: Remove fWatchOnly from CCoinControl (Ava Chow) 1337c72 wallet, rpc: Remove watchonly from RPCs (Ava Chow) e81d95d wallet: Remove watchonly balances (Ava Chow) d20dc9c wallet: Wallets without private keys cannot grind R (Ava Chow) 9991f49 test: Watchonly wallets should estimate larger size (Ava Chow) Pull request description: Descriptor wallets do not use the watchonly behavior as it is not possible to mix watchonly and non-watchonly in a descriptor wallet. With legacy wallets now removed, all of the watchonly handling and reporting code is no longer needed. This PR removes watchonly options and results from the RPCs and the handling of watchonly things from the wallet's internals. With all of the watchonly things removed, ISMINE_WATCH_ONLY is removed as well. Split from #32523 Depends on #32594 for tests that are easier to read ACKs for top commit: Eunovo: ACK bitcoin/bitcoin@b1a8ac0 maflcko: re-ACK b1a8ac0 🌈 rkrux: ACK b1a8ac0 furszy: light code review ACK b1a8ac0 Tree-SHA512: bc87f37a13294f7208991be8f93899b49e5bdf87c70e0f66d9c4cb09c03be6c202320406f27e9a35aa2f57319d19a3f0c07d5e5ddbc97c7edab165b1656d6612
2 parents 87ab691 + b1a8ac0 commit 09add84

23 files changed

+169
-266
lines changed

doc/release-notes-32618.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Wallet
2+
------
3+
4+
* Since descriptor wallets do not allow mixing watchonly and non-watchonly descriptors,
5+
the `include_watchonly` option (and its variants in naming) are removed from all RPCs
6+
that had it.
7+
* The `iswatchonly` field is removed from any RPCs that returned it.

src/wallet/coincontrol.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ class CCoinControl
8989
//! If true, the selection process can add extra unselected inputs from the wallet
9090
//! while requires all selected inputs be used
9191
bool m_allow_other_inputs = true;
92-
//! Includes watch only addresses which are solvable
93-
bool fAllowWatchOnly = false;
9492
//! Override automatic min/max checks on fee, m_feerate must be set if true
9593
bool fOverrideFeeRate = false;
9694
//! Override the wallet's m_pay_tx_fee if set

src/wallet/receive.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,10 @@ Balance GetBalance(const CWallet& wallet, const int min_depth, bool avoid_reuse)
263263
const int tx_depth{wallet.GetTxDepthInMainChain(wtx)};
264264

265265
if (!wallet.IsSpent(outpoint) && (allow_used_addresses || !wallet.IsSpentKey(txo.GetTxOut().scriptPubKey))) {
266-
// Get the amounts for mine and watchonly
266+
// Get the amounts for mine
267267
CAmount credit_mine = 0;
268-
CAmount credit_watchonly = 0;
269268
if (txo.GetIsMine() == ISMINE_SPENDABLE) {
270269
credit_mine = txo.GetTxOut().nValue;
271-
} else if (txo.GetIsMine() == ISMINE_WATCH_ONLY) {
272-
credit_watchonly = txo.GetTxOut().nValue;
273270
} else {
274271
// We shouldn't see any other isminetypes
275272
Assume(false);
@@ -278,13 +275,10 @@ Balance GetBalance(const CWallet& wallet, const int min_depth, bool avoid_reuse)
278275
// Set the amounts in the return object
279276
if (wallet.IsTxImmatureCoinBase(wtx) && wtx.isConfirmed()) {
280277
ret.m_mine_immature += credit_mine;
281-
ret.m_watchonly_immature += credit_watchonly;
282278
} else if (is_trusted && tx_depth >= min_depth) {
283279
ret.m_mine_trusted += credit_mine;
284-
ret.m_watchonly_trusted += credit_watchonly;
285280
} else if (!is_trusted && wtx.InMempool()) {
286281
ret.m_mine_untrusted_pending += credit_mine;
287-
ret.m_watchonly_untrusted_pending += credit_watchonly;
288282
}
289283
}
290284
}

src/wallet/receive.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ struct Balance {
4949
CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more
5050
CAmount m_mine_untrusted_pending{0}; //!< Untrusted, but in mempool (pending)
5151
CAmount m_mine_immature{0}; //!< Immature coinbases in the main chain
52-
CAmount m_watchonly_trusted{0};
53-
CAmount m_watchonly_untrusted_pending{0};
54-
CAmount m_watchonly_immature{0};
5552
};
5653
Balance GetBalance(const CWallet& wallet, int min_depth = 0, bool avoid_reuse = true);
5754

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/coins.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ RPCHelpMan getbalance()
171171
{
172172
{"dummy", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Remains for backward compatibility. Must be excluded or set to \"*\"."},
173173
{"minconf", RPCArg::Type::NUM, RPCArg::Default{0}, "Only include transactions confirmed at least this many times."},
174-
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true for watch-only wallets, otherwise false"}, "Also include balance in watch-only addresses (see 'importaddress')"},
174+
{"include_watchonly", RPCArg::Type::BOOL, RPCArg::Default{false}, "No longer used"},
175175
{"avoid_reuse", RPCArg::Type::BOOL, RPCArg::Default{true}, "(only available if avoid_reuse wallet flag is set) Do not include balance in dirty outputs; addresses are considered dirty if they have previously been used in a transaction."},
176176
},
177177
RPCResult{
@@ -203,13 +203,11 @@ RPCHelpMan getbalance()
203203

204204
const auto min_depth{self.Arg<int>("minconf")};
205205

206-
bool include_watchonly = ParseIncludeWatchonly(request.params[2], *pwallet);
207-
208206
bool avoid_reuse = GetAvoidReuseFlag(*pwallet, request.params[3]);
209207

210208
const auto bal = GetBalance(*pwallet, min_depth, avoid_reuse);
211209

212-
return ValueFromAmount(bal.m_mine_trusted + (include_watchonly ? bal.m_watchonly_trusted : 0));
210+
return ValueFromAmount(bal.m_mine_trusted);
213211
},
214212
};
215213
}

0 commit comments

Comments
 (0)