Post
Topic
Board Bitcoin Technical Support
Re: IMPORTING PRIVATE KEY
by
ETFbitcoin
on 09/09/2021, 09:34:50 UTC
A simple python script can be used to import them to Electrum or Bitcoin Core.

Electrum won't work in this case, because
1. Electrum use JSON as wallet format, which isn't scalable for million addresses.
2. By default, Electrum server limit request amount to prevent DDoS, so sync process will take very long time.
3. And few other reason i currently don't remember.

One script is for IMPORT and one is for EXPORT

Good Luck!

Code:
#Import.py
#
from bitcoin.core import COIN
import bitcoin.rpc
bitcoin.SelectParams("mainnet")

proxy = bitcoin.rpc.Proxy()
with open("priv.txt")  as f:
    lines = f.readlines()

i = 1
for line in lines:
    addr = line.strip()
    #print (addr)
    print (i)
    print(proxy.call("importprivkey", addr,  "ImportWrongWalletAddr" + str(i),  False))

Don't forget to add i = i + 1 inside loop or use enumerate (for i, line in enumerate(lines):), otherwise all address will have exactly same label.