Giter Club home page Giter Club logo

moneywagon's Introduction

Imgur

moneywagon

Moneywagon is a an implementation of a Blockchain Kernel. It is a tool that can be used to built lightweight cryptocurrency wallets. Blockchain Kernels provide an alternative to the outdated "SPV" method of building lightweight cryptocurrency services.

Features

  • Lightweight wallet functionality - Use Moneywagon to build a bitcoin enabled device Works on all cryptocurrencies, including BTC, LTC, PPC, DOGE, VTC, MYR.
    1. Get current crypto/fiat exchange rate
    2. Get crypto balance for address
    3. Get historical transactions for crypto address
    4. Get unspent outputs
    5. Get historical crypto/fiat price.
    6. Get optimal transaction fee (BTC only)
    7. Generate new crypto private/pubic keys supporting both 'WIF' and 'compressed' encodings.

General Cryptocurrency Features:

  • Bip38 support
  • Multi-sig support - coming soon
  • HD-wallet support - coming soon

Prerequisites modules (for BIP38 & installation of module via pip)

$ pip install scrypt
$ pip install pycrypto

Installation

$ pip install moneywagon

Documentation

Contributing

If you would like to add a new service, feel free to make a pull request. If you discover a service is no longer working feel free to create a github issue and some will fix it shortly.

Donations

If you would like to send a donation to support development, please send BTC here: 1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X

moneywagon's People

Contributors

bitcoinssg avatar drewja avatar priestc avatar shivaenigma 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moneywagon's Issues

Corrections to the CLI parameters on the README

Some slight corrections to how it should be documented:

address-balance [address] [crypto]

moneywagon address-balance doge --address=D8ZXs3JDdLuyRjG3wDtRQE2PMT4YQWELfZ

Also works with the crypto trailing:
moneywagon address-balance --address=D8ZXs3JDdLuyRjG3wDtRQE2PMT4YQWELfZ doge
moneywagon address-balance --address=D8ZXs3JDdLuyRjG3wDtRQE2PMT4YQWELfZ doge --verbose --paranoid=3

single-transaction [crypto] [txid]

moneywagon single-transaction ppc --txid=6dddc4deb0806d987844b429e73b20ce5f0355407cce220130b5eac8fa13970e | python -mjson.tool

--paranoid= can be added
--verbose only works if you do not feed it to the json interpreter.

historical-transactions [crypto] [address]

moneywagon historical-transactions doge --address=D8ZXs3JDdLuyRjG3wDtRQE2PMT4YQWELfZ | python -m json.tool

get_single_transaction failing for block 0

  • Try get_single_transaction with 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b

These is due to the fact that both blockr and insight.bitpay somehow don't like this transaction. blockchain.info shows this, but doesn't seem to have implemented get_single_transaction

Can't use this code due to Serialization error in the __init--.py

Hello,
First, let me say that I really appreciate your efforts in creating this code-- thank you. It looks nice but I haven't been able to put it to practice. I've installed it under python 3.7 but I get the following kind of error:

