| 578 | AUTODATA(json_command, &fundpsbt_command); |
| 579 | |
| 580 | static struct command_result *param_txout(struct command *cmd, |
| 581 | const char *name, |
| 582 | const char *buffer, |
| 583 | const jsmntok_t *tok, |
| 584 | struct utxo ***utxos) |
| 585 | { |
| 586 | size_t i; |
| 587 | const jsmntok_t *curr; |
| 588 | |
| 589 | *utxos = tal_arr(cmd, struct utxo *, tok->size); |
| 590 | |
| 591 | json_for_each_arr(i, curr, tok) { |
| 592 | struct utxo *utxo; |
| 593 | jsmntok_t txid_tok, outnum_tok; |
| 594 | struct bitcoin_outpoint outpoint; |
| 595 | |
| 596 | if (!split_tok(buffer, curr, ':', &txid_tok, &outnum_tok)) |
| 597 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 598 | "Could not decode the outpoint from \"%s\"" |
| 599 | " The utxos should be specified as" |
| 600 | " 'txid:output_index'.", |
| 601 | json_strdup(tmpctx, buffer, curr)); |
| 602 | |
| 603 | if (!json_to_txid(buffer, &txid_tok, &outpoint.txid)) { |
| 604 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 605 | "Could not get a txid out of \"%s\"", |
| 606 | json_strdup(tmpctx, buffer, &txid_tok)); |
| 607 | } |
| 608 | if (!json_to_number(buffer, &outnum_tok, &outpoint.n)) { |
| 609 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 610 | "Could not get a vout out of \"%s\"", |
| 611 | json_strdup(tmpctx, buffer, &outnum_tok)); |
| 612 | } |
| 613 | |
| 614 | utxo = wallet_utxo_get(*utxos, cmd->ld->wallet, &outpoint); |
| 615 | if (!utxo) { |
| 616 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 617 | "Unknown UTXO %s", |
| 618 | type_to_string(tmpctx, |
| 619 | struct bitcoin_outpoint, |
| 620 | &outpoint)); |
| 621 | } |
| 622 | if (utxo->status == OUTPUT_STATE_SPENT) { |
| 623 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 624 | "Already spent UTXO %s", |
| 625 | type_to_string(tmpctx, |
| 626 | struct bitcoin_outpoint, |
| 627 | &outpoint)); |
| 628 | } |
| 629 | |
| 630 | (*utxos)[i] = utxo; |
| 631 | } |
| 632 | |
| 633 | if (i == 0) |
| 634 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 635 | "Please specify an array of 'txid:output_index'," |
| 636 | " not \"%.*s\"", |
| 637 | tok->end - tok->start, |
nothing calls this directly
no test coverage detected