mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
follow up to 2a507b91c1
This commit is contained in:
parent
8392fa9504
commit
8b68a742d1
3 changed files with 8 additions and 14 deletions
|
@ -453,7 +453,8 @@ class ElectrumWindow(App):
|
||||||
|
|
||||||
def get_max_amount(self):
|
def get_max_amount(self):
|
||||||
inputs = self.wallet.get_spendable_coins(None)
|
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())
|
return format_satoshis_plain(amount, self.decimal_point())
|
||||||
|
|
||||||
def format_amount(self, x, is_diff=False, whitespaces=False):
|
def format_amount(self, x, is_diff=False, whitespaces=False):
|
||||||
|
|
|
@ -394,18 +394,10 @@ class Commands:
|
||||||
final_outputs = []
|
final_outputs = []
|
||||||
for address, amount in outputs:
|
for address, amount in outputs:
|
||||||
address = self._resolver(address)
|
address = self._resolver(address)
|
||||||
#assert self.wallet.is_mine(address)
|
|
||||||
if amount == '!':
|
if amount == '!':
|
||||||
assert len(outputs) == 1
|
assert len(outputs) == 1
|
||||||
inputs = self.wallet.get_spendable_coins(domain)
|
inputs = self.wallet.get_spendable_coins(domain)
|
||||||
amount = sum(map(lambda x:x['value'], inputs))
|
amount, fee = self.wallet.get_max_amount(self.config, inputs, address, fee)
|
||||||
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
|
|
||||||
else:
|
else:
|
||||||
amount = int(COIN*Decimal(amount))
|
amount = int(COIN*Decimal(amount))
|
||||||
final_outputs.append((TYPE_ADDRESS, address, amount))
|
final_outputs.append((TYPE_ADDRESS, address, amount))
|
||||||
|
|
|
@ -655,15 +655,16 @@ class Abstract_Wallet(PrintError):
|
||||||
return coins
|
return coins
|
||||||
|
|
||||||
def dummy_address(self):
|
def dummy_address(self):
|
||||||
|
print "dummy"
|
||||||
return self.addresses(False)[0]
|
return self.addresses(False)[0]
|
||||||
|
|
||||||
def get_max_amount(self, config, inputs, recipient, fee):
|
def get_max_amount(self, config, inputs, recipient, fee):
|
||||||
sendable = sum(map(lambda x:x['value'], inputs))
|
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:
|
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())
|
fee = self.estimate_fee(config, dummy_tx.estimated_size())
|
||||||
amount = max(0, sendable - fee)
|
amount = max(0, sendable - fee)
|
||||||
return amount, fee
|
return amount, fee
|
||||||
|
|
Loading…
Add table
Reference in a new issue