Browse Source

submarine swaps: fix expected amounts

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

7
electrum/gui/qt/swap_dialog.py

@ -155,12 +155,14 @@ class SwapDialog(WindowModalDialog):
return
if send_amount < self.min_amount or send_amount > self.max_amount:
return
x = int(send_amount * (100 - self.percentage) / 100)
x = send_amount
if self.is_reverse:
x = int(x * (100 - self.percentage) / 100)
x -= self.lockup_fee
x -= self.claim_fee
else:
x -= self.normal_fee
x = int(x * (100 - self.percentage) / 100)
if x < 0:
return
return x
@ -172,9 +174,10 @@ class SwapDialog(WindowModalDialog):
if self.is_reverse:
x += self.lockup_fee
x += self.claim_fee
x = int(x * 100 / (100 - self.percentage)) + 1
else:
x = int(x * 100 / (100 - self.percentage)) + 1
x += self.normal_fee
x = int(x * 100 / (100 - self.percentage)) + 1
return x
def run(self):

4
electrum/submarine_swaps.py

@ -163,7 +163,7 @@ class SwapManager(Logger):
assert pubkey == parsed_script[9][1]
assert locktime == int.from_bytes(parsed_script[6][1], byteorder='little')
# check that onchain_amount is what was announced
assert onchain_amount == expected_onchain_amount
assert onchain_amount <= expected_onchain_amount, (onchain_amount, expected_onchain_amount)
# verify that they are not locking up funds for more than a day
assert locktime - self.network.get_local_height() < 144
# save swap data in wallet in case we need a refund
@ -217,7 +217,7 @@ class SwapManager(Logger):
assert pubkey == parsed_script[7][1]
assert locktime == int.from_bytes(parsed_script[10][1], byteorder='little')
# check that the amount is what we expected
assert onchain_amount == expected_amount, (onchain_amount, expected_amount)
assert onchain_amount >= expected_amount, (onchain_amount, expected_amount)
# verify that we will have enought time to get our tx confirmed
assert locktime - self.network.get_local_height() > 10
# verify invoice preimage_hash

Loading…
Cancel
Save