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

Function hook_extract_shutdown_script

lightningd/dual_open_control.c:365–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365static const u8 *hook_extract_shutdown_script(struct subd* dualopend,
366 const char *buffer,
367 const jsmntok_t *toks)
368{
369 const u8 *close_to_script;
370 enum address_parse_result parse_res;
371
372 if (!buffer)
373 return NULL;
374
375 const jsmntok_t *t = json_get_member(buffer, toks, "result");
376 if (!t)
377 fatal("Plugin must return a 'result'"
378 "%.*s", toks[0].end - toks[0].start,
379 buffer + toks[0].start);
380
381 if (!json_tok_streq(buffer, t, "continue")) {
382 char *errmsg = "Client error. Unable to continue";
383 subd_send_msg(dualopend,
384 take(towire_dualopend_fail(NULL, errmsg)));
385 return NULL;
386 }
387
388 const jsmntok_t *close_to_tok = json_get_member(buffer, toks, "close_to");
389 if (!close_to_tok)
390 return NULL;
391
392 parse_res = json_to_address_scriptpubkey(tmpctx, chainparams, buffer,
393 close_to_tok, &close_to_script);
394 switch (parse_res) {
395 case ADDRESS_PARSE_UNRECOGNIZED:
396 fatal("Plugin returned an invalid response to the"
397 " openchannel2.close_to hook: %.*s",
398 t->end - t->start, buffer + t->start);
399 case ADDRESS_PARSE_WRONG_NETWORK:
400 fatal("Plugin returned invalid response to the"
401 " openchannel2.close_to hook: address %s is"
402 " not on network %s",
403 tal_hex(NULL, close_to_script),
404 chainparams->network_name);
405 case ADDRESS_PARSE_SUCCESS:
406 return close_to_script;
407 }
408
409 return NULL;
410}
411
412
413static bool

Callers 1

Calls 6

json_get_memberFunction · 0.85
json_tok_streqFunction · 0.85
tal_hexFunction · 0.85
fatalFunction · 0.70
subd_send_msgFunction · 0.70

Tested by

no test coverage detected