Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions electrum_gui/android/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio
import copy
import decimal
import itertools
import json
import logging
Expand Down Expand Up @@ -1377,6 +1378,18 @@ def get_exchange_currency(self, type, amount):
text = self.format_amount((int(Decimal(amount) / Decimal(rate) * COIN)))
return text

@api.api_entry(force_version=api.Version.V2)
def get_exchange_rate(self, chain_code: str, token_id: Optional[str] = None) -> decimal.Decimal:
chain_info = coin_manager.get_chain_info(chain_code)
if token_id is None:
coin_code = chain_info.chain_code # Main coin use chain_code
elif token_id == "fee":
coin_code = chain_info.fee_coin
else:
coin_code = coin_manager.get_coin_by_token_address(chain_code, token_id).code

return price_manager.get_last_price(coin_code, self.ccy)

def _set_base_uint(self, base_unit):
"""
Set base unit for(BTC/mBTC/bits/sat), for btc only
Expand Down