From 089c883c558e01c2a18a92f861fa7de9a7cc607a Mon Sep 17 00:00:00 2001 From: pablomartin4btc Date: Thu, 6 Aug 2026 23:28:30 -0300 Subject: [PATCH] test: Add coverage for listreceivedby* excluding "send" addresses Regression test for #16159: an address labeled via setlabel by a wallet that doesn't own it is assigned a "send" purpose and must not appear in listreceivedbyaddress/listreceivedbylabel results, even with include_empty=true. Co-authored-by: Andreas Kouloumos --- test/functional/wallet_listreceivedby.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/functional/wallet_listreceivedby.py b/test/functional/wallet_listreceivedby.py index a1339da3463..f7a08ebd4ad 100755 --- a/test/functional/wallet_listreceivedby.py +++ b/test/functional/wallet_listreceivedby.py @@ -101,6 +101,17 @@ class ReceivedByTest(BitcoinTestFramework): res = self.nodes[1].listreceivedbyaddress(0, True, True, other_addr) assert_equal(len(res), 0) + self.log.info("listreceivedbyaddress and listreceivedbylabel exclude not owned addresses") + # setlabel assigns a "send" purpose when the wallet doesn't own the address. + send_label = "external-address" + external_addr = self.nodes[0].getnewaddress(send_label) + self.nodes[1].setlabel(external_addr, send_label) + assert_equal(self.nodes[1].getaddressinfo(external_addr)["ismine"], False) + assert_array_result(self.nodes[1].listreceivedbyaddress(minconf=0, include_empty=True), + {"address": external_addr}, {}, True) + assert_array_result(self.nodes[1].listreceivedbylabel(minconf=0, include_empty=True), + {"label": send_label}, {}, True) + self.log.info("getreceivedbyaddress Test") # Send from node 0 to 1