Merge bitcoin/bitcoin#36864: rpc: deprecate iswatchonly field of getaddressinfo
What changed, and why it matters
This change hides an old, always-false field called 'iswatchonly' from the getaddressinfo API response unless the user explicitly asks for deprecated features. It is a routine cleanup, not a security fix, and does not change how wallets or funds are protected.
No security action needed. Users or integrations relying on getaddressinfo['iswatchonly'] should migrate before the field is removed in a future release.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deprecates the ‘iswatchonly’ field returned by the getaddressinfo RPC. Since PR #32618 the field has always been false; this commit makes it appear only when -deprecatedrpc=iswatchonly is set, matching the pattern used for other deprecated RPC fields. The change updates RPC result documentation, conditionally pushes the field, and adjusts functional tests accordingly.
Changed components
src/wallet/rpc/addresses.cpptest/functional/rpc_deprecated.pytest/functional/wallet_descriptor.pydoc/release-notes-36864.mdInspect captured patch +16 / −3
### doc/release-notes-36864.md
@@ -0,0 +1,7 @@
+Updated RPCs
+------------
+
+- The `getaddressinfo` RPC no longer returns the `iswatchonly` field unless
+ the configuration option `-deprecatedrpc=iswatchonly` is used. The field has
+ always been `false` since v30 and will be fully removed in the next major
+ release. (#36864)
### src/wallet/rpc/addresses.cpp
@@ -425,7 +425,7 @@ RPCMethod getaddressinfo()
{RPCResult::Type::STR, "address", "The bitcoin address validated."},
{RPCResult::Type::STR_HEX, "scriptPubKey", "The hex-encoded output script generated by the address."},
{RPCResult::Type::BOOL, "ismine", "If the address is yours."},
- {RPCResult::Type::BOOL, "iswatchonly", "(DEPRECATED) Always false."},
+ {RPCResult::Type::BOOL, "iswatchonly", /*optional=*/true, "(DEPRECATED, returned only if config option -deprecatedrpc=iswatchonly is passed) Always false."},
{RPCResult::Type::BOOL, "solvable", "If we know how to spend coins sent to this address, ignoring the possible lack of private keys."},
{RPCResult::Type::STR, "desc", /*optional=*/true, "A descriptor for spending coins sent to this address (only when solvable)."},
{RPCResult::Type::STR, "parent_desc", /*optional=*/true, "The descriptor used to derive this address if this is a descriptor wallet"},
@@ -522,7 +522,9 @@ RPCMethod getaddressinfo()
}
}
- ret.pushKV("iswatchonly", false);
+ if (pwallet->chain().rpcEnableDeprecated("iswatchonly")) {
+ ret.pushKV("iswatchonly", false);
+ }
UniValue detail = DescribeWalletAddress(*pwallet, dest);
ret.pushKVs(std::move(detail));
### test/functional/rpc_deprecated.py
@@ -37,6 +37,9 @@ def run_test(self):
for rpc in (wallet.bumpfee, wallet.psbtbumpfee):
assert_raises_rpc_error(-32, "start the RPC server with the `-deprecatedrpc=confTarget`", rpc, "0" * 64, {"confTarget": 1})
+ self.log.info("Test getaddressinfo iswatchonly field deprecation")
+ assert "iswatchonly" not in wallet.getaddressinfo(wallet.getnewaddress())
+
if __name__ == '__main__':
DeprecatedRpcTest(__file__).main()
### test/functional/wallet_descriptor.py
@@ -28,7 +28,7 @@ class WalletDescriptorTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
- self.extra_args = [['-keypool=100']]
+ self.extra_args = [['-keypool=100', '-deprecatedrpc=iswatchonly']]
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
@@ -104,6 +104,7 @@ def run_test(self):
addr_info = wallet.getaddressinfo(addr)
assert addr_info['desc'].startswith('pkh(')
assert_equal(addr_info['hdkeypath'], 'm/44h/1h/0h/0/0')
+ assert_equal(addr_info['iswatchonly'], False)
addr = wallet.getnewaddress("", "p2sh-segwit")
addr_info = wallet.getaddressinfo(addr)Why this scored 20/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.