Ejemplo n.º 1
0
def test_password_for_keystore_encryption(wallet: Abstract_Wallet,
                                          password: str) -> bool:
    try:
        wallet.check_password(password)
    except InvalidPassword:
        return False
    else:
        return True
Ejemplo n.º 2
0
 def test_save_fiat_and_reset(self):
     self.assertEqual(
         False,
         Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '1000.01',
                                        self.fx, self.value_sat))
     saved = self.fiat_value[ccy][txid]
     self.assertEqual('1,000.01',
                      self.fx.ccy_amount_str(Decimal(saved), commas=True))
     self.assertEqual(
         True,
         Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '', self.fx,
                                        self.value_sat))
     self.assertNotIn(txid, self.fiat_value[ccy])
     # even though we are not setting it to the exact fiat value according to the exchange rate, precision is truncated away
     self.assertEqual(
         True,
         Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '1,000.002',
                                        self.fx, self.value_sat))
Ejemplo n.º 3
0
    def receive_menu(self, menu, addrs, wallet: Abstract_Wallet):
        if type(wallet) is not Standard_Wallet:
            return

        keystore = wallet.get_keystore()
        if type(keystore) is not self.keystore_class:
            return

        if not self.is_mobile_paired():
            return

        if len(addrs) == 1:
            addr = addrs[0]
            if wallet.get_txin_type(addr) != 'p2pkh':
                return
            def show_address():
                keystore.thread.add(partial(self.show_address, wallet, addr, keystore))

            menu.addAction(_("Show on {}").format(self.device), show_address)
Ejemplo n.º 4
0
 def setUp(self):
     super().setUp()
     self.value_sat = COIN
     self.fiat_value = {}
     self.wallet = FakeWallet(fiat_value=self.fiat_value)
     self.fx = FakeFxThread(FakeExchange(Decimal('1000.001')))
     default_fiat = Abstract_Wallet.default_fiat_value(
         self.wallet, txid, self.fx, self.value_sat)
     self.assertEqual(Decimal('1000.001'), default_fiat)
     self.assertEqual('1,000.00',
                      self.fx.ccy_amount_str(default_fiat, commas=True))
Ejemplo n.º 5
0
 def test_save_garbage(self):
     self.assertEqual(
         False,
         Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, 'garbage',
                                        self.fx, self.value_sat))
     self.assertNotIn(ccy, self.fiat_value)
Ejemplo n.º 6
0
 def test_empty_resets(self):
     self.assertEqual(
         True,
         Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '', self.fx,
                                        self.value_sat))
     self.assertNotIn(ccy, self.fiat_value)
Ejemplo n.º 7
0
 def test_too_high_precision_value_resets_with_no_saved_value(self):
     self.assertEqual(
         True,
         Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '1,000.001',
                                        self.fx, self.value_sat))