Open hasanparasteh opened 1 year ago
Yeah I need to print 100 different keys and addresses and it only prints the same ones each time I run it. How do I get it to print different keys so I don't have to run the python file 100 different times?
SOLUTION: Use wallet = Wallet()
every time you need new keys. Because whenever you get a private key using a function like wallet.key.__dict__['mainnet'].__dict__['wif']
for example, it is still referencing that same wallet
variable that was declared earlier.
For example, this is my script:
from bitcoinaddress import Wallet
privs = []
pubs = []
addrs = []
i = -1
for i in range(100):
wallet = Wallet()
privs.append(wallet.key.__dict__['mainnet'].__dict__['wif'])
pubs.append(wallet.address.__dict__['pubkey'])
addrs.append(wallet.address.__dict__['mainnet'].__dict__['pubaddr1'])
for i in privs:
print(i)
print()
for i in pubs:
print(i)
print()
for i in addrs:
print(i)
(At first i had the wallet = Wallet()
before the for loop)
@hasanparasteh You need to use the last part of the documentation: https://github.com/fortesp/bitcoinaddress?tab=readme-ov-file#example-4---check-attributes to get specific data from the wallet. You can also use for loops to get multiple addresses.
This library print the address data very pretty but when you want to use it's API to get some information out of it and get different addresses it become really frustrating..Please review and setup some helper functions to retrieve each address accordingly