Introduction
django-bitcoin is a Django web framework application for building Bitcoin web apps.
Features
Simple Bitcoin wallet management
Bitcoin payment processing
Bitcoin market information
Installation
To install, just add the app to your settings.py INSTALLED_APPS like:
INSTALLED_APPS = [
...
'django_bitcoin',
...
]
```
Also you have to run a local bitcoind instance, and specify connection string in settings:
BITCOIND_CONNECTION_STRING = "http://bitcoinuser:password@localhost:8332"
Usage
Tutorial
There is a small tutorial about how to use django-bitcoin to create your own instawallet.
Wallet websites, escrow services using the “Wallet”-model
You can use the Wallet class to do different bitcoin-moving applications. Typical example would be a marketplace-style site, where there are multiple sellers and buyer. Or job freelance site, where escrow is needed. Or even an exchange could be done with this abstraction (a little extra classes would be needed however).
Note that while you move bitcoins between Wallet-objects, only bitcoin transactions needed are incoming and outgoing transactions. Transactions between the system “Wallet”-objects don’t generate “real” bitcoin transactions. Every transaction (except incoming transactions) is logged to WalletTransaction object to ease accounting.
This also means that outgoing bitcoin transactions are “mixed”:
from django_bitcoin import Wallet, currency
class Profile(models.Model):
wallet = ForeignKey(Wallet)
outgoing_bitcoin_address = CharField()
class Escrow(models.Model):
wallet = ForeignKey(Wallet)
buyer_happy = BooleanField(default=False)
buyer=Profile.objects.create()
seller=Profile.objects.create()
purchase=Escrow.objects.create()
AMOUNT_USD="9.99"
m=currency.Money(AMOUNT_USD, "USD")
btc_amount=currency.exchange(m, "BTC")
print "Send "+str(btc_amount)+" BTC to address "+buyer.wallet.receiving_address()
sleep(5000) # wait for transaction
if p1.wallet.total_balance()>=btc_amount:
p1.send_to_wallet(purchase, btc_amount)
sleep(1000) # wait for product/service delivery
if purchase.buyer_happy:
purchase.wallet.send_to_wallet(seller.wallet)
seller.wallet.send_to_address(seller.outgoing_bitcoin_address, seller.wallet.total_balance())
else:
print "WHY U NO HAPPY"
#return bitcoins to buyer, 50/50 split or something
Transaction notifications
To enable bitcoin transaction notifications, set the following flag in your settings.py:
BITCOIN_TRANSACTION_SIGNALING = True
After that, you need to setup a cron job to run each minute, something like the following:
* * * * * (cd $APP_PATH && python manage.py python manage.py CheckTransactions >> $APP_PATH/logs/email_sends.log 2>&1)
After that you can define your balance_changed and balance_changed_confirmed signals:
from django_bitcoin.models import balance_changed, balance_changed_confirmed
from django.dispatch import receiver
@receiver(balance_changed)
def balance_changed_handler(sender, **kwargs):
pass
# try:
# print "balance changed", sender.id, kwargs["changed"], sender.total_balance()
@receiver(balance_changed_confirmed)
def balance_changed_confirmed_handler(sender, **kwargs):
pass
Community
Currently django-bitcoin is used at production in
More to come!
If you have a site using django-bitcoin, drop me an email and I will link to it here.
Support and source code
Changelog
0.2 (2013-05-14)
README.rst, change log and release process workflow updates [miohtama]
Historical prices data handling [Jeremias Kangas]
0.1
Initial release
Metadata
Release files for django-bitcoin 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-bitcoin-0.2.zip | 63.6 kB | Without provenance | Details |
Release files / django-bitcoin-0.2.zip
| Download URL | django-bitcoin-0.2.zip |
|---|---|
| Size | 63.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c594557a567edf9a6dd170c30117f0e5dad6044eeeebef5f8fe4d40187f800a1
|
|
BLAKE2b-256 checksum How to use checksums |
925005b375d9819fb57c87ba12c1c54dd203c805a3b3336699348ad6d9618835
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-bitcoin 0.2
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.