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

Function hsmd_handle_client_message

hsmd/libhsmd.c:2184–2356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2182}
2183
2184u8 *hsmd_handle_client_message(const tal_t *ctx, struct hsmd_client *client,
2185 const u8 *msg)
2186{
2187 enum hsmd_wire t = fromwire_peektype(msg);
2188
2189 hsmd_status_debug("Client: Received message %d from client", t);
2190
2191 /* Before we do anything else, is this client allowed to do
2192 * what he asks for? */
2193 if (!hsmd_check_client_capabilities(client, t))
2194 return hsmd_status_bad_request_fmt(
2195 client, msg, "does not have capability to run %d", t);
2196
2197 /* If we aren't initialized yet we better get an init message
2198 * first. Otherwise we don't load the secret and every
2199 * signature we produce is just going to be junk. */
2200 if (!initialized && t != WIRE_HSMD_INIT)
2201 hsmd_status_failed(STATUS_FAIL_MASTER_IO,
2202 "hsmd was not initialized correctly, expected "
2203 "message type %d, got %d",
2204 WIRE_HSMD_INIT, t);
2205
2206 /* Now actually go and do what the client asked for */
2207 switch (t) {
2208 case WIRE_HSMD_DEV_PREINIT:
2209 case WIRE_HSMD_INIT:
2210 case WIRE_HSMD_CLIENT_HSMFD:
2211 /* Not implemented yet. Should not have been passed here yet. */
2212 return hsmd_status_bad_request_fmt(
2213 client, msg,
2214 "Message of type %s should be handled externally to "
2215 "libhsmd",
2216 hsmd_wire_name(t));
2217
2218 case WIRE_HSMD_NEW_CHANNEL:
2219 return handle_new_channel(client, msg);
2220 case WIRE_HSMD_SETUP_CHANNEL:
2221 return handle_setup_channel(client, msg);
2222 case WIRE_HSMD_CHECK_OUTPOINT:
2223 return handle_check_outpoint(client, msg);
2224 case WIRE_HSMD_LOCK_OUTPOINT:
2225 return handle_lock_outpoint(client, msg);
2226 case WIRE_HSMD_FORGET_CHANNEL:
2227 return handle_forget_channel(client, msg);
2228 case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY:
2229 return handle_get_output_scriptpubkey(client, msg);
2230 case WIRE_HSMD_CHECK_FUTURE_SECRET:
2231 return handle_check_future_secret(client, msg);
2232 case WIRE_HSMD_ECDH_REQ:
2233 return handle_ecdh(client, msg);
2234 case WIRE_HSMD_SIGN_INVOICE:
2235 return handle_sign_invoice(client, msg);
2236 case WIRE_HSMD_SIGN_OPTION_WILL_FUND_OFFER:
2237 return handle_sign_option_will_fund_offer(client, msg);
2238 case WIRE_HSMD_SIGN_BOLT12:
2239 return handle_sign_bolt12(client, msg);
2240 case WIRE_HSMD_SIGN_BOLT12_2:
2241 return handle_sign_bolt12_2(client, msg);

Callers 1

handle_clientFunction · 0.85

Calls 15

fromwire_peektypeFunction · 0.85
hsmd_wire_nameFunction · 0.85
handle_new_channelFunction · 0.85
handle_setup_channelFunction · 0.85
handle_check_outpointFunction · 0.85
handle_lock_outpointFunction · 0.85
handle_forget_channelFunction · 0.85
handle_ecdhFunction · 0.85

Tested by

no test coverage detected