I am looking for a way to extract all of the public keys associated with my electrum wallet. I am aware that listaddresses() does this for public addresses, such as 1CWX7o1Ppe4JpEpSLmuovU4HFY3D6Ay24C - however, I am looking to extract the public keys, such as 02b96c2739e9543bdc17bbe58b73a3a9a16aedf2ed554faca9e5acf0b279f5d0e1.
2 Answers
You cannot get all of them in one go. You can call getpubkeys("address")
for each address (or do it via the GUI by going to the Addresses tab, right clicking on an address, and selecting "Public Keys")
Alternatively, you can get your master public keys (xpub) and derive from those.
-
Thank you for the input! Would I be better off generating them directly from the xPub using something that generates addresses in the same fashion?– cpe871Commented Jul 28, 2018 at 8:58
-
If you're doing it often enough, having the xpub will likely help/save time. Electrum's client is open source, so you should be able to find the xpub->address code in there, and plenty of implementations exist in other languages Commented Jul 28, 2018 at 9:07
The following code worked for me in the Electrum console and was able to give me all of the addresses in a single command.
for i in listaddresses(): print(i + " = " + getpubkeys(i)[0])