submarine_swaps: minor clean-up (preimage/locktime)
This commit is contained in:
@@ -104,7 +104,7 @@ def create_claim_tx(
|
|||||||
txin.script_sig = bytes.fromhex(push_script(txin.redeem_script.hex()))
|
txin.script_sig = bytes.fromhex(push_script(txin.redeem_script.hex()))
|
||||||
txin.witness_script = witness_script
|
txin.witness_script = witness_script
|
||||||
txout = PartialTxOutput.from_address_and_value(address, amount_sat)
|
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)
|
#tx.set_rbf(True)
|
||||||
sig = bytes.fromhex(tx.sign_txin(0, privkey))
|
sig = bytes.fromhex(tx.sign_txin(0, privkey))
|
||||||
witness = [sig, preimage, witness_script]
|
witness = [sig, preimage, witness_script]
|
||||||
@@ -167,14 +167,21 @@ class SwapManager(Logger):
|
|||||||
self.logger.info('utxo value below dust threshold')
|
self.logger.info('utxo value below dust threshold')
|
||||||
continue
|
continue
|
||||||
address = self.wallet.get_receiving_address()
|
address = self.wallet.get_receiving_address()
|
||||||
preimage = swap.preimage if swap.is_reverse else 0
|
if swap.is_reverse: # successful reverse swap
|
||||||
tx = create_claim_tx(txin=txin,
|
preimage = swap.preimage
|
||||||
witness_script=swap.redeem_script,
|
locktime = 0
|
||||||
preimage=preimage,
|
else: # timing out forward swap
|
||||||
privkey=swap.privkey,
|
preimage = 0
|
||||||
address=address,
|
locktime = swap.locktime
|
||||||
amount_sat=amount_sat,
|
tx = create_claim_tx(
|
||||||
locktime=swap.locktime)
|
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)
|
await self.network.broadcast_transaction(tx)
|
||||||
# save txid
|
# save txid
|
||||||
if swap.is_reverse:
|
if swap.is_reverse:
|
||||||
|
|||||||
Reference in New Issue
Block a user