Skip to main content

django-cc

Build Status

Django-cryptocurrencies web wallet for Bitcoin and other cryptocurrencies.

Simple pluggable application inspired by django-bitcoin.

Python 3

Features

  • Multi-currency
  • Celery support
  • Withdraw and Deposite
  • 3 types of balances: balance, unconfirmed, holded

Quick start

Edit Currency model

from cc.models import Currency

currency = Currency.objects.create(
    label = 'Bitcoin',
    ticker = 'BTC',
    api_url = 'http://root:toor@localhost:8332'
)

Start celery worker

$ celery worker -A tst.cel.app

Get new addresses for wallets

$ celery call cc.tasks.refill_addresses_queue

Now you can create wallets, deposite and withdraw funds

from cc.models import Wallet

wallet = Wallet.objects.create(
    currency=currency
)

wallet.get_address()

wallet.withdraw_to_address('mvEnyQ9b9iTA11QMHAwSVtHUrtD4CTfiDB', Decimal('0.01'))

After creating a withdraw transaction you need to run

$ celery call cc.tasks.process_withdraw_transactions

Query for new deposite transactions:

$ cc.tasks.query_transactions

If you want to catch event from bitcoind, but these calls options in bitcoin.conf file

walletnotify=~/env/bin/celery call cc.tasks.query_transaction --args='["BTC", "'%s'"]'
blocknotify=~/env/bin/celery call cc.tasks.query_transactions --args='["BTC"]'

where "BTC" - ticker (short name) of the Currency

Transactions

When you write applications that are working with money it is extremely important to use Database transactions. Currenly django-cc doesn't inclues any @transaction.atomic. You should do this by yourself.

In my code I have a higher level wrapper with @transaction.atomic and to get wallets I'm always using select for update, like Wallet.objects.select_for_update().get(addresses=address) to get a lock over the Wallet.

Supported crypto currencies

In general django-cc should work with most Bitcoin forks. I've tested it against: Bitcoin, Litecoin, Zcash (not anonymous transactions), Dogecoin and Dash.

When you are adding any other Currency, than Bitcoin, you should define magicbyte and dust values. Use tables below to get the values.

Magic bytes

Magic bytes are used to verify withdraw addresses. They are different for each cryptocurrency

CC Mainnet Testnet
Bitcoin 0,5 111,196
Litecoin 48,50 58
Zcash 28 29
Dogecoin 30,22
Dash 76,16 140

Dust

Minimal amount of valid transaction

CC Dust size
Bitcoin 0.00005430
Litecoin 0.00054600

Testing

Tests are written using Regtest. To run them you need docker and docker-compose. Simply run docker-compose up and it will build and run all tests for you. Usually it takes about 5 min to run all the tests.

Metadata

Release files for django-cc 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-cc 0.2.3
File Size Uploaded Provenance Actions
django-cc-0.2.3.tar.gz 17.3 kB Without provenance Details for django-cc-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-cc 0.2.3
File Interpreter ABI Platform Actions
django_cc-0.2.3-py3-none-any.whl Python 3 none any Details for django_cc-0.2.3-py3-none-any.whl

Total release size: 44.4 kB

Release files / django-cc-0.2.3.tar.gz

Download URL django-cc-0.2.3.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f90f769ca95bbd78d12deefc4331f37b6882fbb0c82afcb53626667ea03920e7
BLAKE2b-256 checksum
How to use checksums
c265f31315a2308cb33cdeebacd7f0705a2fb327aca665c843f74aa590d8ccfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / django_cc-0.2.3-py3-none-any.whl

Download URL django_cc-0.2.3-py3-none-any.whl
Size 27.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94f9139a2c091717ae0f92349a64e8ae73f7abe0c9e5571beb60f669e94bb793
BLAKE2b-256 checksum
How to use checksums
439b61dd2a26ed3185f89050770c28b2c8baa45dc7aeb7a783567aec4a074081
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Security for django-cc 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page