mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
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
This commit is contained in:
parent
47b8b46d54
commit
e186b2620a
@ -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…
Reference in New Issue
Block a user