MCPcopy Create free account
hub / github.com/ccxt/ccxt / parse_transaction

Method parse_transaction

python/ccxt/foxbit.py:1768–1814  ·  view source on GitHub ↗
(self, transaction, currency: Currency = None, since: Int = None, limit: Int = None)

Source from the content-addressed store, hash-verified

1766 return self.safe_string(statuses, status, status)
1767
1768 def parse_transaction(self, transaction, currency: Currency = None, since: Int = None, limit: Int = None) -> Transaction:
1769 cryptoDetails = self.safe_dict(transaction, 'details_crypto')
1770 address = self.safe_string_2(cryptoDetails, 'receiving_address', 'destination_address')
1771 sn = self.safe_string(transaction, 'sn')
1772 type = 'withdrawal'
1773 if sn is not None and sn[0] == 'D':
1774 type = 'deposit'
1775 fee = self.safe_string(transaction, 'fee', '0')
1776 amount = self.safe_string(transaction, 'amount')
1777 currencySymbol = self.safe_string(transaction, 'currency_symbol')
1778 actualAmount = amount
1779 currencyCode = self.safe_currency_code(currencySymbol)
1780 status = self.parse_transaction_status(self.safe_string(transaction, 'state'))
1781 created_at = self.safe_string(transaction, 'created_at')
1782 timestamp = self.parse_date(created_at)
1783 datetime = self.iso8601(timestamp)
1784 if fee is not None and amount is not None:
1785 # actualAmount = amount - fee
1786 actualAmount = Precise.string_sub(amount, fee)
1787 feeRate = Precise.string_div(fee, actualAmount)
1788 feeObj = {
1789 'cost': self.parse_number(fee),
1790 'currency': currencyCode,
1791 'rate': self.parse_number(feeRate),
1792 }
1793 return {
1794 'info': transaction,
1795 'id': self.safe_string(transaction, 'sn'),
1796 'txid': self.safe_string(cryptoDetails, 'transaction_id'),
1797 'timestamp': timestamp,
1798 'datetime': datetime,
1799 'network': self.safe_string(transaction, 'network_code'),
1800 'address': address,
1801 'addressTo': address,
1802 'addressFrom': None,
1803 'tag': self.safe_string(transaction, 'destination_tag'),
1804 'tagTo': self.safe_string(transaction, 'destination_tag'),
1805 'tagFrom': None,
1806 'type': type,
1807 'amount': self.parse_number(amount),
1808 'currency': currencyCode,
1809 'status': status,
1810 'updated': None,
1811 'fee': feeObj,
1812 'comment': None,
1813 'internal': None,
1814 }
1815
1816 def parse_ledger_entry_type(self, type):
1817 types = {

Callers 1

withdrawMethod · 0.95

Calls 10

safe_dictMethod · 0.80
safe_string_2Method · 0.80
safe_stringMethod · 0.80
parse_dateMethod · 0.80
string_subMethod · 0.80
string_divMethod · 0.80
parse_numberMethod · 0.80
safe_currency_codeMethod · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected