def _update(self,): self.onBusy.emit() try: self._wallet.update(self._currentPassKey) self._updateFiat() self._balance = prettyPBitcoin(self._wallet.balance) self._fiatBalance = u'%f %s (%f)' % ((self._wallet.balance * self._fiatRate / 100000000), self._fiatSymbol, self._fiatRate) self.onBalance.emit() self.onFiatBalance.emit() # print self._wallet.getActiveAddresses() self.addressesModel.setData(self._wallet.getActiveAddresses()) try: self.transactionsModel.setData( self._wallet.addresses[self._currentAddressIndex] .transactions) except IndexError: print 'index error loading transactions model : ', \ self._currentAddressIndex self._currentAddressIndex = 0 # self.onDoubleEncrypted.emit() # self.onConnected.emit(True) # self.setDefaultAddress() except urllib2.URLError: pass except Exception, err: print err self.onError.emit(unicode(err))
def unlockWallet(self, passKey): try: self.setCurrentPassKey(passKey) try: self._wallet.load_addresses(self._currentPassKey) except ValueError: raise WrongPassword('Wrong passphrase') try: self._updateFiat() except (urllib2.URLError, urllib2.HTTPError): pass self._balance = prettyPBitcoin(self._wallet.balance) self._fiatBalance = u'%f %s (%f)' % ((self._wallet.balance * self._fiatRate / 100000000), self._fiatSymbol, self._fiatRate) self.onBalance.emit() self.onFiatBalance.emit() self._walletUnlocked = True self.addressesModel.setData(self._wallet.getActiveAddresses()) except WrongPassword: self.onError.emit(u'Wrong passphrase') import traceback traceback.print_exc() return False except Exception, err: self.onError.emit(unicode(err)) import traceback traceback.print_exc() return False
def data(self, index, role): if index.isValid() and role == TransactionsModel.COLUMNS.index('date'): return self._transactions[index.row()].date elif (index.isValid() and role == TransactionsModel.COLUMNS.index('address')): return self._transactions[index.row()].address elif (index.isValid() and role == TransactionsModel.COLUMNS.index('amount')): return prettyPBitcoin(self._transactions[index.row()].amount, True) elif (index.isValid() and role == TransactionsModel.COLUMNS.index('confirmations')): return self._transactions[index.row()].confirmations return None
def data(self, index, role): if index.isValid() and role == AddressesModel.COLUMNS.index('label'): return self._addresses[index.row()].label elif (index.isValid() and role == AddressesModel.COLUMNS.index('address')): return self._addresses[index.row()].addr elif (index.isValid() and role == AddressesModel.COLUMNS.index('prettyBalance')): return prettyPBitcoin(self._addresses[index.row()].balance, True) elif (index.isValid() and role == AddressesModel.COLUMNS.index('balance')): return self._addresses[index.row()].balance elif (index.isValid() and role == AddressesModel.COLUMNS.index('index')): return index.row() return None
def unlockWallet(self, passKey): try: self.setCurrentPassKey(passKey) try: self._wallet.load_addresses(self._currentPassKey) except ValueError: raise WrongPassword('Wrong passphrase') self._balance = prettyPBitcoin(self._wallet.balance) self.onBalance.emit() self._walletUnlocked = True self.addressesModel.setData(self._wallet.getActiveAddresses()) except WrongPassword: self.onError.emit(u'Wrong passphrase') import traceback traceback.print_exc() return False except Exception, err: self.onError.emit(unicode(err)) import traceback traceback.print_exc() return False
def getCurrentBalance(self): try: return prettyPBitcoin(self._wallet.addresses[ self._currentAddressIndex].balance) except IndexError: return prettyPBitcoin(0)