我尝试连接检查BTC地址的数量(使用私钥)。 我在文件里有地址和钥匙。当我直接编写var时,它是python脚本,但当我尝试从文件中对var执行相同的操作时,它不起作用。我已经检查了我的变量后,从文件(打印),我也检查了他们的类型,这是字符串。我也试图str()我的两个变量,但它没有改变什么。我在windows上使用python3.4,在windows上使用api区块链.info. 这里是git文档:https://github.com/blockchain/api-v1-client-python/blob/master/docs/wallet.md
sortieFichier = open(fichierSortie, 'a')
fd = open(fichierClef, 'r')
n = 0
miniCompt=0
aTrouver=": "
for line in fd:
n += 1
miniCompt+= 1
#extract the adress from the file
if(miniCompt==1):
adressBTC=str(line)
tronc = adressBTC.find(aTrouver)
adressBTC =adressBTC[len(aTrouver)+tronc:]
if(miniCompt==2):
# exctract the key
clefBTC=str(line)
tronc = clefBTC.find(aTrouver)
clefBTC =str(clefBTC[len(aTrouver)+tronc:])
print(clefBTC) # = 5J6jgMj4FhcT9y1###########################
print(adressBTC) # = 1CBXtLZdv4jN9LGF5Dbs##############
print(isinstance(clefBTC,int)) # return true
# connect with the function to check the wallet
wallet = Wallet(clefBTC, '')
addr = wallet.get_address(adressBTC, confirmations = 2) # Ligne 37 HERE ERROR
amount=addr.balance
amount=amount/100000000
print(amount)
if(amount>0):
sortieFichier.write(adressBTC)
sortieFichier.write(clefBTC)
sortieFichier.write(amount)
miniCompt=0
fd.close()
这里是错误:
True
Traceback (most recent call last):
File "C:\Python34\Lib\site-packages\blockchain\monScript.py", line 37, in <mod
ule>
addr = wallet.get_address(adressBTC, confirmation
s = 2)
File "C:\Python34\lib\site-packages\blockchain\wallet.py", line 133, in get_ad
dress
response = util.call_api("merchant/{0}/address_balance".format(self.identifi
er), params)
File "C:\Python34\lib\site-packages\blockchain\util.py", line 23, in call_api
response = urlopen(BASE_URL + resource, payload, timeout = TIMEOUT).read()
File "C:\Python34\lib\urllib\request.py", line 153, in urlopen
return opener.open(url, data, timeout)
File "C:\Python34\lib\urllib\request.py", line 453, in open
req = meth(req)
File "C:\Python34\lib\urllib\request.py", line 1097, in do_request_
raise URLError('no host given')
urllib.error.URLError: <urlopen error no host given>
这很奇怪,因为如果我写的是key/address而不是var,那么它就是工作的:
wallet = Wallet('5J6jgMj4FhcT9y1###########################', '')
addr = wallet.get_address('1CBXtLZdv4jN9LGF5Dbs##############', confirmations = 2)
我很抱歉我的英语不好,我仍然愿意进一步解释
不可见字符到这里来:adressBTC=adressBTC[len(aTrouver)+tronc:] 因此,由于adresse的大小总是相同的(等同于key),我会: adressBTC=adressBTC[长度(A)+特朗克:伦(阿托鲁弗)+tronc+34]
相关问题 更多 >
编程相关推荐