Python Forum

Full Version: Помощь по приватным ключам/Private key help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Есть в наличии 300-500 приват. получить адреса и проверить баланс? Посоветовали скрипт для Python2.7

!/usr/bin/python
from pybitcoin import BitcoinPrivateKey
import requests
import json

FILE_PATH = r'ТУТ ВРУЧНУЮ ВВЕДИ ПУТЬ ДО ФАЙЛА С КЛЮЧАМИ'

with open(FILE_PATH) as f:
    keys = f.read().splitlines()

for key in keys:
    private_key = BitcoinPrivateKey(private_key=key)

    public_key = private_key.public_key()
    address = public_key.address()

    r = requests.get('https://chain.so/api/v2/address/BTC/{}'.format(address))
    print ('Address: {} Private Key: {} Balance: {}'.format(address, key, (json.loads(r.content)['data']['balance'])))
преобразовал txt в py в скрипте указал путь до ключей, вышло вот так:

https://prnt.sc/mxnoxb

запустил cmd и при запуске происходит ошибка:

https://prnt.sc/mxnq80

подскажите что за ошибки и как исправить,может другой скрипт есть? Спасибо!
Most people here speak English. The fact that you half posted the title as English, but not the question confuses me. You would get more responses if you posted the question in English (at least as an alternative).
Попробуй изменить строку 13 следующим образом

!/usr/bin/python
from pybitcoin import BitcoinPrivateKey
import requests
import json
 
FILE_PATH = r'ТУТ ВРУЧНУЮ ВВЕДИ ПУТЬ ДО ФАЙЛА С КЛЮЧАМИ'
 
with open(FILE_PATH) as f:
    keys = f.read().splitlines()
 
for key in keys:
    private_key = BitcoinPrivateKey(private_key=key.strip())
 
    public_key = private_key.public_key()
    address = public_key.address()
 
    r = requests.get('https://chain.so/api/v2/address/BTC/{}'.format(address))
    print ('Address: {} Private Key: {} Balance: {}'.format(address, key, (json.loads(r.content)['data']['balance'])))
Я думаю, проблема в том, что ключ имеет символ новый строки '\n' в конце

For english speakers:
I think the problem is with new line char at the end of key
corrected code
http://prntscr.com/myby57
it turned out like this
http://prntscr.com/mybz2v

I run the script on windows 7
Please, don't post images
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.

Unfortunately I don't see what else could be suggested.


Also , the indentation I have tried to fix is not correct and should be:

!/usr/bin/python
from pybitcoin import BitcoinPrivateKey
import requests
import json
  
FILE_PATH = r'ТУТ ВРУЧНУЮ ВВЕДИ ПУТЬ ДО ФАЙЛА С КЛЮЧАМИ'
  
with open(FILE_PATH) as f:
    keys = f.read().splitlines()
  
for key in keys:
    private_key = BitcoinPrivateKey(private_key=key.strip())
  
    public_key = private_key.public_key()
    address = public_key.address()
  
    r = requests.get('https://chain.so/api/v2/address/BTC/{}'.format(address))
    print ('Address: {} Private Key: {} Balance: {}'.format(address, key, (json.loads(r.content)['data']['balance'])))
Note it's not related to your problem
sorry i will stick to your rules.
suggested that the private key format should be in base 58 I have 5KZZnig72wUkKR4QcNcUHpbCfAGUgjP5Nwc j9vGfsWmcdjvZKWg
Can you tell me how to check the balance of private keys?