Browse Source

bitcoin: add nlocktime arg to create_psbt.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
bump-pyln-proto
Rusty Russell 4 years ago
parent
commit
172b9d7ae3
  1. 4
      bitcoin/psbt.c
  2. 3
      bitcoin/psbt.h
  3. 4
      common/psbt_open.c
  4. 2
      common/test/run-psbt_diff.c

4
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); 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);

3
bitcoin/psbt.h

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

4
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_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;

2
common/test/run-psbt_diff.c

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

Loading…
Cancel
Save