| 616 | } |
| 617 | |
| 618 | static struct command_result * |
| 619 | listfunds_success(struct command *cmd, |
| 620 | const char *method, |
| 621 | const char *buf, |
| 622 | const jsmntok_t *result, |
| 623 | struct open_info *info) |
| 624 | { |
| 625 | struct amount_sat available_funds, committed_funds, total_fee; |
| 626 | const jsmntok_t *outputs_tok, *tok; |
| 627 | struct out_req *req; |
| 628 | struct bitcoin_outpoint **avail_prev_outs; |
| 629 | size_t i; |
| 630 | const char *funding_err; |
| 631 | |
| 632 | /* We only use this for RBFs, when there's a prev_outs list */ |
| 633 | struct funder_utxo **avail_utxos = tal_arr(cmd, struct funder_utxo *, 0); |
| 634 | |
| 635 | outputs_tok = json_get_member(buf, result, "outputs"); |
| 636 | if (!outputs_tok) |
| 637 | plugin_err(cmd->plugin, |
| 638 | "`listfunds` payload has no outputs token: %.*s", |
| 639 | json_tok_full_len(result), |
| 640 | json_tok_full(buf, result)); |
| 641 | |
| 642 | available_funds = AMOUNT_SAT(0); |
| 643 | committed_funds = AMOUNT_SAT(0); |
| 644 | total_fee = AMOUNT_SAT(0); |
| 645 | avail_prev_outs = tal_arr(info, struct bitcoin_outpoint *, 0); |
| 646 | json_for_each_arr(i, tok, outputs_tok) { |
| 647 | struct funder_utxo *utxo; |
| 648 | struct amount_sat est_fee; |
| 649 | bool is_reserved; |
| 650 | struct bitcoin_outpoint *prev_out; |
| 651 | char *status; |
| 652 | const char *err; |
| 653 | |
| 654 | utxo = tal(cmd, struct funder_utxo); |
| 655 | err = json_scan(tmpctx, buf, tok, |
| 656 | "{amount_msat:%" |
| 657 | ",status:%" |
| 658 | ",reserved:%" |
| 659 | ",txid:%" |
| 660 | ",output:%}", |
| 661 | JSON_SCAN(json_to_msat_as_sats, &utxo->val), |
| 662 | JSON_SCAN_TAL(cmd, json_strdup, &status), |
| 663 | JSON_SCAN(json_to_bool, &is_reserved), |
| 664 | JSON_SCAN(json_to_txid, &utxo->out.txid), |
| 665 | JSON_SCAN(json_to_number, &utxo->out.n)); |
| 666 | if (err) |
| 667 | plugin_err(cmd->plugin, |
| 668 | "`listfunds` payload did not scan. %s: %.*s", |
| 669 | err, json_tok_full_len(result), |
| 670 | json_tok_full(buf, result)); |
| 671 | |
| 672 | /* v2 opens don't support p2sh-wrapped inputs */ |
| 673 | if (json_get_member(buf, tok, "redeemscript")) |
| 674 | continue; |
| 675 |
nothing calls this directly
no test coverage detected