|
@ -1,4 +1,5 @@ |
|
|
import os |
|
|
import os |
|
|
|
|
|
from decimal import Decimal |
|
|
|
|
|
|
|
|
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QUrl |
|
|
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QUrl |
|
|
from PyQt5.QtCore import Qt, QAbstractListModel, QModelIndex |
|
|
from PyQt5.QtCore import Qt, QAbstractListModel, QModelIndex |
|
@ -7,6 +8,7 @@ from electrum.util import register_callback, get_new_wallet_name, WalletFileExce |
|
|
from electrum.logging import get_logger |
|
|
from electrum.logging import get_logger |
|
|
from electrum.wallet import Wallet, Abstract_Wallet |
|
|
from electrum.wallet import Wallet, Abstract_Wallet |
|
|
from electrum.storage import WalletStorage, StorageReadWriteError |
|
|
from electrum.storage import WalletStorage, StorageReadWriteError |
|
|
|
|
|
from electrum.bitcoin import COIN |
|
|
|
|
|
|
|
|
from .qewallet import QEWallet |
|
|
from .qewallet import QEWallet |
|
|
|
|
|
|
|
@ -133,6 +135,32 @@ class QEDaemon(QObject): |
|
|
self._logger.error(str(e)) |
|
|
self._logger.error(str(e)) |
|
|
self.walletOpenError.emit(str(e)) |
|
|
self.walletOpenError.emit(str(e)) |
|
|
|
|
|
|
|
|
|
|
|
@pyqtSlot(str, result=str) |
|
|
|
|
|
def fiatValue(self, satoshis): |
|
|
|
|
|
rate = self.daemon.fx.exchange_rate() |
|
|
|
|
|
try: |
|
|
|
|
|
sd = Decimal(satoshis) |
|
|
|
|
|
if sd == 0: |
|
|
|
|
|
return '' |
|
|
|
|
|
except: |
|
|
|
|
|
return '' |
|
|
|
|
|
return self.daemon.fx.value_str(satoshis,rate) |
|
|
|
|
|
|
|
|
|
|
|
# TODO: move conversion to FxThread |
|
|
|
|
|
@pyqtSlot(str, result=str) |
|
|
|
|
|
def satoshiValue(self, fiat): |
|
|
|
|
|
rate = self.daemon.fx.exchange_rate() |
|
|
|
|
|
try: |
|
|
|
|
|
fd = Decimal(fiat) |
|
|
|
|
|
except: |
|
|
|
|
|
return '' |
|
|
|
|
|
v = fd / Decimal(rate) * COIN |
|
|
|
|
|
return '' if v.is_nan() else self.daemon.config.format_amount(v) |
|
|
|
|
|
|
|
|
|
|
|
@pyqtSlot() |
|
|
|
|
|
def setFiatCurrency(self): |
|
|
|
|
|
self.daemon.fx.set_currency(self.daemon.config.get('currency')) |
|
|
|
|
|
|
|
|
@pyqtProperty('QString') |
|
|
@pyqtProperty('QString') |
|
|
def path(self): |
|
|
def path(self): |
|
|
return self._path |
|
|
return self._path |
|
|