| 605 | } |
| 606 | |
| 607 | static bool new_missed_channel_account(struct command *cmd, |
| 608 | const char *buf, |
| 609 | const jsmntok_t *result, |
| 610 | struct account *acct, |
| 611 | const char *currency, |
| 612 | u64 timestamp) |
| 613 | { |
| 614 | struct chain_event *chain_ev; |
| 615 | size_t i, j; |
| 616 | const jsmntok_t *curr_peer, *curr_chan, |
| 617 | *peer_arr_tok, *chan_arr_tok; |
| 618 | |
| 619 | peer_arr_tok = json_get_member(buf, result, "peers"); |
| 620 | assert(peer_arr_tok->type == JSMN_ARRAY); |
| 621 | /* There should only be one peer */ |
| 622 | json_for_each_arr(i, curr_peer, peer_arr_tok) { |
| 623 | const char *err; |
| 624 | struct node_id peer_id; |
| 625 | |
| 626 | err = json_scan(cmd, buf, curr_peer, "{id:%}", |
| 627 | JSON_SCAN(json_to_node_id, &peer_id)); |
| 628 | |
| 629 | if (err) |
| 630 | plugin_err(cmd->plugin, |
| 631 | "failure scanning listpeer" |
| 632 | " result: %s", err); |
| 633 | |
| 634 | json_get_member(buf, curr_peer, "id"); |
| 635 | chan_arr_tok = json_get_member(buf, curr_peer, |
| 636 | "channels"); |
| 637 | assert(chan_arr_tok->type == JSMN_ARRAY); |
| 638 | json_for_each_arr(j, curr_chan, chan_arr_tok) { |
| 639 | struct bitcoin_outpoint opt; |
| 640 | struct amount_msat amt, remote_amt, |
| 641 | push_credit, push_debit; |
| 642 | char *opener, *chan_id; |
| 643 | enum mvt_tag *tags; |
| 644 | bool ok, is_opener, is_leased; |
| 645 | |
| 646 | err = json_scan(tmpctx, buf, curr_chan, |
| 647 | "{channel_id:%," |
| 648 | "funding_txid:%," |
| 649 | "funding_outnum:%," |
| 650 | "funding:{local_funds_msat:%," |
| 651 | "remote_funds_msat:%}," |
| 652 | "opener:%}", |
| 653 | JSON_SCAN_TAL(tmpctx, json_strdup, &chan_id), |
| 654 | JSON_SCAN(json_to_txid, &opt.txid), |
| 655 | JSON_SCAN(json_to_number, &opt.n), |
| 656 | JSON_SCAN(json_to_msat, &amt), |
| 657 | JSON_SCAN(json_to_msat, &remote_amt), |
| 658 | JSON_SCAN_TAL(tmpctx, json_strdup, &opener)); |
| 659 | if (err) |
| 660 | plugin_err(cmd->plugin, |
| 661 | "failure scanning listpeer" |
| 662 | " result: %s", err); |
| 663 | |
| 664 | if (!streq(chan_id, acct->name)) |
no test coverage detected