ThomasV 9 years ago
parent
commit
8b68a742d1
  1. 3
      gui/kivy/main_window.py
  2. 10
      lib/commands.py
  3. 9
      lib/wallet.py

3
gui/kivy/main_window.py

@ -453,7 +453,8 @@ class ElectrumWindow(App):
def get_max_amount(self):
inputs = self.wallet.get_spendable_coins(None)
amount, fee = self.wallet.get_max_amount(self.electrum_config, inputs, None)
addr = str(self.send_screen.screen.address) or self.wallet.dummy_address()
amount, fee = self.wallet.get_max_amount(self.electrum_config, inputs, addr, None)
return format_satoshis_plain(amount, self.decimal_point())
def format_amount(self, x, is_diff=False, whitespaces=False):

10
lib/commands.py

@ -394,18 +394,10 @@ class Commands:
final_outputs = []
for address, amount in outputs:
address = self._resolver(address)
#assert self.wallet.is_mine(address)
if amount == '!':
assert len(outputs) == 1
inputs = self.wallet.get_spendable_coins(domain)
amount = sum(map(lambda x:x['value'], inputs))
if fee is None:
for i in inputs:
self.wallet.add_input_info(i)
output = (TYPE_ADDRESS, address, amount)
dummy_tx = Transaction.from_io(inputs, [output])
fee = self.wallet.estimate_fee(self.config, dummy_tx.estimated_size())
amount -= fee
amount, fee = self.wallet.get_max_amount(self.config, inputs, address, fee)
else:
amount = int(COIN*Decimal(amount))
final_outputs.append((TYPE_ADDRESS, address, amount))

9
lib/wallet.py

@ -655,15 +655,16 @@ class Abstract_Wallet(PrintError):
return coins
def dummy_address(self):
print "dummy"
return self.addresses(False)[0]
def get_max_amount(self, config, inputs, recipient, fee):
sendable = sum(map(lambda x:x['value'], inputs))
for i in inputs:
self.add_input_info(i)
outputs = [(TYPE_ADDRESS, recipient, sendable)]
dummy_tx = Transaction.from_io(inputs, outputs)
if fee is None:
for i in inputs:
self.add_input_info(i)
outputs = [(TYPE_ADDRESS, recipient, sendable)]
dummy_tx = Transaction.from_io(inputs, outputs)
fee = self.estimate_fee(config, dummy_tx.estimated_size())
amount = max(0, sendable - fee)
return amount, fee

Loading…
Cancel
Save