GithubHelp home page GithubHelp logo

ascribe / transactions Goto Github PK

View Code? Open in Web Editor NEW
115.0 115.0 20.0 124 KB

๐Ÿ“Ÿ transactions: Bitcoin for humans

License: Apache License 2.0

Python 99.58% Dockerfile 0.42%
bitcoin cryptocurrency python

transactions's People

Contributors

sbellem avatar timdaub avatar trentmc avatar ttmc avatar

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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

transactions's Issues

rename simple_transaction to create

this is more of a proposal with the intent of simplifying the interface

Transaction.create()

appears simpler and less redundant than

Transaction.simple_transaction()

Handle when there are 0 transactions

I'm getting this error when trying to build a simple_transaction and the address returns 0 transactions. Was a bit confusing initially:

File "/usr/local/lib/python2.7/site-packages/transactions/services/blockrservice.py", line 50, in list_transactions
    for tx in results['txs']:
TypeError: list indices must be integers, not unicode

When the response data looks like this:

[{u'txs': [], u'limit_txs': 200, u'nb_txs': 0, u'nb_txs_displayed': 0, u'address': u"(u''"}, {u'txs': [], u'limit_txs': 200, u'nb_txs': 0, u'nb_txs_displayed': 0, u'address': u" u'1Lo9DHhZZsoZJdyVrkcTot3Ha6mjNcmgw7')"}]

flatten the structure by bringing services modules up and possibly merging some togther

mainly for simplification purposes, such that instead of having something like:

class transactions.services.service.BitcoinService(testnet=False)

we can have something like:

class transactions.services.BitcoinService(testnet=False)

and perhaps, simplifying further:

class transactions.services.Bitcoin(testnet=False)

or alternatively:

class transactions.BitcoinService(testnet=False)

transaction error

Traceback (most recent call last):
  File "/home/semyon/Programming/Python/bitcoin/main.py", line 8, in <module>
    tx = transactions.create(alice, (bob, 117432))
  File "/home/semyon/Programming/Python/bitcoin/venv/lib/python3.6/site-packages/transactions/transactions.py", line 114, in simple_transaction
    inputs, change = self._select_inputs(from_address, amount, n_outputs, min_confirmations=min_confirmations)
  File "/home/semyon/Programming/Python/bitcoin/venv/lib/python3.6/site-packages/transactions/transactions.py", line 172, in _select_inputs
    unspents = self.get(address, min_confirmations=min_confirmations)['unspents']
  File "/home/semyon/Programming/Python/bitcoin/venv/lib/python3.6/site-packages/transactions/transactions.py", line 84, in get
    txs = self._service.list_transactions(hash, account=account, max_transactions=max_transactions)
  File "/home/semyon/Programming/Python/bitcoin/venv/lib/python3.6/site-packages/transactions/services/blockrservice.py", line 43, in list_transactions
    results = self.make_request(url)
  File "/home/semyon/Programming/Python/bitcoin/venv/lib/python3.6/site-packages/transactions/services/blockrservice.py", line 33, in make_request
    data = response.json()
  File "/home/semyon/Programming/Python/bitcoin/venv/lib/python3.6/site-packages/requests/models.py", line 896, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Process finished with exit code 1

code:

from transactions import Transactions
alice = 'mwPGBZJFoiELLADPES6E4JphUbw25Ju923'
bob = 'mySjpEjdrGsfhnmgX7rtcTtb7R9XGauwiV'
transactions = Transactions(testnet=True)
tx = transactions.create(alice, (bob, 6117432))
tx_signed = transactions.sign(tx, 'cTKusFK7wT8eGPXbfqLWJgQUEyg37BJmHpMJJ5ze3S******')
transactions.push(tx_signed)

rename sign_transaction to sign

since sign_transaction is a member method of Transactions sign would be sufficient

more clearly:

Transactions.sign_transaction()

could be simplified to:

Transactions.sign()

cannot import name 'Transactions'

from transactions import Transactions
Traceback (most recent call last):
File "", line 1, in
File "/home/ubuntu/env/lib/python3.5/site-packages/transactions/init.py", line 1, in
from transactions import Transactions # noqa
ImportError: cannot import name 'Transactions'

rename build_transaction to build, _build, or create_helper

a proposal to simplify the interface and remove redundancy

Transaction.build()

appears simpler and less redundant than

Transaction.build_transaction()

Since build_transaction appears to be more of a helper method to support simple_transaction, perhaps we could name it _build() to emphasize it is meant to be used more as an internal helper method.

Also, if we do rename simple_transaction to create as proposed in issue #12 build and create are somewhat synonymous, so perhaps using _build could help in preventing confusion.

Or perhaps, a more explicit name such as create_helper could be better.

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.