| 766 | } |
| 767 | |
| 768 | static struct command_result *currency_done(struct command *cmd, |
| 769 | const char *method, |
| 770 | const char *buf, |
| 771 | const jsmntok_t *result, |
| 772 | struct invreq *ir) |
| 773 | { |
| 774 | const jsmntok_t *msat = json_get_member(buf, result, "msat"); |
| 775 | struct amount_msat amount; |
| 776 | |
| 777 | /* Fail in this case, forwarding warnings. */ |
| 778 | if (!msat) |
| 779 | return fail_internalerr(cmd, ir, |
| 780 | "Cannot convert currency %.*s: %.*s", |
| 781 | (int)tal_bytelen(ir->invreq->offer_currency), |
| 782 | (const char *)ir->invreq->offer_currency, |
| 783 | json_tok_full_len(result), |
| 784 | json_tok_full(buf, result)); |
| 785 | |
| 786 | if (!json_to_msat(buf, msat, &amount)) |
| 787 | return fail_internalerr(cmd, ir, |
| 788 | "Bad convert for currency %.*s: %.*s", |
| 789 | (int)tal_bytelen(ir->invreq->offer_currency), |
| 790 | (const char *)ir->invreq->offer_currency, |
| 791 | json_tok_full_len(msat), |
| 792 | json_tok_full(buf, msat)); |
| 793 | |
| 794 | return handle_amount_and_recurrence(cmd, ir, amount); |
| 795 | } |
| 796 | |
| 797 | static struct command_result *convert_currency(struct command *cmd, |
| 798 | struct invreq *ir) |
nothing calls this directly
no test coverage detected