Browse Source
submarine_swaps: minor clean-up (preimage/locktime)
bip39-recovery
SomberNight
5 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
1 changed files with
16 additions and
9 deletions
-
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, |
|
|
|
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=swap.locktime) |
|
|
|
locktime=locktime, |
|
|
|
) |
|
|
|
await self.network.broadcast_transaction(tx) |
|
|
|
# save txid |
|
|
|
if swap.is_reverse: |
|
|
|