mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-05 05:15:12 +00:00
swaps dialog: handle make_unsigned_tx exceptions. fixes #6246
This commit is contained in:
parent
d870778a1b
commit
436ca11021
1 changed files with 15 additions and 6 deletions
|
@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, Optional
|
||||||
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QGridLayout, QPushButton
|
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QGridLayout, QPushButton
|
||||||
|
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
|
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates
|
||||||
from electrum.lnutil import ln_dummy_address
|
from electrum.lnutil import ln_dummy_address
|
||||||
from electrum.transaction import PartialTxOutput, PartialTransaction
|
from electrum.transaction import PartialTxOutput, PartialTransaction
|
||||||
|
|
||||||
|
@ -73,9 +74,10 @@ class SwapDialog(WindowModalDialog):
|
||||||
h.addWidget(fee_combo, 6, 2)
|
h.addWidget(fee_combo, 6, 2)
|
||||||
vbox.addLayout(h)
|
vbox.addLayout(h)
|
||||||
vbox.addStretch(1)
|
vbox.addStretch(1)
|
||||||
ok_button = OkButton(self)
|
self.ok_button = OkButton(self)
|
||||||
ok_button.setDefault(True)
|
self.ok_button.setDefault(True)
|
||||||
vbox.addLayout(Buttons(CancelButton(self), ok_button))
|
self.ok_button.setEnabled(False)
|
||||||
|
vbox.addLayout(Buttons(CancelButton(self), self.ok_button))
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def fee_slider_callback(self, dyn, pos, fee_rate):
|
def fee_slider_callback(self, dyn, pos, fee_rate):
|
||||||
|
@ -140,6 +142,7 @@ class SwapDialog(WindowModalDialog):
|
||||||
self.recv_amount_e.follows = False
|
self.recv_amount_e.follows = False
|
||||||
self.send_follows = False
|
self.send_follows = False
|
||||||
self.update_fee()
|
self.update_fee()
|
||||||
|
self.ok_button.setEnabled(recv_amount is not None)
|
||||||
|
|
||||||
def on_recv_edited(self):
|
def on_recv_edited(self):
|
||||||
if self.recv_amount_e.follows:
|
if self.recv_amount_e.follows:
|
||||||
|
@ -155,6 +158,7 @@ class SwapDialog(WindowModalDialog):
|
||||||
self.send_amount_e.follows = False
|
self.send_amount_e.follows = False
|
||||||
self.send_follows = True
|
self.send_follows = True
|
||||||
self.update_fee()
|
self.update_fee()
|
||||||
|
self.ok_button.setEnabled(send_amount is not None)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
sm = self.swap_manager
|
sm = self.swap_manager
|
||||||
|
@ -206,12 +210,17 @@ class SwapDialog(WindowModalDialog):
|
||||||
def update_tx(self, onchain_amount):
|
def update_tx(self, onchain_amount):
|
||||||
if onchain_amount is None:
|
if onchain_amount is None:
|
||||||
self.tx = None
|
self.tx = None
|
||||||
|
self.ok_button.setEnabled(False)
|
||||||
return
|
return
|
||||||
outputs = [PartialTxOutput.from_address_and_value(ln_dummy_address(), onchain_amount)]
|
outputs = [PartialTxOutput.from_address_and_value(ln_dummy_address(), onchain_amount)]
|
||||||
coins = self.window.get_coins()
|
coins = self.window.get_coins()
|
||||||
self.tx = self.window.wallet.make_unsigned_transaction(
|
try:
|
||||||
coins=coins,
|
self.tx = self.window.wallet.make_unsigned_transaction(
|
||||||
outputs=outputs)
|
coins=coins,
|
||||||
|
outputs=outputs)
|
||||||
|
except (NotEnoughFunds, NoDynamicFeeEstimates) as e:
|
||||||
|
self.tx = None
|
||||||
|
self.ok_button.setEnabled(False)
|
||||||
|
|
||||||
def do_normal_swap(self, lightning_amount, onchain_amount, password):
|
def do_normal_swap(self, lightning_amount, onchain_amount, password):
|
||||||
coro = self.swap_manager.normal_swap(lightning_amount, onchain_amount, password, tx=self.tx)
|
coro = self.swap_manager.normal_swap(lightning_amount, onchain_amount, password, tx=self.tx)
|
||||||
|
|
Loading…
Add table
Reference in a new issue