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

Function listpeers_multi_done

plugins/bkpr/bookkeeper.c:867–922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

865}
866
867static struct command_result *
868listpeers_multi_done(struct command *cmd,
869 const char *buf,
870 const jsmntok_t *result,
871 struct new_account_info **new_accts)
872{
873 /* Let's register all these accounts! */
874 for (size_t i = 0; i < tal_count(new_accts); i++) {
875 struct new_account_info *info = new_accts[i];
876 struct acct_balance **balances, *bal;
877 struct amount_msat credit_diff, debit_diff;
878 char *err;
879
880 if (!new_missed_channel_account(cmd, buf, result,
881 info->acct,
882 info->currency,
883 info->timestamp)) {
884 plugin_log(cmd->plugin, LOG_BROKEN,
885 "Unable to find account %s in listpeers",
886 info->acct->name);
887 continue;
888 }
889
890 db_begin_transaction(db);
891 err = account_get_balance(tmpctx, db, info->acct->name,
892 false, false, &balances, NULL);
893 db_commit_transaction(db);
894
895 if (err)
896 plugin_err(cmd->plugin, err);
897
898 /* FIXME: multiple currencies */
899 if (tal_count(balances) > 0)
900 bal = balances[0];
901 else {
902 bal = tal(tmpctx, struct acct_balance);
903 bal->credit = AMOUNT_MSAT(0);
904 bal->debit= AMOUNT_MSAT(0);
905 }
906
907 err = msat_find_diff(info->curr_bal,
908 bal->credit,
909 bal->debit,
910 &credit_diff, &debit_diff);
911 if (err)
912 plugin_err(cmd->plugin, err);
913
914 log_journal_entry(info->acct,
915 info->currency,
916 info->timestamp - 1,
917 credit_diff, debit_diff);
918 }
919
920 plugin_log(cmd->plugin, LOG_DBG, "Snapshot balances updated");
921 return notification_handled(cmd);
922}
923
924static char *do_account_close_checks(const tal_t *ctx,

Callers

nothing calls this directly

Calls 8

account_get_balanceFunction · 0.85
msat_find_diffFunction · 0.85
log_journal_entryFunction · 0.85
notification_handledFunction · 0.85
plugin_logFunction · 0.50
db_commit_transactionFunction · 0.50
plugin_errFunction · 0.50

Tested by

no test coverage detected