Bitcoin Forum
May 04, 2024, 06:37:18 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: List addresses!  (Read 1480 times)
cooltoadfrommoon (OP)
Copper Member
Member
**
Offline Offline

Activity: 242
Merit: 12


View Profile
June 17, 2014, 01:23:06 PM
 #1

Can somebody tell me the console command to get an output of 50 unused addresses from my client?

Also is there a documentation how exactly the MPK works?
1714804638
Hero Member
*
Offline Offline

Posts: 1714804638

View Profile Personal Message (Offline)

Ignore
1714804638
Reply with quote  #2

1714804638
Report to moderator
1714804638
Hero Member
*
Offline Offline

Posts: 1714804638

View Profile Personal Message (Offline)

Ignore
1714804638
Reply with quote  #2

1714804638
Report to moderator
1714804638
Hero Member
*
Offline Offline

Posts: 1714804638

View Profile Personal Message (Offline)

Ignore
1714804638
Reply with quote  #2

1714804638
Report to moderator
"Your bitcoin is secured in a way that is physically impossible for others to access, no matter for what reason, no matter how good the excuse, no matter a majority of miners, no matter what." -- Greg Maxwell
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714804638
Hero Member
*
Offline Offline

Posts: 1714804638

View Profile Personal Message (Offline)

Ignore
1714804638
Reply with quote  #2

1714804638
Report to moderator
1714804638
Hero Member
*
Offline Offline

Posts: 1714804638

View Profile Personal Message (Offline)

Ignore
1714804638
Reply with quote  #2

1714804638
Report to moderator
dabura667
Sr. Member
****
Offline Offline

Activity: 475
Merit: 252


View Profile
June 17, 2014, 01:32:16 PM
 #2

1.
Code:
wallet.storage.put('gap_limit', 50)

2. close, reopen electrum

3.
Code:
listaddresses()



https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki

BIP32 was based off of Electrum. But slightly different.

For more details about mpk and its calculations, peek into your /lib/accounts.py file and you should find the code somewhere in there.

My Tip Address:
1DXcHTJS2DJ3xDoxw22wCt11FeAsgfzdBU
Abdussamad
Legendary
*
Offline Offline

Activity: 3612
Merit: 1564



View Profile
June 17, 2014, 03:41:39 PM
 #3

He wants only unused addresses. listaddresses will show all main account addresses including used ones.

Edit:
I think you have to combine listaddresses with getaddresshistory. Loop over the output of listaddresses and then use getaddresshistory on each of them. If getaddresshistory returns empty then that's an unused address.

For stuff like this I prefer the command line rather than the elecrum console:

Code:
electrum listaddresses
electrum getaddresshistory 1BitcoinEaterAddressDontSendf59kuE

Electrum spawns a daemon process when you use the command line so multiple requests are more efficient. Still, getaddresshistory takes a few seconds per address so perhaps there is a more efficient way?
cooltoadfrommoon (OP)
Copper Member
Member
**
Offline Offline

Activity: 242
Merit: 12


View Profile
June 17, 2014, 04:10:56 PM
 #4

Thank you for your thorough answers Smiley


Still it is a lot to repeat manually.

Another solution would be to just generate 50 new addresses and show them to me.

How can I do this?
dabura667
Sr. Member
****
Offline Offline

Activity: 475
Merit: 252


View Profile
June 17, 2014, 04:35:28 PM
 #5

Another solution would be to just generate 50 new addresses and show them to me.

What is your definition of "new"?

Do you mean new addresses that are NOT a part of your seed?

If you want addresses that are a part of your seed, then what is your idea of "new"?

One that is not showing in the receive tab?

One that has not been used before? But is it ok if it's been shown on the receive tab before?



I think maybe it would be better to tell us what you want to do rather than asking how to make addresses.

My Tip Address:
1DXcHTJS2DJ3xDoxw22wCt11FeAsgfzdBU
cooltoadfrommoon (OP)
Copper Member
Member
**
Offline Offline

Activity: 242
Merit: 12


View Profile
June 17, 2014, 05:09:08 PM
Last edit: June 17, 2014, 06:22:37 PM by cooltoadfrommoon
 #6

My main goal is to get a list of all unused addresses from my Electrum in a way that I can copy and paste them without doing that manually Smiley

Excellent would be if I were able to output them to a csv or simple textfile.

Or simply generate a specific amount of new addresses (50) and export these into a text file.

Of course they all belong to the same wallet and its seed & master public key.

With "unused" I mean -> receiving addresses that did not receive anything at all yet.
cooltoadfrommoon (OP)
Copper Member
Member
**
Offline Offline

Activity: 242
Merit: 12


View Profile
June 18, 2014, 10:23:35 AM
 #7

Any ideas?
dabura667
Sr. Member
****
Offline Offline

Activity: 475
Merit: 252


