blockio / block_io-python Goto Github PK
View Code? Open in Web Editor NEWPython library for Block.io
License: MIT License
Python library for Block.io
License: MIT License
when i am trying to withdraw funds from one wallet to other wallet it is throwing the error:
TypeError: Odd-length string
from_label : deposit279943213
to_label: withdraw294302757
and the Traceback is:
File "C:\Users\Co-Admin\workspace\subcryptshares\Txns\Txns.py", line 98, in pay_sponsor
blockio.withdraw_funds(source, str(balance), target)
File "C:\Users\Co-Admin\workspace\subcryptshares\SubBlockio\Blockio.py", line 26, in withdraw_funds
reply = self.block_io.withdraw_from_addresses(amounts=amount, from_addresses=source, to_addresses=target)
File "C:\Python27\lib\site-packages\block_io_init_.py", line 171, in withdraw_hook
return self.withdraw_meta(attr, **kwargs)
File "C:\Python27\lib\site-packages\block_io_init_.py", line 237, in withdraw_meta
key = self.Helper.extractKey(response['data']['encrypted_passphrase']['passphrase'], self.encryption_key)
File "C:\Python27\lib\site-packages\block_io_init_.py", line 100, in extractKey
return BlockIo.Key.from_passphrase(unhexlify(decrypted))
TypeError: Odd-length string
Looks like block.io API servers have issues (getting Bad Gateway now and then). This makes block.io Python client melt in smoldering ashes. Like:
File "/home/ubuntu/src/bitbucket.org/miohtama/cryptoassets/venv/lib/python3.4/site-packages/block_io/__init__.py", line 253, in api_call
if ('error_message' in response['data'].keys()):
KeyError: 'data'
[2015-01-12 13:27:37,608] cryptoassets.core.tools.broadcast send_broadcasts():183 'data'
Traceback (most recent call last):
File "/home/ubuntu/src/bitbucket.org/miohtama/cryptoassets/cryptoassets/core/tools/broadcast.py", line 177, in send_broadcasts
txid, fee = self.backend.send(outgoing, "Outgoing broadcast {}".format(b.id))
File "/home/ubuntu/src/bitbucket.org/miohtama/cryptoassets/cryptoassets/core/backend/blockio.py", line 136, in send
resp = self.block_io.withdraw(amounts=",".join(amounts), to_addresses=",".join(addresses))
File "/home/ubuntu/src/bitbucket.org/miohtama/cryptoassets/venv/lib/python3.4/site-packages/block_io/__init__.py", line 146, in withdraw_hook
return self.withdraw_meta(attr, **kwargs)
File "/home/ubuntu/src/bitbucket.org/miohtama/cryptoassets/venv/lib/python3.4/site-packages/block_io/__init__.py", line 224, in withdraw_meta
response = self.api_call('sign_and_finalize_withdrawal', **args)
File "/home/ubuntu/src/bitbucket.org/miohtama/cryptoassets/venv/lib/python3.4/site-packages/block_io/__init__.py", line 253, in api_call
if ('error_message' in response['data'].keys()):
KeyError: 'data'
It could be ideal to add some defensive programming to block.io API client, so that it displays friendlier exception Got 500 Internal Server Error from API server and possible raise APICallFailed() exception, so that the client application can gracefully handle the situation.
I'm trying to run: examples\sweep.py
says
module 'block_io' has no attribute 'prepare_sweep_transaction'
When doing pip install block_io
on Python 3 you get:
Downloading/unpacking block-io
Downloading block-io-1.0.6.tar.gz
Running setup.py (path:/Users/mikko/code/cryptoassets/venv/build/block-io/setup.py) egg_info for package block-io
Requirement already satisfied (use --upgrade to upgrade): requests in /Users/mikko/code/cryptoassets/venv/lib/python3.4/site-packages (from block-io)
Downloading/unpacking pycrypto (from block-io)
Downloading pycrypto-2.6.1.tar.gz (446kB): 446kB downloaded
Running setup.py (path:/Users/mikko/code/cryptoassets/venv/build/pycrypto/setup.py) egg_info for package pycrypto
Downloading/unpacking hashlib (from block-io)
Downloading hashlib-20081119.zip (42kB): 42kB downloaded
Running setup.py (path:/Users/mikko/code/cryptoassets/venv/build/hashlib/setup.py) egg_info for package hashlib
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/Users/mikko/code/cryptoassets/venv/lib/python3.4/site-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extension import Extension
File "/Users/mikko/code/cryptoassets/venv/lib/python3.4/site-packages/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/Users/mikko/code/cryptoassets/venv/lib/python3.4/site-packages/setuptools/dist.py", line 15, in <module>
from setuptools.compat import numeric_types, basestring
File "/Users/mikko/code/cryptoassets/venv/lib/python3.4/site-packages/setuptools/compat.py", line 48, in <module>
import http.client as httplib
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 69, in <module>
import email.parser
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/email/feedparser.py", line 27, in <module>
from email import message
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/email/message.py", line 15, in <module>
from email import utils
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/email/utils.py", line 28, in <module>
import random
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/random.py", line 45, in <module>
from hashlib import sha512 as _sha512
File "/Users/mikko/code/cryptoassets/venv/build/hashlib/hashlib.py", line 80
raise ValueError, "unsupported hash type"
^
SyntaxError: invalid syntax
Apparently some of the dependencies refer to (old?) versions which are not Python 3 compatible. I'll see if I can get bottom of this.
The preferred method of installing packages in Python is virtualenv.
https://packaging.python.org/en/latest/installing.html
Is it ok to update the README?
I am member in Block.io from autumn 2014. I asked a Litecoin withdrawal before a few minutes. Your system says that: Unexpected character in line 1 column 1. I can't withdraw my Dogecoins too. I am waiting for the solution. Thank you.
Hi,
When signing a p2pkh I think your lib adds SIGHASH_ALL redundantly since it's already added by btc util lib:
secretkey.sign_input()
sighash=SIGHASH_ALL
signature += struct.pack('B', sighash)
your's
signature_with_sighash(signature, sighash = constants.SIGHASH_ALL)
return hexlify(unhexlify(signature) + (sighash).to_bytes(1, byteorder="big"))
thus creating 193vbyte length instead of 192 vBytes
How come this passed test cases and never caused problem?
I've been having trouble trying to get a balance from a label address and withdraw all of it. An error is raised saying that I don't have enough when I try to withdraw the whole balance - obviously - due to network fees. But using the block_io.get_network_fee_estimate
method returns the wrong fee amount for bitcoin, so I can't subtract that from the address balance either. Is there a better way to withdraw the maximum amount from an address?
How to change label?
setup.py now declares version pindowns for its dependencies. This is not the best practice - it makes it troublematic to deploy block.io library with your application if your application happens to use other minor version of these packages.
setup.py should declare versionless dependencies only. For the reference, and for the CI testing, one can supply referential requirements.txt
which known good set of absolute versions of dependencies. Then you can mix block.io requirements.txt
with your application requirements.txt
.
Further read about the topic:
Hello,
There is a vulnerability in pycrypto : https://security-tracker.debian.org/tracker/CVE-2013-7459
The migration to pycryptodome should be pretty easy as it implement the same functions.
__init__.py
declares its own version as:
VERSION = "1.0.6"
This should be unnecessary as nowadays one can use pkg_utils
to query the installed version of distutils packages.
Hi,
I tried to spend from uncompressed P2PKH (don't laugh :)
but I think the generated signature is invalid for that.
get_address()
has default parameter compressed=True
thus generating invalid h160 into scriptsig.
elif cur_address_type == 'P2PKH' or cur_address_type == 'P2WPKH-over-P2SH' or cur_address_type == 'P2WPKH':
pkh_script = get_output_script(PublicKey(cur_public_keys[0]).get_address().to_string())
It should select compressed parameter based on first byte of provided pubkey '02'/'04' to compressed=True/False
Just a note, bytes and strings are mixed in the lib.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.