https://bitcoincore.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1-x86_64-linux-gnu.tar.gz
Problem: listreceivedbyaddress always returns an empty array for a watch-only wallet when it’s of type descriptor (not legacy). This problem doesn’t occur with a legacy watch-only wallet, only a descriptor watch-only wallet.
Apparent reason: bitcoind thinks the addresses are for change.
Work-around: When importing descriptors, set active=true.
Thanks to achow101 on IRC Libera Chat #bitcoin-core-dev, 2023-01-04.
0$ cat $HOME/data1/bitcoin.conf
1printtoconsole=1
2regtest=1
3txindex=1
4[regtest]
5port=18444
6rpcport=18443
7
8$ $HOME/bitcoin-24.0.1/bin/bitcoin-qt -datadir=$HOME/data1 -server -fallbackfee=0.00001 &
9
10$ cat bcli.sh
11#!/bin/bash
12$HOME/bitcoin-24.0.1/bin/bitcoin-cli -datadir=$HOME/data1 "$@"
13
14
15$ bcli.sh createwallet w1
16$ bcli.sh createwallet w2 true true
17$ bcli.sh -rpcwallet=w1 listdescriptors
18...
19 {
20 "desc": "wpkh([577ce3ca/84'/1'/0']tpubDCNwCevBBSLGZm5d2urnpLDD2B4s5dWf7TRigFngte9M7sijNQg6QVjq1K7Nb7uLAP7xLn2h4X1MoiT3JmMP3sQYuKsY1qnPj1HR63hQDuT/0/*)#cw6xz6mx",
21 "timestamp": 1672848018,
22 "active": true,
23 "internal": false,
24 "range": [
25 0,
26 999
27 ],
28 "next": 0
29 },
30...
31
32$ bcli.sh -rpcwallet=w2 importdescriptors "[{\"desc\": \"wpkh([577ce3ca/84'/1'/0']tpubDCNwCevBBSLGZm5d2urnpLDD2B4s5dWf7TRigFngte9M7sijNQg6QVjq1K7Nb7uLAP7xLn2h4X1MoiT3JmMP3sQYuKsY1qnPj1HR63hQDuT/0/*)#cw6xz6mx\", \"timestamp\": 0, \"range\": 999}]"
33
34$ bcli.sh -rpcwallet=w1 getnewaddress
35bcrt1qxu3fl6lyqydvtgxsdpeu69gyywy2dya5a4kray
36
37$ bcli.sh -rpcwallet=w1 generatetoaddress 101 bcrt1qxu3fl6lyqydvtgxsdpeu69gyywy2dya5a4kray
38
39$ bcli.sh -rpcwallet=w2 listreceivedbyaddress 1 true true "" true
40[
41]