kangasbros / django-bitcoin Goto Github PK
View Code? Open in Web Editor NEWbitcoin payment management for django
License: MIT License
bitcoin payment management for django
License: MIT License
The BitcoinAddress -> Wallet m2m relation was causing some
bitcoinaddresses to belong multiple wallets. This basically allow
double spends for some edge cases. Should be problem only if
you are runnign very big installation.
You can check your installation from django shell this way:
BitcoinAddress.objects.all()
for ba in BitcoinAddress.objects.all():
if ba.wallet_set.count()>1:
print [(w.id, w.total_balance()) for w in ba.wallet_set.all()]
If it doesn't output anything, you are good. Otherwise you have to go
thourgh the cases manually.
The issue is fixed in current version on git, if you have south
migrations then it should be pretty painless to upgrade. (The m2m
relationship was changed to basic foreignkey relationship).
If you enter an invalid transaction (for example, sending bitcoins from a Wallet object to an invalid address), funds will get reduced from the Wallet anyways, even though no transaction was made.
for example :
wallet.send_to_address('invalid address', Decimal('0.1'))
will debit 0.1 BTC from the wallet, even though no bitcoin was sent.
When I try to generate a new wallet using the code below:
master_wallet, created = Wallet.objects.get_or_create(label="master_wallet")
A bitcoinaddress
is generated by the bitcoind
but this address is not saved into our database.
Would be nice to be able to use this with Python 3!
When I am calling receiving_address method the following way, I am getting TransactionManagementError exception.
address = user.wallet.receiving_address()
print address
Does anybody have idea why is this happening or how can I debug it?
Traceback:
Traceback:
File "/Users/Elijen/Projects/Python/bitstore/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/Elijen/Projects/Python/bitstore/bitstore/bitstore/views/invoice.py" in create
12. addr = invoice.wallet.receiving_address(fresh_addr=True)
File "/Users/Elijen/Projects/Python/bitstore/lib/python2.7/site-packages/django_bitcoin/models.py" in receiving_address
363. addr = new_bitcoin_address()
File "/Users/Elijen/Projects/Python/bitstore/lib/python2.7/site-packages/django_bitcoin/models.py" in new_bitcoin_address
123. print "wallet transaction concurrency:", bp.address
File "/Users/Elijen/Projects/Python/bitstore/lib/python2.7/site-packages/django/db/transaction.py" in __exit__
393. self.exiting(exc_type, self.using)
File "/Users/Elijen/Projects/Python/bitstore/lib/python2.7/site-packages/django/db/transaction.py" in exiting
436. leave_transaction_management(using=using)
File "/Users/Elijen/Projects/Python/bitstore/lib/python2.7/site-packages/django/db/transaction.py" in leave_transaction_management
78. get_connection(using).leave_transaction_management()
File "/Users/Elijen/Projects/Python/bitstore/lib/python2.7/site-packages/django/db/backends/__init__.py" in leave_transaction_management
315. "Transaction managed block ended with pending COMMIT/ROLLBACK")
wallet_transactoin.deposit_transaction doen't created during query_transactions call
If a transaction fee is required from completing a transaction, it will get debited from the main wallet.dat account, and the user won't get informed. We need a way to raise an exception when a transaction fee from a transaction happens.
Hi
I'm trying to send bitcoins from wallet
>>> from django_bitcoin.models import Wallet
>>> w=Wallet.objects.get(id=6)
>>> w.send_to_address('n4a3fmSEqwoDLeWdjWLyiKr39j3xpRJAwL', 0.01)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/limpbrains/dev/split/env/local/lib/python2.7/site-packages/django_bitcoin/models.py", line 804, in send_to_address
return (bwt, None)
File "/home/limpbrains/dev/split/env/local/lib/python2.7/site-packages/django/db/transaction.py", line 393, in __exit__
self.exiting(exc_type, self.using)
File "/home/limpbrains/dev/split/env/local/lib/python2.7/site-packages/django/db/transaction.py", line 436, in exiting
leave_transaction_management(using=using)
File "/home/limpbrains/dev/split/env/local/lib/python2.7/site-packages/django/db/transaction.py", line 78, in leave_transaction_management
get_connection(using).leave_transaction_management()
File "/home/limpbrains/dev/split/env/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 315, in leave_transaction_management
"Transaction managed block ended with pending COMMIT/ROLLBACK")
TransactionManagementError: Transaction managed block ended with pending COMMIT/ROLLBACK
I'm using Django 1.6.1
django-bitcoin from master
I've tried sqllite and mysql/innodb
I follow this tutorial:
http://opensourcehacker.com/2013/10/16/accepting-and-spending-bitcoins-in-a-django-application/
Everything is ok if database is sqlite (or mysql) but when I use postgresql (psycopg2) and I try to do master_wallet.receiving_address(fresh=False)
it returns
"DatabaseError: SELECT FOR UPDATE/SHARE cannot be applied to the nullable side of an outer join"
It is problem in new_bitcoin_address() (django_bitcoin/models.py) around line 118:
updated = BitcoinAddress.objects.select_for_update().filter(Q(id=bp.id) & Q(active=False) & Q(wallet__isnull=True) & \
Q(least_received__lte=0)).update(active=True)
Query it tries to run looks like this:
u'UPDATE "django_bitcoin_bitcoinaddress" SET "active" = %s WHERE "django_bitcoin_bitcoinaddress"."id" IN (SELECT U0."id" FROM "django_bitcoin_bitcoinaddress" U0 LEFT OUTER JOIN "django_bitcoin_wallet" U1 ON (U0."wallet_id" = U1."id") WHERE (U0."id" = %s AND U0."active" = %s AND U1."id" IS NULL AND U0."least_received" <= %s ) FOR UPDATE)'
But I'm not sure what to do with this, why query looks like this or what should it do. Maybe I am doing something wrong, maybe django ORM is translating it not the way it should, or the ORM query is not what you expected it to be.
If you know how to fix this, I would love to use django-bitcoin in my project.
django-bitcoin is no longer mantained if anyone have some knowledge of a continuation fork, please mention it. Thanks.
I'm having problem getting data from this URL http://bitcoincharts.com/t/weighted_prices.json
so I decided to have a look to Bitcoincharts web site and I realise that they have now a different URL to call their API http://api.bitcoincharts.com/v1/weighted_prices.json
Should we change the URL that we are using in the code right now?
Cheers.
When wallet recieves "generate" transacion (transaction from mining pool with fresh coins) it ignored by django_bitcoin.tasks.query_transactions
Also utils.bitcoind.total_received doesn't work correctly, it also ignores generate transacions, because bitcoind API call getreceivedbyaddress ingnores them too.
PS
I wonder, is somebody using django-botcoin in production ? With django 1.6 ?
I'm creating a new wallet with the code below:
master_wallet, created = Wallet.objects.get_or_create(label="master_wallet")
And trying to get one bitcoinaddress
to start receiving coins but instead the code below generate 5 address and only one is activated in the database (activate=1)
recv_address = master_wallet.receiving_address(fresh_addr=False)
print recv_address
Steps to reproduce
Get the latest version from gh.
pip install -r django_bitcoin/requirements.txt
go to your application
run python manage.py CheckTransactions
it yields:
python manage.py CheckTransactions
starting overall1 0.000110864639282 2013-11-11 01:32:48.944677
starting round 0.00641298294067
TypeError: string indices must be integers
Am I doing something wrong? I have tried this with an application that had some running wallets as well as with an empty one, to no avail.
Currently uses google QR code generation, which is no good, because that way google knows the public address. In future will use http://code.google.com/p/pyqrnative/
python manage.py CheckTransactions
starting overall1 3.60012054443e-05 2014-04-04 02:21:14.127606
starting round 0.000263214111328
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/site/.virtualenvs/satoshi/lib/python2.7/site-packages/django/core/management/init.py", line 399, in execute_from_command_line
utility.execute()
File "/home/site/.virtualenvs/satoshi/lib/python2.7/site-packages/django/core/management/init.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/site/.virtualenvs/satoshi/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(_args, *_options.dict)
File "/home/site/.virtualenvs/satoshi/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(_args, *_options)
File "/home/site/.virtualenvs/satoshi/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/home/site/.virtualenvs/satoshi/lib/python2.7/site-packages/django_bitcoin/management/commands/CheckTransactions.py", line 45, in handle_noargs
dp.address.query_bitcoind(triggered_tx=t[u'txid'])
File "/home/site/.virtualenvs/satoshi/lib/python2.7/site-packages/django_bitcoin/models.py", line 272, in query_bitcoind
raise Exception("Deprecated")
Exception: Deprecated
Django 1.6.2
When creating Payment to yoursefl, bitcoin-qt creates transaction with zero fee.
So no need to raise an error in this case
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.