MCPcopy Create free account
hub / github.com/ElementsProject/lightning / new_missed_channel_account

Function new_missed_channel_account

plugins/bkpr/bookkeeper.c:607–750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605}
606
607static 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))

Callers 2

listpeers_multi_doneFunction · 0.85
listpeers_doneFunction · 0.85

Calls 15

amount_msat_addFunction · 0.85
find_push_amtsFunction · 0.85
log_chain_eventFunction · 0.85
maybe_update_accountFunction · 0.85
try_update_open_feesFunction · 0.85
amount_msat_zeroFunction · 0.85
log_channel_eventFunction · 0.85
new_channel_eventFunction · 0.70
json_get_memberFunction · 0.50
json_scanFunction · 0.50
plugin_errFunction · 0.50

Tested by

no test coverage detected