Browse Source

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
nifty/pset-pre
niftynei 5 years ago
committed by Christian Decker
parent
commit
f9300e8480
  1. 6
      bitcoin/tx.c
  2. 3
      bitcoin/tx.h
  3. 4
      channeld/commit_tx.c
  4. 4
      common/initial_commit_tx.c
  5. 2
      onchaind/test/run-grind_feerate-bug.c

6
bitcoin/tx.c

@ -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,

3
bitcoin/tx.h

@ -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

4
channeld/commit_tx.c

@ -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:
*

4
common/initial_commit_tx.c

@ -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:
*

2
onchaind/test/run-grind_feerate-bug.c

@ -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…
Cancel
Save