listreceivedbyaddress incorrectly shows watchonly addresses as empty #10468

issue keystrike opened this issue on May 27, 2017
  1. keystrike commented at 3:05 PM on May 27, 2017: contributor

    The arguments are minconf, include_empty, and include_watchonly. If include_empty is true then watchonly addresses are returned as having a 0 balance even if they have a positive balance. Only when include_watchonly is also true do watchonly addresses with a balance return with their correct balance.

    When include_empty is true and include_watchonly is false then the watchonly addresses should not be returned at all.

    Example: $ ./bitcoin-cli listreceivedbyaddress 1 true [ { "address": "watch only", "account": "", "amount": 0.00000000, "confirmations": 0, "label": "", "txids": [ ] }, { "address": "address with privkey", "account": "", "amount": 0.00000000, "confirmations": 0, "label": "", "txids": [ ] } ]

    $ ./bitcoin-cli listreceivedbyaddress 1 true true [ { "address": "address with privkey", "account": "", "amount": 0.00000000, "confirmations": 0, "label": "", "txids": [ ] }, { "address": "watch only", "account": "", "amount": 1.0000000, "confirmations": 1234, "txids": [ ... ] } ]

  2. fanquake added the label RPC/REST/ZMQ on May 28, 2017
  3. Sjors commented at 3:10 PM on July 10, 2018: member

    Just noticed this while reviewing #9662. It's quite weird:

    $ src/bitcoin-cli -rpcwallet="hi" listreceivedbyaddress 0 true
    [
      {
        "address": "mzDWjPWzsNr7Nbd5rhC73MnmJt9L1Vd9CH",
        "account": "",
        "amount": 0.00000000,
        "confirmations": 0,
        "label": "",
        "txids": [
        ]
      }
    ]
    
    $ src/bitcoin-cli -rpcwallet="hi" listreceivedbyaddress 0 true true
    [
      {
        "involvesWatchonly": true,
        "address": "mzDWjPWzsNr7Nbd5rhC73MnmJt9L1Vd9CH",
        "account": "",
        "amount": 0.01000000,
        "confirmations": 0,
        "label": "",
        "txids": [
          "e710f6f7f1c9cd9e4cd86ec345d7058dd8236c717caf0e0088ad018c231cfa92"
        ]
      }
    ]
    
  4. kouloumos commented at 4:11 PM on August 3, 2022: contributor

    The expected behavior with listreceivedbyaddress is that when include_empty=true and include_watchonly=false the watchonly addresses should not be returned at all.

    What has been reported and what I was able to reproduce is that when watchonly addresses are not supposed to be included (include_watchonly=false), they are included if include_empty=true and are always returned as having 0 balance even if they have a positive balance.

    I was able to reproduced this using legacy wallets on regtest.

    • Preparation
      # create directories for nodes
      mkdir -p /tmp/node1-datadir
      mkdir -p /tmp/node2-datadir
      
      # run node1
      src/bitcoind -regtest -datadir=/tmp/node1-datadir
      
      # run node2
      src/bitcoind -regtest -datadir=/tmp/node2-datadir -rpcport=18300 -port=18400
      
      # (using variables for productivity)
      NODE1="src/bitcoin-cli -regtest -datadir=/tmp/node1-datadir"
      NODE2="src/bitcoin-cli -regtest -datadir=/tmp/node2-datadir -rpcport=18300"
      
      # create wallets (legacy) 
      $NODE1 -named createwallet wallet_name=wallet1 descriptors=false
      $NODE2 -named createwallet wallet_name=wallet2 descriptors=false
      
      watch_address=$($NODE1 getnewaddress) # generate address on node1
      $NODE2 importaddress $watch_address # add address as watchonly on node2
      
      
    • Observe issue when there is no balance in $watch_address.
      #  This returns nothing, **as expected**.
      $NODE2 -named listreceivedbyaddress include_empty=false include_watchonly={false,true}
      []
      
      # This should also return nothing, but it returns the empty $watch_address
      $NODE2 -named listreceivedbyaddress include_empty=true include_watchonly=false
      [
        {
          "address": $watch_address,
          "amount": 0.00000000,
          "confirmations": 0,
          "label": "",
          "txids": [
          ]
        }
      ]
      
    • Observe issue with balance in $watch_address.
      $NODE1 addnode 127.0.0.1:18400 "add"  # connect nodes 1->2
      $NODE1 generatetoaddress 101 $watch_address # mine blocks to address 
      
      # Correctly returns the watchonly address
      $NODE2 -named listreceivedbyaddress include_empty={false,true} include_watchonly=true
      [
        {
          "involvesWatchonly": true,
          "address": $watch_address,
          "amount": 50.00000000,
          "confirmations": 101,
          "label": "",
          "txids": [
            "c0be670898b208f156a7be5776b97f2c459e7056450ff10c66e0a2058352c319"
          ]
        }
      ]
      
      # Correctly returns nothing
      $NODE2 -named listreceivedbyaddress include_empty=false include_watchonly=false
      []
      
      # This should also return nothing , but it returns the empty $watch_address
      $NODE2 -named listreceivedbyaddress include_empty=true include_watchonly=false
      [
        {
          "address": $watch_address,
          "amount": 0.00000000,
          "confirmations": 0,
          "label": "",
          "txids": [
          ]
        }
      ]
      

    Note: The same behavior can also reproduced for the listreceivedbylabel RPC.

  5. willcl-ark commented at 2:55 PM on October 21, 2025: member

    It looks like this issue has been resolved by the descriptor wallet. If that’s not the case, please let us know by commenting here or opening a new issue.

  6. willcl-ark closed this on Oct 21, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me