| 1029 | } |
| 1030 | |
| 1031 | static void htlc_accepted_hook_serialize(struct htlc_accepted_hook_payload *p, |
| 1032 | struct json_stream *s, |
| 1033 | struct plugin *plugin) |
| 1034 | { |
| 1035 | const struct route_step *rs = p->route_step; |
| 1036 | struct htlc_in *hin = p->hin; |
| 1037 | s32 expiry = hin->cltv_expiry, blockheight = p->ld->topology->tip->height; |
| 1038 | |
| 1039 | tal_free(hin->status); |
| 1040 | hin->status = |
| 1041 | tal_fmt(hin, "Waiting for the htlc_accepted hook of plugin %s", |
| 1042 | plugin->shortname); |
| 1043 | |
| 1044 | json_object_start(s, "onion"); |
| 1045 | |
| 1046 | json_add_hex_talarr(s, "payload", rs->raw_payload); |
| 1047 | if (p->payload) { |
| 1048 | json_add_string(s, "type", "tlv"); |
| 1049 | |
| 1050 | if (p->payload->forward_channel) |
| 1051 | json_add_short_channel_id(s, "short_channel_id", |
| 1052 | p->payload->forward_channel); |
| 1053 | if (deprecated_apis) |
| 1054 | json_add_string(s, "forward_amount", |
| 1055 | fmt_amount_msat(tmpctx, |
| 1056 | p->payload->amt_to_forward)); |
| 1057 | json_add_amount_msat_only(s, "forward_msat", |
| 1058 | p->payload->amt_to_forward); |
| 1059 | json_add_u32(s, "outgoing_cltv_value", p->payload->outgoing_cltv); |
| 1060 | /* These are specified together in TLV, so only print total_msat |
| 1061 | * if payment_secret set (ie. modern, and final hop) */ |
| 1062 | if (p->payload->payment_secret) { |
| 1063 | json_add_amount_msat_only(s, "total_msat", |
| 1064 | *p->payload->total_msat); |
| 1065 | json_add_secret(s, "payment_secret", |
| 1066 | p->payload->payment_secret); |
| 1067 | } |
| 1068 | if (p->payload->payment_metadata) { |
| 1069 | json_add_hex_talarr(s, "payment_metadata", |
| 1070 | p->payload->payment_metadata); |
| 1071 | } |
| 1072 | } |
| 1073 | json_add_hex_talarr(s, "next_onion", p->next_onion); |
| 1074 | json_add_secret(s, "shared_secret", hin->shared_secret); |
| 1075 | json_object_end(s); |
| 1076 | |
| 1077 | if (p->fwd_channel_id) |
| 1078 | json_add_channel_id(s, "forward_to", p->fwd_channel_id); |
| 1079 | |
| 1080 | json_object_start(s, "htlc"); |
| 1081 | json_add_short_channel_id( |
| 1082 | s, "short_channel_id", |
| 1083 | channel_scid_or_local_alias(hin->key.channel)); |
| 1084 | json_add_u64(s, "id", hin->key.id); |
| 1085 | if (deprecated_apis) |
| 1086 | json_add_amount_msat_only(s, "amount", hin->msat); |
| 1087 | json_add_amount_msat_only(s, "amount_msat", hin->msat); |
| 1088 | json_add_u32(s, "cltv_expiry", expiry); |
nothing calls this directly
no test coverage detected