Browse Source

submarine swaps: add normal swaps to GUI, various minor fixes

bip39-recovery
ThomasV 5 years ago
parent
commit
7d2979d776
  1. 8
      electrum/gui/qt/swap_dialog.py
  2. 7
      electrum/submarine_swaps.py

8
electrum/gui/qt/swap_dialog.py

@ -123,9 +123,11 @@ class SwapDialog(WindowModalDialog):
self.get_pairs()
if not self.exec_():
return
amount_sat = self.send_amount_e.get_amount()
if self.is_reverse:
amount_sat = self.send_amount_e.get_amount()
coro = ss.reverse_swap(amount_sat, self.window.wallet, self.network)
asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
else:
pass
amount_sat = self.recv_amount_e.get_amount()
password = self.window.protect(lambda x: x, [])
coro = ss.normal_swap(amount_sat, self.window.wallet, self.network, password)
asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)

7
electrum/submarine_swaps.py

@ -9,7 +9,11 @@ from .transaction import script_GetOp, match_script_against_template, OPPushData
from .transaction import Transaction
from .util import log_exceptions
from .bitcoin import dust_threshold
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .network import Network
from .wallet import Abstract_Wallet
API_URL = 'http://ecdsa.org:9001'
@ -132,6 +136,7 @@ async def normal_swap(amount_sat, wallet: 'Abstract_Wallet', network: 'Network',
lnaddr = lnworker._check_invoice(invoice, amount_sat)
payment_hash = lnaddr.paymenthash
preimage = lnworker.get_preimage(payment_hash)
address = wallet.get_unused_address()
request_data = {
"type": "submarine",
"pairId": "BTC/BTC",
@ -148,7 +153,7 @@ async def normal_swap(amount_sat, wallet: 'Abstract_Wallet', network: 'Network',
response_id = data["id"]
zeroconf = data["acceptZeroConf"]
onchain_amount = data["expectedAmount"]
locktime = data["timeoutBlockHeight"],
locktime = data["timeoutBlockHeight"]
lockup_address = data["address"]
redeem_script = data["redeemScript"]
# verify redeem_script is built with our pubkey and preimage

Loading…
Cancel
Save