Skip to content

Commit b6f58d6

Browse files
committed
Merge #210: Added generatetoaddress(self,numblocks,addr) to rpc.py
6fa8b95 Added generatetoaddress(self,numblocks,addr), replacing generate(self,numblocks) which will be dropped in bitcoin-core v0.19 (alexei.zamyatin) Pull request description: Fixing #209 Added `generatetoaddress(self,numblocks,addr)` to rpc.py, which should replace `generate(self,numblocks)`. The latter will be dropped in bitcoin-core v0.19. Keeping `generate(self,numblocks)` for now (for backward compatibility) Tree-SHA512: cfd676fa852c57663186b952d6c0015cbc8d6f79f532b061c438389db6bff33489b8d18ce87cb4205a69b9b78d9688fd94f9dc698d2b895b989f23706014b817
2 parents c6617fc + 6fa8b95 commit b6f58d6

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

bitcoin/rpc.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,30 @@ def fundrawtransaction(self, tx, include_watching=False):
381381
return r
382382

383383
def generate(self, numblocks):
384-
"""Mine blocks immediately (before the RPC call returns)
384+
"""
385+
DEPRECATED (will be removed in bitcoin-core v0.19)
386+
387+
Mine blocks immediately (before the RPC call returns)
385388
386389
numblocks - How many blocks are generated immediately.
387390
388391
Returns iterable of block hashes generated.
389392
"""
390393
r = self._call('generate', numblocks)
391394
return (lx(blk_hash) for blk_hash in r)
395+
396+
def generatetoaddress(self, numblocks, addr):
397+
"""Mine blocks immediately (before the RPC call returns) and
398+
allocate block reward to passed address. Replaces deprecated
399+
"generate(self,numblocks)" method.
400+
401+
numblocks - How many blocks are generated immediately.
402+
addr - Address to receive block reward (CBitcoinAddress instance)
403+
404+
Returns iterable of block hashes generated.
405+
"""
406+
r = self._call('generatetoaddress', numblocks, str(addr))
407+
return (lx(blk_hash) for blk_hash in r)
392408

393409
def getaccountaddress(self, account=None):
394410
"""Return the current Bitcoin address for receiving payments to this

0 commit comments

Comments
 (0)