From 172b9d7ae3671e58f94c52506ecd5632b48ef476 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 20 Aug 2020 13:41:10 +0930 Subject: [PATCH] bitcoin: add nlocktime arg to create_psbt. Signed-off-by: Rusty Russell --- bitcoin/psbt.c | 4 ++-- bitcoin/psbt.h | 3 ++- common/psbt_open.c | 4 ++-- common/test/run-psbt_diff.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bitcoin/psbt.c b/bitcoin/psbt.c index e417c5d47..7c3d54f88 100644 --- a/bitcoin/psbt.c +++ b/bitcoin/psbt.c @@ -36,13 +36,13 @@ static struct wally_psbt *init_psbt(const tal_t *ctx, size_t num_inputs, size_t return tal_steal(ctx, psbt); } -struct wally_psbt *create_psbt(const tal_t *ctx, size_t num_inputs, size_t num_outputs) +struct wally_psbt *create_psbt(const tal_t *ctx, size_t num_inputs, size_t num_outputs, u32 locktime) { int wally_err; struct wally_tx *wtx; struct wally_psbt *psbt; - if (wally_tx_init_alloc(WALLY_TX_VERSION_2, 0, num_inputs, num_outputs, &wtx) != WALLY_OK) + if (wally_tx_init_alloc(WALLY_TX_VERSION_2, locktime, num_inputs, num_outputs, &wtx) != WALLY_OK) abort(); psbt = init_psbt(ctx, num_inputs, num_outputs); diff --git a/bitcoin/psbt.h b/bitcoin/psbt.h index effd9fac0..cb6d766bf 100644 --- a/bitcoin/psbt.h +++ b/bitcoin/psbt.h @@ -25,8 +25,9 @@ void psbt_destroy(struct wally_psbt *psbt); * @ctx - allocation context * @num_inputs - number of inputs to allocate * @num_outputs - number of outputs to allocate + * @locktime - locktime for the transaction */ -struct wally_psbt *create_psbt(const tal_t *ctx, size_t num_inputs, size_t num_outputs); +struct wally_psbt *create_psbt(const tal_t *ctx, size_t num_inputs, size_t num_outputs, u32 locktime); /* * new_psbt - Create a PSBT, using the passed in tx diff --git a/common/psbt_open.c b/common/psbt_open.c index bfc74bba1..ff2617e4c 100644 --- a/common/psbt_open.c +++ b/common/psbt_open.c @@ -61,7 +61,7 @@ static const u8 *linearize_input(const tal_t *ctx, const struct wally_psbt_input *in, const struct wally_tx_input *tx_in) { - struct wally_psbt *psbt = create_psbt(NULL, 1, 0); + struct wally_psbt *psbt = create_psbt(NULL, 1, 0, 0); size_t byte_len; if (wally_tx_add_input(psbt->tx, tx_in) != WALLY_OK) @@ -87,7 +87,7 @@ static const u8 *linearize_output(const tal_t *ctx, const struct wally_psbt_output *out, const struct wally_tx_output *tx_out) { - struct wally_psbt *psbt = create_psbt(NULL, 1, 1); + struct wally_psbt *psbt = create_psbt(NULL, 1, 1, 0); size_t byte_len; struct bitcoin_txid txid; diff --git a/common/test/run-psbt_diff.c b/common/test/run-psbt_diff.c index de5be99b8..04693e62c 100644 --- a/common/test/run-psbt_diff.c +++ b/common/test/run-psbt_diff.c @@ -127,7 +127,7 @@ int main(int argc, const char *argv[]) chainparams = chainparams_for_network("bitcoin"); /* Create two psbts! */ - end = create_psbt(tmpctx, 1, 1); + end = create_psbt(tmpctx, 1, 1, 0); if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK) abort(); diff_count(start, end, 0, 0);