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

Function hook_extract_shutdown_script

lightningd/dual_open_control.c:367–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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