mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +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:
parent
db8ef922ed
commit
f9300e8480
5 changed files with 14 additions and 5 deletions
|
@ -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,
|
||||
u32 outnum, u32 sequence, const u8 *scriptSig,
|
||||
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,
|
||||
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.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
tx->wtx->locktime
|
||||
= (0x20000000 | (obscured_commitment_number & 0xFFFFFF));
|
||||
bitcoin_tx_set_locktime(tx,
|
||||
(0x20000000 | (obscured_commitment_number & 0xFFFFFF)));
|
||||
|
||||
/* 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
|
||||
* lower 24 bits of the obscured commitment number
|
||||
*/
|
||||
tx->wtx->locktime =
|
||||
(0x20000000 | (obscured_commitment_number & 0xFFFFFF));
|
||||
bitcoin_tx_set_locktime(tx,
|
||||
(0x20000000 | (obscured_commitment_number & 0xFFFFFF)));
|
||||
|
||||
/* 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);
|
||||
tx->chainparams = chainparams;
|
||||
|
||||
tx->wtx->locktime = cltv_expiry;
|
||||
bitcoin_tx_set_locktime(tx, cltv_expiry);
|
||||
return tx;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue