electrum

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

commit 9385d2dae371075c73d4919557ab8935339e1350
parent 1ace265992a738023ebb0d8d6d49788925b67772
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun, 21 Jun 2020 08:36:40 +0200

submarine_swaps: minor clean-up (preimage/locktime)

Diffstat:
Melectrum/submarine_swaps.py | 25++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/electrum/submarine_swaps.py b/electrum/submarine_swaps.py @@ -104,7 +104,7 @@ def create_claim_tx( txin.script_sig = bytes.fromhex(push_script(txin.redeem_script.hex())) txin.witness_script = witness_script txout = PartialTxOutput.from_address_and_value(address, amount_sat) - tx = PartialTransaction.from_io([txin], [txout], version=2, locktime=(None if preimage else locktime)) + tx = PartialTransaction.from_io([txin], [txout], version=2, locktime=locktime) #tx.set_rbf(True) sig = bytes.fromhex(tx.sign_txin(0, privkey)) witness = [sig, preimage, witness_script] @@ -167,14 +167,21 @@ class SwapManager(Logger): self.logger.info('utxo value below dust threshold') continue address = self.wallet.get_receiving_address() - preimage = swap.preimage if swap.is_reverse else 0 - tx = create_claim_tx(txin=txin, - witness_script=swap.redeem_script, - preimage=preimage, - privkey=swap.privkey, - address=address, - amount_sat=amount_sat, - locktime=swap.locktime) + if swap.is_reverse: # successful reverse swap + preimage = swap.preimage + locktime = 0 + else: # timing out forward swap + preimage = 0 + locktime = swap.locktime + tx = create_claim_tx( + txin=txin, + witness_script=swap.redeem_script, + preimage=preimage, + privkey=swap.privkey, + address=address, + amount_sat=amount_sat, + locktime=locktime, + ) await self.network.broadcast_transaction(tx) # save txid if swap.is_reverse: