summaryrefslogtreecommitdiffstats
path: root/bitvend/processor.py
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2017-04-06 17:35:56 +0200
committerPiotr Dobrowolski <admin@tastycode.pl>2017-04-06 17:35:56 +0200
commitddeb9f522a177a29b6f0947f28c16dfd3de01eff (patch)
treea6d07f872de89a3590ad28504cc1a1855dc162b6 /bitvend/processor.py
parent0543a74223e5e0d0b6fb7e7b0773a67c66237301 (diff)
downloadbitvend-ddeb9f522a177a29b6f0947f28c16dfd3de01eff.tar.gz
bitvend-ddeb9f522a177a29b6f0947f28c16dfd3de01eff.tar.bz2
bitvend-ddeb9f522a177a29b6f0947f28c16dfd3de01eff.tar.xz
bitvend-ddeb9f522a177a29b6f0947f28c16dfd3de01eff.zip
Fix bitcoin transactions
Diffstat (limited to 'bitvend/processor.py')
-rw-r--r--bitvend/processor.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/bitvend/processor.py b/bitvend/processor.py
index 58df9b7..37732f0 100644
--- a/bitvend/processor.py
+++ b/bitvend/processor.py
@@ -63,13 +63,24 @@ class PaymentProcessor(threading.Thread):
self.logger.info('In local currency: %r', to_local_currency(tx_value))
with self.app.app_context():
- tx = Transaction(tx_hash=tx_hash)
- tx.uid = '__bitcoin__'
- tx.amount = -to_local_currency(tx_value)
- tx.type = 'purchase'
- db.session.add(tx)
+ intx = Transaction(
+ uid='__bitcoin__',
+ type='bitcoin',
+ amount=to_local_currency(tx_value),
+ tx_hash=tx_hash,
+ )
+ db.session.add(intx)
db.session.commit()
+ outtx = Transaction(
+ uid='__bitcoin__',
+ type='purchase',
+ )
+ db.session.add(outtx)
+ db.session.commit()
+
+ tx_id = outtx.id
+
if to_local_currency(tx_value) < 100:
self.logger.warning('Whyyyy so low...')
return
@@ -78,12 +89,10 @@ class PaymentProcessor(threading.Thread):
self.logger.warning('Fee too low...')
return
- self.logger.info('Transaction ok, going to device...')
+ self.logger.info('Transaction %d ok, going to device...', tx_id)
# FIXME we need better handling of ACK on POLL responses...
- self.device.begin_session(to_local_currency(tx_value), tx.id)
- self.device.begin_session(to_local_currency(tx_value), tx.id)
- self.device.begin_session(to_local_currency(tx_value), tx.id)
+ self.device.begin_session(to_local_currency(tx_value), tx_id)
def on_message(self, ws, message):
#print message