mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 15:31:31 +00:00
submarine swaps: fix expected amounts
This commit is contained in:
parent
17485e3b88
commit
46770bfd71
2 changed files with 7 additions and 4 deletions
|
@ -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):
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue