Skip to content

Commit 6483d17

Browse files
committed
Merge pull request #31
454a80b Implemented getreceivedbyaddress RPC call (Blake Jakopovic)
2 parents a2ba0a8 + 454a80b commit 6483d17

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

bitcoin/rpc.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,21 @@ def getrawtransaction(self, txid, verbose=False):
322322

323323
return r
324324

325+
def getreceivedbyaddress(self, addr, minconf=1):
326+
"""Get the amount (in satoshi) received by <address> in transactions
327+
with at least [minconf] confirmations. It correctly handles the case
328+
where someone has sent to the address in multiple transactions.
329+
330+
Works only for addresses in the local wallet, external addresses will
331+
always show 0.
332+
333+
addr - The selected address.
334+
minconf - Only include transactions confirmed at least this many times. (default=1)
335+
"""
336+
addr = str(addr)
337+
r = self._call('getreceivedbyaddress', addr, minconf)
338+
return int(r*COIN)
339+
325340
def gettransaction(self, txid):
326341
"""Get detailed information about in-wallet transaction txid
327342

0 commit comments

Comments
 (0)