| 1700 | } |
| 1701 | |
| 1702 | static struct command_result *json_coin_moved(struct command *cmd, |
| 1703 | const char *buf, |
| 1704 | const jsmntok_t *params) |
| 1705 | { |
| 1706 | const char *err, *mvt_type, *acct_name, *coin_type; |
| 1707 | u32 version; |
| 1708 | u64 timestamp; |
| 1709 | struct amount_msat credit, debit; |
| 1710 | enum mvt_tag *tags; |
| 1711 | |
| 1712 | err = json_scan(tmpctx, buf, params, |
| 1713 | "{coin_movement:" |
| 1714 | "{version:%" |
| 1715 | ",type:%" |
| 1716 | ",account_id:%" |
| 1717 | ",credit_msat:%" |
| 1718 | ",debit_msat:%" |
| 1719 | ",coin_type:%" |
| 1720 | ",timestamp:%" |
| 1721 | "}}", |
| 1722 | JSON_SCAN(json_to_number, &version), |
| 1723 | JSON_SCAN_TAL(tmpctx, json_strdup, &mvt_type), |
| 1724 | JSON_SCAN_TAL(tmpctx, json_strdup, &acct_name), |
| 1725 | JSON_SCAN(json_to_msat, &credit), |
| 1726 | JSON_SCAN(json_to_msat, &debit), |
| 1727 | JSON_SCAN_TAL(tmpctx, json_strdup, &coin_type), |
| 1728 | JSON_SCAN(json_to_u64, ×tamp)); |
| 1729 | |
| 1730 | if (err) |
| 1731 | plugin_err(cmd->plugin, |
| 1732 | "`coin_movement` payload did not scan %s: %.*s", |
| 1733 | err, json_tok_full_len(params), |
| 1734 | json_tok_full(buf, params)); |
| 1735 | |
| 1736 | err = parse_tags(tmpctx, buf, |
| 1737 | json_get_member(buf, params, "coin_movement"), |
| 1738 | &tags); |
| 1739 | if (err) |
| 1740 | plugin_err(cmd->plugin, |
| 1741 | "`coin_movement` payload did not scan %s: %.*s", |
| 1742 | err, json_tok_full_len(params), |
| 1743 | json_tok_full(buf, params)); |
| 1744 | |
| 1745 | /* We expect version 2 of coin movements */ |
| 1746 | assert(version == 2); |
| 1747 | |
| 1748 | plugin_log(cmd->plugin, LOG_DBG, "coin_move %d (%s) %s -%s %s %"PRIu64, |
| 1749 | version, |
| 1750 | mvt_tag_str(tags[0]), |
| 1751 | type_to_string(tmpctx, struct amount_msat, &credit), |
| 1752 | type_to_string(tmpctx, struct amount_msat, &debit), |
| 1753 | mvt_type, timestamp); |
| 1754 | |
| 1755 | if (streq(mvt_type, CHAIN_MOVE)) |
| 1756 | return parse_and_log_chain_move(cmd, buf, params, |
| 1757 | acct_name, credit, debit, |
| 1758 | coin_type, timestamp, tags, |
| 1759 | NULL); |
nothing calls this directly
no test coverage detected