Browse Source

txprepare: Verify that outputs arg is an array

We were not checking that outputs is indeed an array, and just going
ahead creating the array of outputs. Since `tok->size` for a string is
0 we ended up ignoring the argument altogether and thus the created
transaction would end up only with a single change output.

Fixes #4258
fix-mocks
Christian Decker 4 years ago
committed by Rusty Russell
parent
commit
e186b2620a
  1. 7
      plugins/txprepare.c

7
plugins/txprepare.c

@ -67,6 +67,13 @@ static struct command_result *param_outputs(struct command *cmd,
size_t i;
const jsmntok_t *t;
if (tok->type != JSMN_ARRAY) {
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Expected an array of outputs in the "
"format '[{\"txid\":0}, ...]', got \"%s\"",
json_strdup(tmpctx, buffer, tok));
}
txp->outputs = tal_arr(txp, struct tx_output, tok->size);
txp->output_total = AMOUNT_SAT(0);
txp->all_output_idx = -1;

Loading…
Cancel
Save