| 137 | } |
| 138 | |
| 139 | static void dump_token_shallow(char **str, struct token *token, char *prefix) |
| 140 | { |
| 141 | const char *tmp; |
| 142 | |
| 143 | tal_append_fmt(str, "%s%zu:%s", prefix, token->script_index, |
| 144 | token_type_str(token->type)); |
| 145 | |
| 146 | if (token->c) { |
| 147 | tal_append_fmt(str, " char:"); |
| 148 | if (token->c == '\n') |
| 149 | tal_append_fmt(str, "'\\n'"); |
| 150 | else if (token->c == '\r') |
| 151 | tal_append_fmt(str, "'\\r'"); |
| 152 | else if (token->c == '\t') |
| 153 | tal_append_fmt(str, "'\\t'"); |
| 154 | else if (token->c < ' ') |
| 155 | tal_append_fmt(str, "0x%02x", token->c); |
| 156 | else |
| 157 | tal_append_fmt(str, "'%c'", token->c); |
| 158 | } |
| 159 | |
| 160 | if (token->str) |
| 161 | tal_append_fmt(str, " str:\"%s\"", token->str); |
| 162 | |
| 163 | if (token->node_id) |
| 164 | tal_append_fmt(str, " node_id:%s", |
| 165 | fmt_node_id(tmpctx, token->node_id)); |
| 166 | |
| 167 | if (token->chan_id) |
| 168 | tal_append_fmt(str, " chan_id:%s", |
| 169 | tal_hexstr(tmpctx, token->chan_id, sizeof(struct channel_id))); |
| 170 | |
| 171 | if (token->ppm) |
| 172 | tal_append_fmt(str, " ppm:%u", token->ppm); |
| 173 | |
| 174 | if (!amount_sat_is_zero(token->amount_sat) || token->type == TOK_SATS) { |
| 175 | tmp = fmt_amount_sat(tmpctx, token->amount_sat); |
| 176 | tal_append_fmt(str, " amnt:%s", tmp); |
| 177 | tal_free(tmp); |
| 178 | } |
| 179 | |
| 180 | if (token->flags) |
| 181 | tal_append_fmt(str, " flags:%u", token->flags); |
| 182 | } |
| 183 | #endif /* SCRIPT_DUMP_TOKENS || SCRIPT_DUMP_SEGMENTS */ |
| 184 | |
| 185 | #if SCRIPT_DUMP_TOKENS |
no test coverage detected