from moneywagon import get_block
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\moneywagon__
init__.py", line 9, in
from .core import (
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\moneywagon\co
re.py", line 11, in
from bitcoin import serialize
ImportError: cannot import name 'serialize' from 'bitcoin' (C:\Users\user\AppData\Local\Program

I get this same kind of error on a linux machine as well under both python 2.7 and python 3 environment.
Secondly, cannot use $ moneywagon function at the command prompt to create keypairs.

Any suggestions?

Genesis block number

Again, playing around with this tool around the genesis block.

$ moneywagon get-block --block_number 0 btc
Traceback (most recent call last):
  File "/usr/local/bin/moneywagon", line 199, in <module>
    block_hash=argz.block_hash or '', latest=argz.latest or False, modes=modes
  File "/usr/local/bin/moneywagon", line 145, in prepare_json
    result = high_level_func(*args, **kwargs)
  File "/home/.../.local/lib/python2.7/site-packages/moneywagon/__init__.py", line 264, in get_block
    services, GetBlock, kwargs, modes=modes
  File "/home/.../.local/lib/python2.7/site-packages/moneywagon/core.py", line 490, in enforce_service_mode
    consensus_results = fetcher.action(**kwargs)
  File "/home/.../.local/lib/python2.7/site-packages/moneywagon/__init__.py", line 459, in action
    raise ValueError("Only one of `block_hash`, `latest`, or `block_number` allowed.")
ValueError: Only one of `block_hash`, `latest`, or `block_number` allowed.

I would expect the genesis block to be printed out, just like:
moneywagon get-block --block_hash 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f btc
Other block values do work.

Seems like a tiny default value (to zero) problem ^^ Keep up with the amazing work!

full api docs?

Hi. I'm looking into implementing a light wallet where the client only handles addresses and keys, and there's a server that provides the information about the blockchain. This library would be great for that because it lets me start with multiple currencies without having to host all the blockchains, but I have a few questions:

  • Is the full API documented in the README file? I'm missing a few things, like getting the balance of an address with a number of confirmations, or getting the unconfirmed balance, or getting specific information about transactions (like the scriptPubkey so I can sign it). Are those features available?
  • Is there a way to access this remotely, like via a json/http interfase?

Thanks!

Add support for Bitcoin Cash.

I can't find any public API available at the moment, but when they appear this would be a really nice to have for moneywagon.

get_single_transaction type of value field

  • While the type of value field in inputs is float, in output it is a unicode string. The expected type should be same in both cases
  • Also output of get_single_transaction in README doesn't match what we are getting actually
Got Response: https://insight.bitpay.com/api/tx/e91675777b5096e1549f5b493442b90abe9a3362944ac9d5f0b6bbe75d1a0140
{'inputs': [{'value': 566.53881077, 'address': u'15tYFmUV6wG4e1Gbi1buxBM9zSQzcWSkiK'}], 'total_out': 566.53714271, 'fee': 0.00166806, 'outputs': [{'value': u'0.90075063', 'address': u'19MGBhJbo6tk7iSxv7iXF7epCMEbdmhqm9'}, {'value': u'565.63639208', 'address': u'15tYFmUV6wG4e1Gbi1buxBM9zSQzcWSkiK'}], 'txid': u'e91675777b5096e1549f5b493442b90abe9a3362944ac9d5f0b6bbe75d1a0140', 'confirmations': 10, 'total_in': 566.53881077, 'time': datetime.datetime(2017, 3, 10, 2, 53, 26, tzinfo=tzutc())}

error on pip install...

Something goes wrong when it is looking for README.md...

$ pip install moneywagon

Collecting moneywagon
Using cached moneywagon-1.0.3.tar.gz
Traceback (most recent call last):
File "", line 20, in
File "/private/var/folders/qp/7w5k82s92rncmtd89bsrxw4w0000gn/T/pip-build-cjxtgwol/moneywagon/setup.py", line 9, in
long_description=open('README.md').read(),
FileNotFoundError: [Errno 2] No such file or directory: 'README.md'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

  File "<string>", line 20, in <module>

  File "/private/var/folders/qp/7w5k82s92rncmtd89bsrxw4w0000gn/T/pip-build-cjxtgwol/moneywagon/setup.py", line 9, in <module>

    long_description=open('README.md').read(),

FileNotFoundError: [Errno 2] No such file or directory: 'README.md'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/qp/7w5k82s92rncmtd89bsrxw4w0000gn/T/pip-build-cjxtgwol/moneywagon

can't search 'doge' from HistoricalTransactions()

Hi, when I try to use the HistoricalTransactions() function to search 'doge' the result didn't show up, but I try 'btc' it works, wonder if there's any bug or something I miss?

from moneywagon import HistoricalTransactions
x = HistoricalTransactions().action('doge', 'myaddress')
print(x)

Token support?

Hi @priestc, is it possible to deal with ERC20 tokens using this library? Would be really cool.

Altcoin support

Hey guys,

Can this library be used for any altcoin? I have currently setup my own cryptocoin which is based on litecoin, but this is limited to my test environment with no intention to do anything public with it.

You have a long list of supported cryptocurrency, but I feel like the library isn't designed to support arbitrary custom coin implementations?

Thanks in advance

generate_keypair doesn't work for certain cryptos

Here's the error message:

/moneywagon/__init__.py", line 333, in generate_keypair
    pub_byte, priv_byte = get_magic_bytes(crypto)
/moneywagon/core.py", line 823, in get_magic_bytes
    if priv_byte >= 128:
TypeError: '>=' not supported between instances of 'NoneType' and 'int'

This is happening because in core.py in get_magic_bytes function,

        pub_byte = crypto_data[crypto]['address_version_byte']
        priv_byte = crypto_data[crypto]['private_key_prefix']
        if priv_byte >= 128:
            priv_byte -= 128 #pybitcointools bug

Maybe we need to expand on currency support to accommodate this?

something like:

    support_categories = {
        'address': ['address_form', 'private_key_form'],
        'transaction': [ 'transaction_form', 'transaction_hash_algo', 'script_hash_algo'],
        'block': ['header_hash_algo'],
        'generate_keypair': ['address_version_byte', 'private_key_prefix'],
    }

Command line address-balance throwing an error

Installed via pip on OS X 10.11.5

All calls via the command line for address-balance give errors:

$ moneywagon address-balance doge D8ZXs3JDdLuyRjG3wDtRQE2PMT4YQWELfZ
usage: moneywagon [-h]
                  {current-price,generate-keypair,historical-price,address-balance,single-transaction,get-block,historical-transactions,sweep,unspent-outputs,explorer-urls,service-table,wallet-balance}
                  ...
moneywagon: error: unrecognized arguments: D8ZXs3JDdLuyRjG3wDtRQE2PMT4YQWELfZ

Or:

moneywagon address-balance btc 1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X --paranoid=5 --verbose
usage: moneywagon [-h]
                  {current-price,generate-keypair,historical-price,address-balance,single-transaction,get-block,historical-transactions,sweep,unspent-outputs,explorer-urls,service-table,wallet-balance}
                  ...
moneywagon: error: unrecognized arguments: 1HWpyFJ7N6rvFkq3ZCMiFnqM6hviNFmG5X

Function().get doesn't work

As per README.md
HistoricalTransactions().get('ltc', 'Lb78JDGxMcih1gs3AirMeRW6jaG5V9hwFZ')
AddressBalance().get('ppc', 'PVoei4A3TozCSK8W9VvS55fABdTZ1BCwfj')

don't work, instead Function().action() works.
Not sure if we want to fix doc or the function name.

Support parallel operation

Hi,
Logging this as a feature request. Feel free to ignore.

Today, I tried getting detail of all transactions in a block and it took half an hour. I feel it would be good moneywagon can natively support parallel operations

  • get_single_transaction_multi should does parallel requests to get tx details
  • can use a framework like tornado, eventlet
  • can be applied to other functions also

Process of transaction creation is broken

When I tried to create a transaction, I got such an error:

In [1]: from moneywagon.tx import Transaction

In [2]: tx = Transaction('dash')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-7aa0183c11b6> in <module>()
----> 1 tx = Transaction('dash')

/home/illia-v/.virtualenvs/crypto/local/lib/python2.7/site-packages/moneywagon/tx.pyc in __init__(self, crypto, hex, verbose)
     22 
     23         services = get_optimal_services(self.crypto, 'current_price')
---> 24         self.price_getter = CurrentPrice(services=services, verbose=verbose)
     25 
     26         if hex:

/home/illia-v/.virtualenvs/crypto/local/lib/python2.7/site-packages/moneywagon/core.pyc in __init__(self, services, verbose, responses, timeout, random_wait_seconds)
    363         for ServiceClass in services:
    364             self.services.append(
--> 365                 ServiceClass(verbose=verbose, responses=responses, timeout=timeout)
    366             )
    367 

TypeError: 'str' object is not callable

Looks like the process was broken by 3e1274a, when type of services current_price was transformed from list to dict.

Genesis transaction

I tried a bit of calls and while quering the genesis block and this related to it, I found out that its transaction fails. Yet most explorers display that transaction id for the genesis block (https://blockchain.info/fr/block-index/14849).
Anyway, I would expect that tool to return a valid output for that txid, even if genesis.

$ moneywagon single-transaction --txid=4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b btc
Traceback (most recent call last):
  File "/usr/local/bin/moneywagon", line 193, in <module>
    get_single_transaction, argz.crypto, **modes
  File "/usr/local/bin/moneywagon", line 145, in prepare_json
    result = high_level_func(*args, **kwargs)
  File "/home/.../.local/lib/python2.7/site-packages/moneywagon/__init__.py", line 202, in get_single_transaction
    services, SingleTransaction, {'crypto': crypto, 'txid': txid}, modes=modes
  File "/home/.../.local/lib/python2.7/site-packages/moneywagon/core.py", line 490, in enforce_service_mode
    consensus_results = fetcher.action(**kwargs)
  File "/home/.../.local/lib/python2.7/site-packages/moneywagon/__init__.py", line 446, in action
    return self._try_services("get_single_transaction", crypto, txid)
  File "/home/.../.local/lib/python2.7/site-packages/moneywagon/core.py", line 437, in _try_services
    raise NoService(self.no_service_msg(*args, **kwargs) + "! Tried: " + failed_msg)

moneywagon.core.NoService: Could not get transaction info for: btc:4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b! Tried: Bitpay Insight -> Skipped: 404 - Not Found, Blockr.io -> Skipped: 404 - Not Found, BlockCypher -> Skipped: 404 - Not Found, BlockExplorer.com -> Skipped: 404 - Not Found, Chain.So -> Skipped: 404 - Not Found, CoinPrism -> TypeError 'NoneType' object has no attribute '__getitem__', SmartBit -> KeyError 'transaction', LocalBitcoinsChain (Insight) -> Skipped: 404 - Not Found

recover gracefully on ssl error

(blockonomics)enigma@enigma-laptop:~/btxfees$ python main.py 1LuckyG4tMMZf64j6ea7JhCz7sDpk6vdcS -a 1.5
* Trying: <Service: CoinPrism (0 in cache)> btc 1luckyg4tmmzf64j6ea7jhcz7sdpk6vdcs
Traceback (most recent call last):
  File "main.py", line 32, in <module>
    main()
  File "main.py", line 29, in main
    get_txout(args.addresses)
  File "main.py", line 14, in get_txout
    get_unspent_outputs('btc', addr, random=True, verbose=True)
  File "/home/enigma/venvs/blockonomics/local/lib/python2.7/site-packages/moneywagon/__init__.py", line 53, in get_unspent_outputs
    services, UnspentOutputs, {'crypto': crypto, 'address': address}, modes=modes
  File "/home/enigma/venvs/blockonomics/local/lib/python2.7/site-packages/moneywagon/core.py", line 310, in enforce_service_mode
    return FetcherClass(services=services, verbose=verbose).action(**kwargs)
  File "/home/enigma/venvs/blockonomics/local/lib/python2.7/site-packages/moneywagon/__init__.py", line 223, in action
    return self._try_services('get_unspent_outputs', crypto=crypto, address=address)
  File "/home/enigma/venvs/blockonomics/local/lib/python2.7/site-packages/moneywagon/core.py", line 247, in _try_services
    ret =  getattr(service, method_name)(*args, **kwargs)
  File "/home/enigma/venvs/blockonomics/local/lib/python2.7/site-packages/moneywagon/services.py", line 501, in get_unspent_outputs
    for tx in self.get_url(url).json():
  File "/home/enigma/venvs/blockonomics/local/lib/python2.7/site-packages/moneywagon/core.py", line 44, in get_url
    return self._external_request('get', url, *args, **kwargs)
  File "/home/enigma/venvs/blockonomics/local/lib/python2.7/site-packages/moneywagon/core.py", line 66, in _external_request
    response = getattr(requests, method)(url, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 383, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 486, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 385, in send
    raise SSLError(e)
requests.exceptions.SSLError: hostname 'api.coinprism.com' doesn't match either of 'www.coinprism.com', 'coinprism.com'

Expected: FAIL and try next service
Also request timeout seems too large , maybe set to 3sec or give an option to set timeout

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.