def storeTransactions(jsonTxs): # avoid serializers for now since all the blockchains will be nuanced and transaction mappings are # likely to differ. #print "Set Size: " + str(len(jsonTxs)) try: for tx in jsonTxs: #---------NEW ACCOUNT TEST ---------- # check if we have an account registered with the address querySet = Account.objects.filter(bitcoinAddress=tx['address']) owner = None if (len(querySet) == 0): print('About to add a covert account for address: ' + tx['address']) # store the address as a 'covert' account acc = Account() acc.owner = User.objects.filter(username="******")[0] acc.bitcoinAddress = tx['address'] acc.bitcoinBalance = 0.0 acc.ethereumAddress = "TBA" acc.ethereumBalance = 0.0 acc.pendingTx = "[]" acc.latestTx = "[]" acc.save() owner = acc.owner else: owner = querySet.first().owner # ----------------------------------- transaction = Transaction() transaction.target = owner transaction.involvesWatchonly = tx['involvesWatchonly'] transaction.account = tx['account'] transaction.address = tx['address'] transaction.category = tx['category'] transaction.amount = tx['amount'] transaction.label = tx['label'] transaction.confirmations = tx['confirmations'] transaction.blockhash = tx['blockhash'] transaction.blockindex = tx['blockindex'] transaction.blocktime = tx['blocktime'] transaction.txid = tx['txid'] transaction.vout = tx['vout'] transaction.walletconflicts = tx['walletconflicts'] transaction.time = tx['time'] transaction.timereceived = tx['timereceived'] transaction.bip125replaceable = tx['bip125-replaceable'] transaction.save() # since this is getting more interesting, let's store the unknown accounts as well # even though the addresses may not be part of the exchange it can infer balances # and patterns in the future an discovery services! :) except: print traceback.print_exc()
def GetTransactionData(self,dataPost, amount): transactionModel = Transaction() transactionModel.stripe_token = dataPost['stripeToken'] transactionModel.date = datetime.datetime.now() transactionModel.amount = amount transactionModel.address = dataPost['address'] transactionModel.city = dataPost['city'] transactionModel.zip = dataPost['zip'] return transactionModel