common/iso4217: make find_iso4217 a little more usable.

We often have the currency as a tal string.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-12-12 09:26:55 +10:30
committed by Christian Decker
parent d971e3de98
commit 0f2c9cf5d5
3 changed files with 14 additions and 10 deletions

View File

@@ -112,14 +112,14 @@ static bool print_amount(const struct bitcoin_blkid *chains,
minor_unit = 11;
} else {
const struct iso4217_name_and_divisor *iso;
currency = tal_strndup(tmpctx, iso4217, tal_bytelen(iso4217));
iso = find_iso4217(currency);
if (iso)
iso = find_iso4217(iso4217, tal_bytelen(iso4217));
if (iso) {
minor_unit = iso->minor_unit;
else {
currency = iso->name;
} else {
minor_unit = 0;
currency = tal_fmt(tmpctx, "%s (UNKNOWN CURRENCY)",
currency);
currency = tal_fmt(tmpctx, "%.*s (UNKNOWN CURRENCY)",
(int)tal_bytelen(iso4217), iso4217);
ok = false;
}
}