Python Forum
Помощь по приватным ключам/Private key help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Помощь по приватным ключам/Private key help (/thread-16797.html)



Помощь по приватным ключам/Private key help - vlrubl777 - Mar-15-2019

Есть в наличии 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

подскажите что за ошибки и как исправить,может другой скрипт есть? Спасибо!


RE: Помощь по приватным ключам/Private key help - metulburr - Mar-15-2019

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).


RE: Помощь по приватным ключам/Private key help - buran - Mar-15-2019

Попробуй изменить строку 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


RE: Помощь по приватным ключам/Private key help - vlrubl777 - Mar-15-2019

corrected code
http://prntscr.com/myby57
it turned out like this
http://prntscr.com/mybz2v

I run the script on windows 7


RE: Помощь по приватным ключам/Private key help - buran - Mar-15-2019

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


RE: Помощь по приватным ключам/Private key help - vlrubl777 - Mar-15-2019

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?