electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 46770bfd71d7675abaca3d2e74cc7b8088cd8ac4
parent 17485e3b88415a2b9f339f424d73fa8427307667
Author: ThomasV <thomasv@electrum.org>
Date:   Mon, 25 May 2020 22:18:18 +0200

submarine swaps: fix expected amounts

Diffstat:
Melectrum/gui/qt/swap_dialog.py | 7+++++--
Melectrum/submarine_swaps.py | 4++--
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/electrum/gui/qt/swap_dialog.py b/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): diff --git a/electrum/submarine_swaps.py b/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