mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
tx: add setter for tx locktime
We need to update the psbt's global transaction simultaneously, so we wrap access to the locktime in a method which will handle both
This commit is contained in:
committed by
Christian Decker
parent
db8ef922ed
commit
f9300e8480
@@ -151,6 +151,12 @@ static int elements_tx_add_fee_output(struct bitcoin_tx *tx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bitcoin_tx_set_locktime(struct bitcoin_tx *tx, u32 locktime)
|
||||||
|
{
|
||||||
|
tx->wtx->locktime = locktime;
|
||||||
|
tx->psbt->tx->locktime = locktime;
|
||||||
|
}
|
||||||
|
|
||||||
int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid,
|
int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid,
|
||||||
u32 outnum, u32 sequence, const u8 *scriptSig,
|
u32 outnum, u32 sequence, const u8 *scriptSig,
|
||||||
struct amount_sat amount, const u8 *scriptPubkey,
|
struct amount_sat amount, const u8 *scriptPubkey,
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
|
|||||||
int bitcoin_tx_add_multi_outputs(struct bitcoin_tx *tx,
|
int bitcoin_tx_add_multi_outputs(struct bitcoin_tx *tx,
|
||||||
struct bitcoin_tx_output **outputs);
|
struct bitcoin_tx_output **outputs);
|
||||||
|
|
||||||
|
/* Set the locktime for a transaction */
|
||||||
|
void bitcoin_tx_set_locktime(struct bitcoin_tx *tx, u32 locktime);
|
||||||
|
|
||||||
/* Add a new input to a bitcoin tx.
|
/* Add a new input to a bitcoin tx.
|
||||||
*
|
*
|
||||||
* For P2WSH inputs, we'll also store the wscript and/or scriptPubkey
|
* For P2WSH inputs, we'll also store the wscript and/or scriptPubkey
|
||||||
|
|||||||
@@ -276,8 +276,8 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
|
|||||||
*
|
*
|
||||||
* * locktime: upper 8 bits are 0x20, lower 24 bits are the lower 24 bits of the obscured commitment number
|
* * locktime: upper 8 bits are 0x20, lower 24 bits are the lower 24 bits of the obscured commitment number
|
||||||
*/
|
*/
|
||||||
tx->wtx->locktime
|
bitcoin_tx_set_locktime(tx,
|
||||||
= (0x20000000 | (obscured_commitment_number & 0xFFFFFF));
|
(0x20000000 | (obscured_commitment_number & 0xFFFFFF)));
|
||||||
|
|
||||||
/* BOLT #3:
|
/* BOLT #3:
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -228,8 +228,8 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx,
|
|||||||
* * locktime: upper 8 bits are 0x20, lower 24 bits are the
|
* * locktime: upper 8 bits are 0x20, lower 24 bits are the
|
||||||
* lower 24 bits of the obscured commitment number
|
* lower 24 bits of the obscured commitment number
|
||||||
*/
|
*/
|
||||||
tx->wtx->locktime =
|
bitcoin_tx_set_locktime(tx,
|
||||||
(0x20000000 | (obscured_commitment_number & 0xFFFFFF));
|
(0x20000000 | (obscured_commitment_number & 0xFFFFFF)));
|
||||||
|
|
||||||
/* BOLT #3:
|
/* BOLT #3:
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx,
|
|||||||
psbt_input_set_prev_utxo_wscript(tx->psbt, 0, commit_wscript, in_amount);
|
psbt_input_set_prev_utxo_wscript(tx->psbt, 0, commit_wscript, in_amount);
|
||||||
tx->chainparams = chainparams;
|
tx->chainparams = chainparams;
|
||||||
|
|
||||||
tx->wtx->locktime = cltv_expiry;
|
bitcoin_tx_set_locktime(tx, cltv_expiry);
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user