MCPcopy Create free account
hub / github.com/ElementsProject/lightning / get_data_details

Function get_data_details

plugins/renepay/json.c:119–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119static bool get_data_details(struct payment_result *result,
120 const char *buffer,
121 const jsmntok_t *datatok)
122{
123
124 const jsmntok_t *erridxtok, *failcodetok, *errnodetok, *errchantok,
125 *errdirtok, *rawmsgtok, *failcodenametok;
126 erridxtok = json_get_member(buffer, datatok, "erring_index");
127 failcodetok = json_get_member(buffer, datatok, "failcode");
128
129 if (!erridxtok || !failcodetok)
130 return false;
131 result->failcode = tal(result, enum onion_wire);
132 json_to_u32(buffer, failcodetok, result->failcode);
133
134 result->erring_index = tal(result, u32);
135 json_to_u32(buffer, erridxtok, result->erring_index);
136
137 // search for other fields
138 errnodetok = json_get_member(buffer, datatok, "erring_node");
139 errchantok = json_get_member(buffer, datatok, "erring_channel");
140 errdirtok = json_get_member(buffer, datatok, "erring_direction");
141 failcodenametok = json_get_member(buffer, datatok, "failcodename");
142 rawmsgtok = json_get_member(buffer, datatok, "raw_message");
143
144 if (errnodetok != NULL) {
145 result->erring_node = tal(result, struct node_id);
146 json_to_node_id(buffer, errnodetok, result->erring_node);
147 }
148
149 if (errchantok != NULL) {
150 result->erring_channel = tal(result, struct short_channel_id);
151 json_to_short_channel_id(buffer, errchantok,
152 result->erring_channel);
153 }
154 if (errdirtok != NULL) {
155 result->erring_direction = tal(result, int);
156 json_to_int(buffer, errdirtok, result->erring_direction);
157 }
158 if (rawmsgtok != NULL)
159 result->raw_message =
160 json_tok_bin_from_hex(result, buffer, rawmsgtok);
161
162 if (failcodenametok != NULL)
163 result->failcodename =
164 json_strdup(result, buffer, failcodenametok);
165
166 return true;
167}
168
169struct payment_result *tal_sendpay_result_from_json(const tal_t *ctx,
170 const char *buffer,

Callers 1

Calls 7

json_get_memberFunction · 0.85
json_to_intFunction · 0.85
json_to_u32Function · 0.50
json_to_node_idFunction · 0.50
json_to_short_channel_idFunction · 0.50
json_tok_bin_from_hexFunction · 0.50
json_strdupFunction · 0.50

Tested by

no test coverage detected