Python Forum
Помощь по приватным ключам/Private key help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Помощь по приватным ключам/Private key help
#1
Есть в наличии 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

подскажите что за ошибки и как исправить,может другой скрипт есть? Спасибо!
Reply
#2
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).
Recommended Tutorials:
Reply
#3
Попробуй изменить строку 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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

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

I run the script on windows 7
Reply
#5
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Lint and private var names PatM 1 656 Dec-15-2022, 05:08 PM
Last Post: deanhystad
  Unable to import Private Repo using setup.py Bob786 1 1,706 Sep-02-2021, 04:19 PM
Last Post: snippsat
  python 3 dns lookup private domain didact 1 2,501 Sep-19-2020, 06:01 PM
Last Post: bowlofred
  [split] Помощь по приватным ключам/Private key help sairam17519 0 1,578 Sep-07-2020, 12:55 PM
Last Post: sairam17519
  Download file from Private GitHub rep vinuvt 0 1,930 Jul-27-2020, 11:38 AM
Last Post: vinuvt
  Private package distribution abomination disadvantages research andreir 2 2,117 May-07-2020, 12:32 AM
Last Post: andreir
  when to make attributes private? sneakyimp 10 5,776 Jan-21-2019, 02:54 PM
Last Post: sneakyimp
  Fetching private ip address from instances of an autoscaling group deepsonune 0 3,244 May-18-2018, 10:32 AM
Last Post: deepsonune
  Inheritance private attributes vaison 5 12,623 May-03-2018, 09:22 AM
Last Post: vaison
  Can access class private variable? Michael 2 7,145 Aug-11-2017, 01:59 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020