lnsweep and submarine_swaps: set txin.nsequence, instead of
calling set_rbf. set_rbf must be avoided if we batch transactions, because it blindly overwrites nsequence of all txins.
This commit is contained in:
@@ -780,8 +780,7 @@ def tx_their_ctx_htlc(
|
|||||||
txin._trusted_value_sats = val
|
txin._trusted_value_sats = val
|
||||||
txin.witness_script = witness_script
|
txin.witness_script = witness_script
|
||||||
txin.script_sig = b''
|
txin.script_sig = b''
|
||||||
if has_anchors:
|
txin.nsequence = 1 if has_anchors else 0xffffffff - 2
|
||||||
txin.nsequence = 1
|
|
||||||
sweep_inputs = [txin]
|
sweep_inputs = [txin]
|
||||||
tx_size_bytes = 200 # TODO (depends on offered/received and is_revocation)
|
tx_size_bytes = 200 # TODO (depends on offered/received and is_revocation)
|
||||||
fee = config.estimate_fee(tx_size_bytes, allow_fallback_to_static_rates=True)
|
fee = config.estimate_fee(tx_size_bytes, allow_fallback_to_static_rates=True)
|
||||||
@@ -817,6 +816,7 @@ def tx_their_ctx_to_remote(
|
|||||||
txin.num_sig = 1
|
txin.num_sig = 1
|
||||||
if not has_anchors:
|
if not has_anchors:
|
||||||
txin.script_type = 'p2wpkh'
|
txin.script_type = 'p2wpkh'
|
||||||
|
txin.nsequence = 0xffffffff - 2
|
||||||
tx_size_bytes = 110 # approx size of p2wpkh->p2wpkh
|
tx_size_bytes = 110 # approx size of p2wpkh->p2wpkh
|
||||||
else:
|
else:
|
||||||
txin.script_sig = b''
|
txin.script_sig = b''
|
||||||
@@ -831,7 +831,6 @@ def tx_their_ctx_to_remote(
|
|||||||
sweep_tx = PartialTransaction.from_io(sweep_inputs, sweep_outputs)
|
sweep_tx = PartialTransaction.from_io(sweep_inputs, sweep_outputs)
|
||||||
|
|
||||||
if not has_anchors:
|
if not has_anchors:
|
||||||
sweep_tx.set_rbf(True)
|
|
||||||
sweep_tx.sign({our_payment_pubkey: our_payment_privkey.get_secret_bytes()})
|
sweep_tx.sign({our_payment_pubkey: our_payment_privkey.get_secret_bytes()})
|
||||||
else:
|
else:
|
||||||
sig = sweep_tx.sign_txin(0, our_payment_privkey.get_secret_bytes())
|
sig = sweep_tx.sign_txin(0, our_payment_privkey.get_secret_bytes())
|
||||||
@@ -862,6 +861,7 @@ def tx_ctx_to_local(
|
|||||||
txin._trusted_value_sats = val
|
txin._trusted_value_sats = val
|
||||||
txin.script_sig = b''
|
txin.script_sig = b''
|
||||||
txin.witness_script = witness_script
|
txin.witness_script = witness_script
|
||||||
|
txin.nsequence = 0xffffffff - 2
|
||||||
sweep_inputs = [txin]
|
sweep_inputs = [txin]
|
||||||
if not is_revocation:
|
if not is_revocation:
|
||||||
assert isinstance(to_self_delay, int)
|
assert isinstance(to_self_delay, int)
|
||||||
|
|||||||
@@ -172,7 +172,6 @@ def create_claim_tx(
|
|||||||
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=locktime)
|
tx = PartialTransaction.from_io([txin], [txout], version=2, locktime=locktime)
|
||||||
tx.set_rbf(True)
|
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
|
|
||||||
@@ -1075,6 +1074,7 @@ class SwapManager(Logger):
|
|||||||
sig_dummy = b'\x00' * 71 # DER-encoded ECDSA sig, with low S and low R
|
sig_dummy = b'\x00' * 71 # DER-encoded ECDSA sig, with low S and low R
|
||||||
witness = [sig_dummy, preimage, witness_script]
|
witness = [sig_dummy, preimage, witness_script]
|
||||||
txin.witness_sizehint = len(construct_witness(witness))
|
txin.witness_sizehint = len(construct_witness(witness))
|
||||||
|
txin.nsequence = 0xffffffff - 2
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def sign_tx(cls, tx: PartialTransaction, swap: SwapData) -> None:
|
def sign_tx(cls, tx: PartialTransaction, swap: SwapData) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user