| 1236 | } |
| 1237 | |
| 1238 | static void htlc_accepted_hook_serialize(struct htlc_accepted_hook_payload *p, |
| 1239 | struct json_stream *s, |
| 1240 | struct plugin *plugin) |
| 1241 | { |
| 1242 | const struct route_step *rs = p->route_step; |
| 1243 | struct htlc_in *hin = p->hin; |
| 1244 | s32 expiry = hin->cltv_expiry, blockheight = p->ld->topology->tip->height; |
| 1245 | |
| 1246 | tal_free(hin->status); |
| 1247 | hin->status = |
| 1248 | tal_fmt(hin, "Waiting for the htlc_accepted hook of plugin %s", |
| 1249 | plugin->shortname); |
| 1250 | |
| 1251 | if (p->channel && p->channel->peer) |
| 1252 | json_add_node_id(s, "peer_id", &p->channel->peer->id); |
| 1253 | |
| 1254 | json_object_start(s, "onion"); |
| 1255 | |
| 1256 | json_add_hex_talarr(s, "payload", rs->raw_payload); |
| 1257 | if (p->payload) { |
| 1258 | json_add_string(s, "type", "tlv"); |
| 1259 | |
| 1260 | if (p->payload->forward_channel) |
| 1261 | json_add_short_channel_id(s, "short_channel_id", |
| 1262 | *p->payload->forward_channel); |
| 1263 | if (p->payload->forward_node_id) |
| 1264 | json_add_pubkey(s, "next_node_id", |
| 1265 | p->payload->forward_node_id); |
| 1266 | json_add_amount_msat(s, "forward_msat", |
| 1267 | p->payload->amt_to_forward); |
| 1268 | json_add_u32(s, "outgoing_cltv_value", p->payload->outgoing_cltv); |
| 1269 | /* These are specified together in TLV, so only print total_msat |
| 1270 | * if payment_secret set (ie. modern, and final hop) */ |
| 1271 | if (p->payload->payment_secret) { |
| 1272 | json_add_amount_msat(s, "total_msat", |
| 1273 | *p->payload->total_msat); |
| 1274 | json_add_secret(s, "payment_secret", |
| 1275 | p->payload->payment_secret); |
| 1276 | } |
| 1277 | if (p->payload->payment_metadata) { |
| 1278 | json_add_hex_talarr(s, "payment_metadata", |
| 1279 | p->payload->payment_metadata); |
| 1280 | } |
| 1281 | } |
| 1282 | json_add_hex_talarr(s, "next_onion", p->next_onion); |
| 1283 | json_add_secret(s, "shared_secret", hin->shared_secret); |
| 1284 | json_object_end(s); |
| 1285 | |
| 1286 | if (p->fwd_channel_id) |
| 1287 | json_add_channel_id(s, "forward_to", p->fwd_channel_id); |
| 1288 | |
| 1289 | json_object_start(s, "htlc"); |
| 1290 | json_add_short_channel_id( |
| 1291 | s, "short_channel_id", |
| 1292 | channel_scid_or_local_alias(hin->key.channel)); |
| 1293 | json_add_u64(s, "id", hin->key.id); |
| 1294 | json_add_amount_msat(s, "amount_msat", hin->msat); |
| 1295 | json_add_u32(s, "cltv_expiry", expiry); |
nothing calls this directly
no test coverage detected