Exemple #1
0
 def get_max_amount(self):
     from electrum_mona.transaction import TxOutput
     if run_hook('abort_send', self):
         return ''
     inputs = self.wallet.get_spendable_coins(None)
     if not inputs:
         return ''
     addr = None
     if self.send_screen:
         addr = str(self.send_screen.screen.address)
     if not addr:
         addr = self.wallet.dummy_address()
     outputs = [TxOutput(TYPE_ADDRESS, addr, '!')]
     try:
         tx = self.wallet.make_unsigned_transaction(inputs, outputs)
     except NoDynamicFeeEstimates as e:
         Clock.schedule_once(lambda dt, bound_e=e: self.show_error(str(bound_e)))
         return ''
     except NotEnoughFunds:
         return ''
     except InternalAddressCorruption as e:
         self.show_error(str(e))
         send_exception_to_crash_reporter(e)
         return ''
     amount = tx.output_value()
     __, x_fee_amount = run_hook('get_tx_extra_fee', self.wallet, tx) or (None, 0)
     amount_after_all_fees = amount - x_fee_amount
     return format_satoshis_plain(amount_after_all_fees, self.decimal_point())
Exemple #2
0
 def fiat_to_btc(self, fiat_amount):
     if not fiat_amount:
         return ''
     rate = self.fx.exchange_rate()
     if not rate:
         return ''
     satoshis = int(pow(10, 8) * Decimal(fiat_amount) / Decimal(rate))
     return format_satoshis_plain(satoshis, self.decimal_point())
Exemple #3
0
 def setAmount(self, amount_sat):
     if amount_sat is None:
         self.setText(" ")  # Space forces repaint in case units changed
     else:
         self.setText(
             format_satoshis_plain(amount_sat,
                                   decimal_point=self.decimal_point()))
     self.repaint()  # macOS hack for #6269
Exemple #4
0
 def get_max_amount(self):
     inputs = self.wallet.get_spendable_coins(None, self.electrum_config)
     addr = str(
         self.send_screen.screen.address) or self.wallet.dummy_address()
     outputs = [(TYPE_ADDRESS, addr, '!')]
     tx = self.wallet.make_unsigned_transaction(inputs, outputs,
                                                self.electrum_config)
     amount = tx.output_value()
     return format_satoshis_plain(amount, self.decimal_point())
Exemple #5
0
 def test_format_satoshis_plain_to_mbtc(self):
     self.assertEqual("0.01234", format_satoshis_plain(1234,
                                                       decimal_point=5))
Exemple #6
0
 def test_format_satoshis_plain_decimal(self):
     self.assertEqual("0.00001234", format_satoshis_plain(Decimal(1234)))
Exemple #7
0
 def format_amount_and_units(self, x):
     return format_satoshis_plain(
         x, self.decimal_point()) + ' ' + self.base_unit
Exemple #8
0
 def setAmount(self, amount):
     if amount is None:
         self.setText(" ")  # Space forces repaint in case units changed
     else:
         self.setText(format_satoshis_plain(amount, self.decimal_point()))