Title: Electrum 3.0.5 list receiving addresses Post by: smartwombat on August 31, 2018, 11:38:39 AM In the console, or in the wallet UI, how can I extract a list of only receiving addresses ?
>> listaddresses() Will return all addresses it seems, both change and receiving. In the UI on the addresses tab I can filter to just receiving or just change addresses. And then filter to unused, funded, used. But there appears no way to extract that list. Title: Re: Electrum 3.0.5 list receiving addresses Post by: HCP on August 31, 2018, 12:16:58 PM listaddresses() takes optional arguments...
Quote from: https://github.com/spesmilo/electrum/blob/6ee689345fdba24fddf0a719e906fed406e0d448/electrum/commands.py def listaddresses(self, receiving=False, change=False, labels=False, frozen=False, unused=False, funded=False, balance=False): """List wallet addresses. Returns the list of all addresses in your wallet. Use optional arguments to filter the results.""" So, listaddresses(True) will give you receive. listaddresses(False,True) will give you change... Title: Re: Electrum 3.0.5 list receiving addresses Post by: smartwombat on August 31, 2018, 02:03:44 PM Thanks for that.
Documentation, instead of reading the code, would be useful. Also the error reporting from the console is, how can I put it politely, sub-optimal. "Traceback (most recent call last):" tells me absolutely nothing useful when (not if) I make a mistake. For my use I think I need this: Code: listaddresses(True,False,False,False,True) So it appears that this code: Code: for addr in self.wallet.get_addresses(): Because unused was passed as True and it returns the same list as when left as default (=False). So perhaps self.wallet.is_used() doesn't mean what I guess it does. By adding random parentheses to a non-working example, I found this gets the unused addresses as well: Code: print ("\n".join(i for i in wallet.get_receiving_addresses() if len(wallet.history.get(i,{})) == 0)) Title: Re: Electrum 3.0.5 list receiving addresses Post by: jackg on August 31, 2018, 02:28:11 PM Quote from: https://github.com/spesmilo/electrum/blob/6ee689345fdba24fddf0a719e906fed406e0d448/electrum/commands.py def listaddresses(self, receiving=False, change=False, labels=False, frozen=False, unused=False, funded=False, balance=False): """List wallet addresses. Returns the list of all addresses in your wallet. Use optional arguments to filter the results.""" Based on what HCP posted, Can't you just use Code: listaddresses(true,false,false,false,true,false) Title: Re: Electrum 3.0.5 list receiving addresses Post by: HCP on September 01, 2018, 12:40:38 AM Thanks for that. You'll need to take that up with the devs... Documentation, instead of reading the code, would be useful. Quote Also the error reporting from the console is, how can I put it politely, sub-optimal. "Traceback (most recent call last):" tells me absolutely nothing useful when (not if) I make a mistake. The console is more or less a cut down Python console. So what you see is basically just a Python interpretor error... Unfortunately, these aren't very helpful a lot of the time :P Quote For my use I think I need this: Thankfully, I only have 23 rows to count... But using that command I get 22 returned... It is definitely leaving out the one address which received then spent all funds.Code: listaddresses(True,False,False,False,True) However there are 2 other addresses which have received, but are still included when unused=True... Quote So perhaps self.wallet.is_used() doesn't mean what I guess it does. I'd have to agree to a certain extent... I'm not 100% sure as I haven't gone digging into the code yet. Perhaps ask the devs direct on the Electrum GitHub?? https://github.com/spesmilo/electrum/issuesBased on what HCP posted, He said it didn't work... I've tested it and it "sort of" works... But perhaps not as one might imagine... So I think the definition of "unused" is slightly different to what the OP is expecting.Can't you just use Code: listaddresses(true,false,false,false,true,false) Also, note that you need to use True and False... Capitalisation is important. ;) |