0

I'm trying to convert a txt of WIF to Public Address but only convert the last line, if someone knows another way to do, i really appreciate

from hdwallet import HDWallet
from hdwallet.symbols import BTC as SYMBOL
import sys
import os
import json
import requests
from requests import get


with open('/content/wif.txt') as f:
  for line in f:
    wif = line.rstrip()

# Initialize Bitcoin testnet HDWallet
hdwallet: HDWallet = HDWallet(symbol=SYMBOL)
# Get Bitcoin HDWallet from wallet important format
hdwallet.from_wif(wif=WALLET_IMPORTANT_FORMAT)

# Print all Bitcoin HDWallet information's
#print(json.dumps(hdwallet.dumps(), indent=4, ensure_ascii=False))


print(hdwallet.p2pkh_address()), (hdwallet.wif())

1 Answer 1

0
from hdwallet import HDWallet
from hdwallet.symbols import BTC as SYMBOL


All_WIF = []

with open('/content/wif.txt') as f:
    data = f.readlines()
    for i in data:
        wif = i.strip('\n')
        All_WIF.append(wif.rstrip())

for each_wif in All_WIF:
    # Initialize Bitcoin testnet HDWallet
    hdwallet: HDWallet = HDWallet(symbol=SYMBOL)
    # Get Bitcoin HDWallet from wallet important format
    hdwallet.from_wif(wif=each_wif)
    print("Addrss: " + hdwallet.p2pkh_address() + '    WIF: ' + hdwallet.wif())
1
  • bro thanks for saving my life Jun 25, 2023 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.