| 1192 | } |
| 1193 | |
| 1194 | static void htlc_accepted_hook_serialize(struct htlc_accepted_hook_payload *p, |
| 1195 | struct json_stream *s, |
| 1196 | struct plugin *plugin) |
| 1197 | { |
| 1198 | const struct route_step *rs = p->route_step; |
| 1199 | struct htlc_in *hin = p->hin; |
| 1200 | s32 expiry = hin->cltv_expiry, blockheight = p->ld->topology->tip->height; |
| 1201 | |
| 1202 | tal_free(hin->status); |
| 1203 | hin->status = |
| 1204 | tal_fmt(hin, "Waiting for the htlc_accepted hook of plugin %s", |
| 1205 | plugin->shortname); |
| 1206 | |
| 1207 | if (p->channel && p->channel->peer) |
| 1208 | json_add_node_id(s, "peer_id", &p->channel->peer->id); |
| 1209 | |
| 1210 | json_object_start(s, "onion"); |
| 1211 | |
| 1212 | json_add_hex_talarr(s, "payload", rs->raw_payload); |
| 1213 | if (p->payload) { |
| 1214 | json_add_string(s, "type", "tlv"); |
| 1215 | |
| 1216 | if (p->payload->forward_channel) |
| 1217 | json_add_short_channel_id(s, "short_channel_id", |
| 1218 | *p->payload->forward_channel); |
| 1219 | if (p->payload->forward_node_id) |
| 1220 | json_add_pubkey(s, "next_node_id", |
| 1221 | p->payload->forward_node_id); |
| 1222 | json_add_amount_msat(s, "forward_msat", |
| 1223 | p->payload->amt_to_forward); |
| 1224 | json_add_u32(s, "outgoing_cltv_value", p->payload->outgoing_cltv); |
| 1225 | /* These are specified together in TLV, so only print total_msat |
| 1226 | * if payment_secret set (ie. modern, and final hop) */ |
| 1227 | if (p->payload->payment_secret) { |
| 1228 | json_add_amount_msat(s, "total_msat", |
| 1229 | *p->payload->total_msat); |
| 1230 | json_add_secret(s, "payment_secret", |
| 1231 | p->payload->payment_secret); |
| 1232 | } |
| 1233 | if (p->payload->payment_metadata) { |
| 1234 | json_add_hex_talarr(s, "payment_metadata", |
| 1235 | p->payload->payment_metadata); |
| 1236 | } |
| 1237 | } |
| 1238 | json_add_hex_talarr(s, "next_onion", p->next_onion); |
| 1239 | json_add_secret(s, "shared_secret", hin->shared_secret); |
| 1240 | json_object_end(s); |
| 1241 | |
| 1242 | if (p->fwd_channel_id) |
| 1243 | json_add_channel_id(s, "forward_to", p->fwd_channel_id); |
| 1244 | |
| 1245 | json_object_start(s, "htlc"); |
| 1246 | json_add_short_channel_id( |
| 1247 | s, "short_channel_id", |
| 1248 | channel_scid_or_local_alias(hin->key.channel)); |
| 1249 | json_add_u64(s, "id", hin->key.id); |
| 1250 | json_add_amount_msat(s, "amount_msat", hin->msat); |
| 1251 | json_add_u32(s, "cltv_expiry", expiry); |
nothing calls this directly
no test coverage detected