1
0

swaps: when RBF-ing a forward swap tx, payment amt must not decrease

This commit is contained in:
SomberNight
2022-03-30 19:01:57 +02:00
parent 1364e7538a
commit 357aaff582
2 changed files with 18 additions and 11 deletions

View File

@@ -300,7 +300,7 @@ class SwapManager(Logger):
dummy_output = PartialTxOutput.from_address_and_value(ln_dummy_address(), expected_onchain_amount_sat)
tx.outputs().remove(dummy_output)
tx.add_outputs([funding_output])
tx.set_rbf(True) # rbf must not decrease payment
tx.set_rbf(True) # note: rbf must not decrease payment
self.wallet.sign_transaction(tx, password)
# save swap data in wallet in case we need a refund
swap = SwapData(
@@ -543,6 +543,12 @@ class SwapManager(Logger):
return swap
return None
def is_lockup_address_for_a_swap(self, addr: str) -> bool:
for key, swap in self.swaps.items(): # TODO take lock? or add index to avoid looping
if addr == swap.lockup_address:
return True
return False
def sign_tx(self, tx, swap):
preimage = swap.preimage if swap.is_reverse else 0
witness_script = swap.redeem_script