follow up to 2a507b91c1
This commit is contained in:
parent
8392fa9504
commit
8b68a742d1
|
@ -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):
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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…
Reference in New Issue