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

Function option_currency

plugins/bkpr/bookkeeper.c:2019–2064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2017}
2018
2019static char *option_currency(struct command *cmd,
2020 const char *arg,
2021 bool check_only,
2022 struct bkpr *bkpr)
2023{
2024 const struct iso4217_name_and_divisor *newcur;
2025
2026 /* Explicit empty string means unset. */
2027 if (!streq(arg, "")) {
2028 newcur = find_iso4217(arg, strlen(arg));
2029 if (!newcur)
2030 return "unknown ISO4217 code";
2031 } else
2032 newcur = NULL;
2033
2034 if (check_only)
2035 return NULL;
2036
2037 /* Changed? Clean up old one! */
2038 if (bkpr->currency != NULL) {
2039 /* Stop refreshes */
2040 bkpr->currency_cmds = tal_free(bkpr->currency_cmds);
2041 /* Clear existing values and free contents.*/
2042 tal_free(bkpr->currency_rates);
2043 bkpr->currency_rates = tal(bkpr, currencymap_t);
2044 uintmap_init(bkpr->currency_rates);
2045 memleak_add_helper(bkpr->currency_rates, memleak_scan_currencyrates);
2046 bkpr->currency = NULL;
2047 }
2048
2049 if (!newcur)
2050 return NULL;
2051
2052 bkpr->currency = newcur;
2053 /* Reset this so we get a new message for new currency */
2054 bkpr->warned_currency_fail = false;
2055
2056 /* Start with saved currency rates */
2057 load_currencyrates(cmd, bkpr);
2058
2059 /* Don't do this yet if we're before init! */
2060 if (bkpr->accounts)
2061 start_waiting_for_currency(bkpr, cmd);
2062
2063 return NULL;
2064}
2065
2066int main(int argc, char *argv[])
2067{

Callers

nothing calls this directly

Calls 4

find_iso4217Function · 0.85
tal_freeFunction · 0.85
load_currencyratesFunction · 0.85

Tested by

no test coverage detected