From e6f4af9fd5c0c1dd7bbcbeca70e7399beb7acf9d Mon Sep 17 00:00:00 2001 From: Guido Diepen Date: Sat, 21 Jan 2017 08:04:37 +0100 Subject: [PATCH] Implemented getunusedaddress command The implementation of the getunusedaddress will directly query the wallet for the first unused address --- lib/commands.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/commands.py b/lib/commands.py index 7eddbd699..daf8f98a3 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -563,6 +563,19 @@ class Commands: out = filter(lambda x: x.get('status')==f, out) return map(self._format_request, out) + @command('w') + def getunusedaddress(self,force=False): + """Returns the first unused address.""" + addr = self.wallet.get_unused_address() + if addr is None and force: + addr = self.wallet.create_new_address(False) + + if addr: + return addr + else: + return False + + @command('w') def addrequest(self, amount, memo='', expiration=None, force=False): """Create a payment request."""