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

Method parse_transaction

python/ccxt/coinbaseexchange.py:1893–1968  ·  view source on GitHub ↗
(self, transaction: dict, currency: Currency = None)

Source from the content-addressed store, hash-verified

1891 return 'pending'
1892
1893 def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
1894 #
1895 # privateGetTransfers
1896 #
1897 # [
1898 # {
1899 # "id": "bee6fd7c-afb2-4e47-8298-671d09997d16",
1900 # "type": "deposit",
1901 # "created_at": "2022-12-21 00:48:45.477503+00",
1902 # "completed_at": null,
1903 # "account_id": "sal3802-36bd-46be-a7b8-alsjf383sldak", # only from privateGetTransfers
1904 # "user_id": "6382048209f92as392039dlks2", # only from privateGetTransfers
1905 # "amount": "0.01000000",
1906 # "details": {
1907 # "network": "litecoin",
1908 # "crypto_address": "MKemtnCFUYKsNWaf5EMYMpwSszcXWFDtTY",
1909 # "coinbase_account_id": "fl2b6925-f6ba-403n-jj03-40fl435n430f",
1910 # "coinbase_transaction_id": "63a25bb13cb5cf0001d2cf17", # withdrawals only
1911 # "crypto_transaction_hash": "752f35570736341e2a253f7041a34cf1e196fc56128c900fd03d99da899d94c1",
1912 # "tx_service_transaction_id": "1873249104",
1913 # "coinbase_payment_method_id": ""
1914 # },
1915 # "canceled_at": null,
1916 # "processed_at": null,
1917 # "user_nonce": null,
1918 # "idem": "5e3201b0-e390-5k3k-a913-c32932049242",
1919 # "profile_id": "k3k302a8-c4dk-4f49-9d39-3203923wpk39",
1920 # "currency": "LTC"
1921 # }
1922 # ]
1923 #
1924 details = self.safe_value(transaction, 'details', {})
1925 timestamp = self.parse8601(self.safe_string(transaction, 'created_at'))
1926 currencyId = self.safe_string(transaction, 'currency')
1927 code = self.safe_currency_code(currencyId, currency)
1928 amount = self.safe_number(transaction, 'amount')
1929 type = self.safe_string(transaction, 'type')
1930 address = self.safe_string(details, 'crypto_address')
1931 address = self.safe_string(transaction, 'crypto_address', address)
1932 fee = {
1933 'currency': None,
1934 'cost': None,
1935 'rate': None,
1936 }
1937 if type == 'withdraw':
1938 type = 'withdrawal'
1939 address = self.safe_string(details, 'sent_to_address', address)
1940 feeCost = self.safe_number(details, 'fee')
1941 if feeCost is not None:
1942 if amount is not None:
1943 amount -= feeCost
1944 fee['cost'] = feeCost
1945 fee['currency'] = code
1946 networkId = self.safe_string(details, 'network')
1947 return {
1948 'info': transaction,
1949 'id': self.safe_string(transaction, 'id'),
1950 'txid': self.safe_string(details, 'crypto_transaction_hash'),

Callers 1

withdrawMethod · 0.95

Calls 8

safe_valueMethod · 0.80
safe_stringMethod · 0.80
safe_numberMethod · 0.80
parse8601Method · 0.45
safe_currency_codeMethod · 0.45
network_id_to_codeMethod · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected