bitcoin: add nlocktime arg to create_psbt.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2020-08-20 13:41:10 +09:30
parent 7435d50970
commit 172b9d7ae3
4 changed files with 7 additions and 6 deletions

View File

@ -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); 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; int wally_err;
struct wally_tx *wtx; struct wally_tx *wtx;
struct wally_psbt *psbt; 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(); abort();
psbt = init_psbt(ctx, num_inputs, num_outputs); psbt = init_psbt(ctx, num_inputs, num_outputs);

View File

@ -25,8 +25,9 @@ void psbt_destroy(struct wally_psbt *psbt);
* @ctx - allocation context * @ctx - allocation context
* @num_inputs - number of inputs to allocate * @num_inputs - number of inputs to allocate
* @num_outputs - number of outputs 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 * new_psbt - Create a PSBT, using the passed in tx

View File

@ -61,7 +61,7 @@ static const u8 *linearize_input(const tal_t *ctx,
const struct wally_psbt_input *in, const struct wally_psbt_input *in,
const struct wally_tx_input *tx_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; size_t byte_len;
if (wally_tx_add_input(psbt->tx, tx_in) != WALLY_OK) 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_psbt_output *out,
const struct wally_tx_output *tx_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; size_t byte_len;
struct bitcoin_txid txid; struct bitcoin_txid txid;

View File

@ -127,7 +127,7 @@ int main(int argc, const char *argv[])
chainparams = chainparams_for_network("bitcoin"); chainparams = chainparams_for_network("bitcoin");
/* Create two psbts! */ /* 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) if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
abort(); abort();
diff_count(start, end, 0, 0); diff_count(start, end, 0, 0);