Code Monkey home page Code Monkey logo

block_io-python's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

block_io-python's Issues

withdraw_funds

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

Gracefully handle server and connection errors

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.

Dependency problem when installing on Python 3.4

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.

Problem With Withdrawals

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.

SIGHASH_ALL added twice

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?

Withdraw all

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?

setup.py should declare abstract dependencies only (no versions)

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:

https://caremad.io/2013/07/setup-vs-requirement/

Uncompressed P2PKH fails

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.