def CreateWithdrawTransaction(self, fund, amount, outAddress): tx = Transaction() tx.withdrawAddress = outAddress tx.amount = amount precoinrAcc = Account.objects.get(accountName='precoinr') tx.fundIdIn = AccountFund.objects.get(accountId=precoinrAcc, currencyCode=fund.currencyCode).id tx.fundIdOut = fund.id tx.precoinrFee = amount*5/1000 tx.transactionType= 'withdraw' tx.timeStamp = datetime.utcnow().replace(tzinfo=utc) tx.TxUUId = uuid.uuid4().__str__() tx.ccTxId='' return tx
def CreateSystemOutTransaction(self, fund, amount, fee): tx = Transaction() tx.amount = amount precoinrAcc = Account.objects.get(accountName='precoinr') tx.fundIdOut = AccountFund.objects.get(accountId=precoinrAcc, currencyCode=fund.currencyCode).id tx.precoinrFee = fee tx.transactionType= 'systemOut' tx.timeStamp = datetime.utcnow().replace(tzinfo=utc) tx.TxUUId = uuid.uuid4().__str__() tx.ccTxId='' return tx
def WorkTroughNewTransactions(self, transactions, fund): noSeen=0 for tx in transactions: if tx.category=='receive': thisTx = Transaction() try: thisTx = Transaction.objects.get(ccTxId=tx.txid) noSeen = noSeen + 1 except ObjectDoesNotExist: try: with transaction.commit_on_success(): thisTx = Transaction() thisTx.amount=tx.amount thisTx.transactionType=tx.category thisTx.ccTxId=tx.txid thisTx.seenInWallet=True thisTx.confirmations=tx.confirmations thisTx.fundIdIn=fund.id thisTx.timeStamp = datetime.utcfromtimestamp(tx.time).replace(tzinfo=utc) thisTx.save() FundDataHelpers.RecalculateFunds(thisTx) noSeen = noSeen + 1 logger.info('NEW Deposit of '+tx.amount.__str__()+'on '+fund.fundAddress) except Exception as e: transaction.rollback() logger.error('Could not commit incoming transaction on '+fund.fundAddress+': '+e.message) return noSeen else: logger.info('MOVE detected: '+tx.amount.__str__()+' from '+ fund.fundAddress) noSeen = noSeen + 1 return noSeen
def CreateTransaction(self, type, data): tx = Transaction() tx.amount = data.actualAmount if type == 'pay': tx.fundIdIn = AccountFund.objects.get(accountId=data.mrc, currencyCode=data.payType).id tx.fundIdOut = AccountFund.objects.get(accountId=data.acc, currencyCode=data.payType).id tx.precoinrFee = tx.amount*float(data.precoinrFee)/10000 tx.exchangeAmount=data.requestAmount tx.exchangeCode=data.requestType tx.exchangeRate=data.exchangeRate elif type == 'fee': precoinrAcc = Account.objects.get(accountName='precoinr') tx.fundIdIn = AccountFund.objects.get(accountId=precoinrAcc, currencyCode=data.payType).id tx.fundIdOut = AccountFund.objects.get(accountId=data.mrc, currencyCode=data.payType).id elif type == 'exchangeOUT': precoinrAcc = Account.objects.get(accountName='precoinr') tx.fundIdIn = AccountFund.objects.get(accountId=precoinrAcc, currencyCode=data.payType).id tx.fundIdOut = AccountFund.objects.get(accountId=data.mrc, currencyCode=data.payType).id tx.exchangeAmount=data.actualExchangeAmount tx.exchangeCode=data.requestType tx.exchangeRate=data.exchangeRate elif type == 'exchangeIN': precoinrAcc = Account.objects.get(accountName='precoinr') tx.fundIdIn = AccountFund.objects.get(accountId=data.mrc, currencyCode=data.requestType).id tx.fundIdOut = AccountFund.objects.get(accountId=precoinrAcc.id, currencyCode=data.requestType).id tx.transactionType= type tx.timeStamp = data.timestamp tx.TxUUId = data.txUUId return tx