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

Function option_currency

plugins/bkpr/bookkeeper.c:2043–2088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2041}
2042
2043static char *option_currency(struct command *cmd,
2044 const char *arg,
2045 bool check_only,
2046 struct bkpr *bkpr)
2047{
2048 const struct iso4217_name_and_divisor *newcur;
2049
2050 /* Explicit empty string means unset. */
2051 if (!streq(arg, "")) {
2052 newcur = find_iso4217(arg, strlen(arg));
2053 if (!newcur)
2054 return "unknown ISO4217 code";
2055 } else
2056 newcur = NULL;
2057
2058 if (check_only)
2059 return NULL;
2060
2061 /* Changed? Clean up old one! */
2062 if (bkpr->currency != NULL) {
2063 /* Stop refreshes */
2064 bkpr->currency_cmds = tal_free(bkpr->currency_cmds);
2065 /* Clear existing values and free contents.*/
2066 tal_free(bkpr->currency_rates);
2067 bkpr->currency_rates = tal(bkpr, currencymap_t);
2068 uintmap_init(bkpr->currency_rates);
2069 memleak_add_helper(bkpr->currency_rates, memleak_scan_currencyrates);
2070 bkpr->currency = NULL;
2071 }
2072
2073 if (!newcur)
2074 return NULL;
2075
2076 bkpr->currency = newcur;
2077 /* Reset this so we get a new message for new currency */
2078 bkpr->warned_currency_fail = false;
2079
2080 /* Start with saved currency rates */
2081 load_currencyrates(cmd, bkpr);
2082
2083 /* Don't do this yet if we're before init! */
2084 if (bkpr->accounts)
2085 start_waiting_for_currency(bkpr, cmd);
2086
2087 return NULL;
2088}
2089
2090int main(int argc, char *argv[])
2091{

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