Skip to content

Commit 6fa8b95

Browse files
Added generatetoaddress(self,numblocks,addr), replacing generate(self,numblocks) which will be dropped in bitcoin-core v0.19
1 parent c6617fc commit 6fa8b95

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)