View Profile
June 18, 2014, 11:38:42 AM
Last edit: June 18, 2014, 03:31:37 PM by dabura667
 #8

Any ideas?

EDIT:
Here, I made a one line command window command that will generate a number of addresses for you that are related to your seed. combine it with two other lines (3 commands in a row) to get the addresses you want.

1. set an array called "addy" (line 1)
2. change the 50 in range(0,50) to tell the number of addresses you want to generate. However, from that number, any addresses with a history will be removed in the 3rd step. Also, the 0 can be changed to pick a staring point. (0 is first address, 1 is second address, 2 is third address, etc.)
3. just run the third line as is. It will print out all the addresses that don't have a tx history.
(Remember, don't copy over the ">>" when inputting)

Code:
>> addy = []
>> for i in range(0,50): addy.append(bitcoin.public_key_to_bc_address(('04' + '%064x' % (bitcoin.ecdsa.ellipticcurve.Point(bitcoin.ecdsa.ecdsa.curve_secp256k1, int(wallet.storage.get('master_public_key')[:64],16), int(wallet.storage.get('master_public_key')[64:],16), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141L) + (int(bitcoin.Hash("%d:%d:"%(i,0) + wallet.storage.get('master_public_key').decode('hex')).encode('hex'),16) * bitcoin.ecdsa.ellipticcurve.Point(bitcoin.ecdsa.ecdsa.curve_secp256k1, 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798L, 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8L, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141L))).x() + '%064x' % (bitcoin.ecdsa.ellipticcurve.Point(bitcoin.ecdsa.ecdsa.curve_secp256k1, int(wallet.storage.get('master_public_key')[:64],16), int(wallet.storage.get('master_public_key')[64:],16), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141L) + (int(bitcoin.Hash("%d:%d:"%(i,0) + wallet.storage.get('master_public_key').decode('hex')).encode('hex'),16) * bitcoin.ecdsa.ellipticcurve.Point(bitcoin.ecdsa.ecdsa.curve_secp256k1, 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798L, 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8L, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141L))).y()).decode('hex')))
>> print "\n".join(i for i in addy if len(wallet.history.get(i,{})) == 0)




VVV---OLD---VVV

Code:
print "\n".join(i for i in wallet.addresses() if len(wallet.history.get(i,{})) == 0 and not wallet.is_change(i))

Paste this into your console and it will only list addresses with 0 transaction history AND that are NOT CHANGE ADDRESSES.
NOTE: THIS WILL NOT LIST ADDRESSES WITH TRANSACTION HISTORY, EVEN WITH 0 BALANCE.

Notice the number of addresses listed will = your gap_limit. So before using the above command, use:

Code:
wallet.storage.put('gap_limit', XX)

1. Replace XX with the number of addresses you wish to generate, and then restart Electrum.
2. Run the "print "\n".join..." command
3. Copy the list that comes out of the console.

I think that electrum's console doesn't have a limit to the number of lines that can be displayed, but if you have any problems let me know.

My Tip Address:
1DXcHTJS2DJ3xDoxw22wCt11FeAsgfzdBU
cooltoadfrommoon (OP)
Copper Member
Member
**
Offline Offline

Activity: 242
Merit: 12


View Profile
June 18, 2014, 06:15:17 PM
 #9

Excellent !

I love this Community !

Thank you guys & especially DABURA!
Perlover
Full Member
***
Offline Offline

Activity: 162
Merit: 109


View Profile
January 04, 2017, 10:36:21 AM
 #10

Code:
print "\n".join(i for i in wallet.addresses() if len(wallet.history.get(i,{})) == 0 and not wallet.is_change(i))

This doesn't work in Electrum 2.7.12
Code:
>> print "\n".join(i for i in wallet.addresses() if len(wallet.history.get(i,{})) == 0 and not wallet.is_change(i))
Traceback (most recent call last):
AttributeError: 'Standard_Wallet' object has no attribute 'addresses'
Sad
Perlover
Full Member
***
Offline Offline

Activity: 162
Merit: 109


View Profile
January 04, 2017, 10:42:15 AM
 #11

I saw sources of electrum-ltc ( https://github.com/pooler/electrum-ltc/blob/master/lib/wallet.py#L1431 ) and changed line to:
Code:
print "\n".join(i for i in wallet.get_receiving_addresses() if len(wallet.history.get(i,{})) == 0)
Now it works! Smiley
ogrebao
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
January 13, 2018, 09:32:32 PM
 #12

Electrum 3.04, command doesn't work (syntax error)
Abdussamad
Legendary
*
Offline Offline

Activity: 3612
Merit: 1564



View Profile
January 14, 2018, 06:26:28 AM
 #13

This thread is old. Use addrequest with the --force option to get unused addresses: https://bitcointalk.org/index.php?topic=2721832.msg27959367#msg27959367 . Use it in a loop if you want lots of addresses.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!