forked from Python3pkg/Crypto-Balances
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of cryptobalances package. Currently only supports two …
…currencies: BTC and LTC
- Loading branch information
1 parent
9fc956b
commit 8eb4cae
Showing
6 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Package build | ||
/dist/* | ||
/cryptobalances.egg-info/* | ||
cryptobalances/__pycache__/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Crypto-Balances | ||
Python module for getting balance of varios crypto currency | ||
Python module for getting the balance of a various crypto currency. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Description | ||
=========== | ||
A module for getting the balance of wallet for various crypto currency. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .checker import get_balance | ||
__version__ = '0.9' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
import json | ||
import argparse | ||
from urllib.request import urlopen | ||
from urllib.error import URLError, HTTPError | ||
|
||
|
||
def get_balance(currency, identifier): | ||
api_url = {'ETH': 'http://api.etherscan.io/api?module=account&action=balance&address={identifier}&tag=latest', | ||
'BTC': 'https://chain.so/api/v2/get_address_balance/{network}/{identifier}', | ||
'LTC': 'https://chain.so/api/v2/get_address_balance/{network}/{identifier}', | ||
'DOGE': 'http://dogechain.info/api/v1/address/balance/{identifier}', | ||
'XCP': 'http://xcp.blockscan.com/api2?module=address&action=balance&btc_address={identifier}'} | ||
try: | ||
with urlopen(api_url[currency].format(network=currency, identifier=identifier), timeout=60) as f: | ||
return json.loads(f.read().decode('utf-8'))['data']['confirmed_balance'] | ||
except HTTPError as error: | ||
response = json.loads(error.read().decode('utf-8')) | ||
print("{}. {}".format(response['data']['network'], response['data']['address'])) | ||
except URLError as error: | ||
print(error.reason) | ||
except (ValueError, KeyError) as error: | ||
print(error) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Getting balance of wallet of your crypto currency') | ||
parser.add_argument('currency', nargs='?', type=str, help='Type of currency') | ||
parser.add_argument('wallet', nargs='?', type=str, help='Identifier of wallet') | ||
args = parser.parse_args() | ||
if (args.currency and args.wallet) is not None: | ||
print(get_balance(args.currency, args.wallet)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import cryptobalances | ||
from setuptools import setup, find_packages | ||
from os.path import join, dirname | ||
|
||
|
||
setup( | ||
name='cryptobalances', | ||
version=cryptobalances.__version__, | ||
author='Aliaksandr Leonau', | ||
author_email='[email protected]', | ||
packages=find_packages(), | ||
description='Python module for getting the balance of a various crypto currency', | ||
long_description=open(join(dirname(__file__), 'README.rst')).read(), | ||
url='https://github.com', | ||
platforms='Linux', | ||
) |