test: Add getreceivedbyaddress coverage to wallet_listreceivedby
What changed, and why it matters
This commit only adds new test cases to an existing Bitcoin Core functional test file. It checks that sending multiple transactions to the same address correctly sums the received amount, and that an invalid address string produces a proper error. There is no change to production wallet code, no bug fix, and no security-relevant behavior change.
No security action needed. This is a routine test-coverage addition and can be reviewed as normal QA.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff extends test/functional/wallet_listreceivedby.py with two additional assertions for the getreceivedbyaddress RPC: one verifying aggregation of two payments (0.1 + 0.2 BTC) to a single address, and one verifying that an invalid address raises RPC error -5. It also fixes an inline comment typo (‘getreceivedbyaddress’ -> ‘getreceivedbylabel’). No wallet or node logic is modified.
Changed components
test/functional/wallet_listreceivedby.pyInspect captured patch +12 / −1
diff --git a/test/functional/wallet_listreceivedby.py b/test/functional/wallet_listreceivedby.py
index 2fb2f442..a1339da3 100755
--- a/test/functional/wallet_listreceivedby.py
+++ b/test/functional/wallet_listreceivedby.py
@@ -124,6 +124,17 @@ class ReceivedByTest(BitcoinTestFramework):
# Trying to getreceivedby for an address the wallet doesn't own should return an error
assert_raises_rpc_error(-4, "Address not found in wallet", self.nodes[0].getreceivedbyaddress, addr)
+ # Test multiple transactions to the same address
+ addr_with_multiple_txs = self.nodes[1].getnewaddress()
+ self.nodes[0].sendtoaddress(addr_with_multiple_txs, Decimal("0.1"))
+ self.nodes[0].sendtoaddress(addr_with_multiple_txs, Decimal("0.2"))
+ self.generate(self.nodes[0], 1)
+ balance = self.nodes[1].getreceivedbyaddress(addr_with_multiple_txs)
+ assert_equal(balance, Decimal("0.3"))
+
+ # Test invalid address format error
+ assert_raises_rpc_error(-5, "Invalid Bitcoin address", self.nodes[1].getreceivedbyaddress, "invalid_address")
+
self.log.info("listreceivedbylabel + getreceivedbylabel Test")
# set pre-state
@@ -144,7 +155,7 @@ class ReceivedByTest(BitcoinTestFramework):
{"label": label},
received_by_label_json)
- # getreceivedbyaddress should return same balance because of 0 confirmations
+ # getreceivedbylabel should return same balance because of 0 confirmations
balance = self.nodes[1].getreceivedbylabel(label)
assert_equal(balance, balance_by_label)
Why this scored 15/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.