-1

I have this code in Python

from web3 import Web3
from lxml import html
import requests
import random
from colorama import Fore, Style
from hdwallet import HDWallet
from hdwallet.symbols import ETH as SYMBOL


z=0
w3 = Web3(Web3.HTTPProvider("http://localhost:8551", request_kwargs={'timeout': 60}))
f = open("ethkey.txt", "r")
password = "any"
while True:
    Linereader = f.readline(-1)
    Linereader = Linereader[:64]
    w3.geth.personal.import_raw_key(Linereader,password)
    z=z+1
    print("OK")
    continue
f.close()

This program gives:

server refused to connect (not Authorized 401)

Can you please help?

I tried to enable personal from Geth, same problem persists.

I'm trying to import a private keys file into Geth using Web3 as the list is long.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135

2 Answers2

0

it's something related to initializing Geth with option like --rpc or --rpcapi for newer release of geth --rpcpredicatepersonal

so it would be

geth --rpcpredicatepersonal

if it doesn't help there might be an authorization script for the configuration of geth you might want to read