简体   繁体   English

我的var不适用于Blockchain API

[英]My var does not work with Blockchain API

I try to connect check the amount of an BTC adress ( with the private key ). 我尝试连接检查BTC地址的数量(使用私钥)。 I have the adress and key in a file. 我有一个文件中的地址和密钥。 When i write the var directly is the python script it's work's but when i try to do the same with the var from the file it does not work. 当我直接写var是python脚本它的工作,但是当我尝试对文件中的var做同样的事情时它不起作用。 I have check my var after take them from the file ( with print ) and i also have check their type which is String.I also try to str() my two var but it's change nothing. 从文件中取出后我检查了我的var(带打印),我也检查了它们的类型是String.I也尝试str()我的两个var但它没有改变。 I use python 3.4 on windows and the api from blockchain.info . 我在windows上使用python 3.4,在blockchain.info上使用api。 Here the git doc : https://github.com/blockchain/api-v1-client-python/blob/master/docs/wallet.md 这里是git doc: 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()

and here the error : 这里的错误:

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>

It's very strange because if i write the key/adress instead of the var it's work : 这很奇怪,因为如果我写密钥/地址而不是var它的工作:

wallet = Wallet('5J6jgMj4FhcT9y1###########################', '')
addr = wallet.get_address('1CBXtLZdv4jN9LGF5Dbs##############', confirmations = 2)

I apologize for my bad english and i'm still open for further explications 我为我糟糕的英语道歉,我仍然愿意接受进一步的解释

隐形字符来到这里:adressBTC = adressBTC [len(aTrouver)+ tronc:]因为adresse总是相同的大小(键的同义词)我做:adressBTC = adressBTC [len(aTrouver)+ tronc:len(aTrouver)+ tronc + 34]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过api检查我的blockchain.info钱包的历史记录 - check history of my blockchain.info wallet via api 为什么我对OVH的API调用在分配的ipBlock上不起作用? - Why does my API call to OVH not work on my allocated ipBlock? Sage的“var”如何运作? - How does Sage's “var” work? 因为我在var语句中无法按预期工作 - for i in var statement does not work as expected python使用var运行sql select不起作用 - python running sql select with var does not work 为什么我的 Google Translate API 可以在终端中运行,但不能在可执行文件中运行? - Why does my Google Translate API work in the terminal but not an executable? 为什么我的 api 在我的 python 代码中调用时在 Z945F3FC449518A73B9F5F26 中使用 ssh 调用时不起作用 - why does my api call in my python code not work when called using ssh in lambda 为什么BLOCKCHAIN.COM API只返回收件人BASE58地址而省略BECH32s? - Why does BLOCKCHAIN.COM API only return recipient BASE58 addresses and omits BECH32s? Python:var = var / 5 * 2 的计算结果与 var /= 5 * 2 不同 - Python: var = var / 5 * 2 does not evaluate the same as var /= 5 * 2 Queryset API distinct()不起作用? - Queryset API distinct() does not work?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM