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

Function rbf_channel_hook_deserialize

lightningd/dual_open_control.c:521–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

519
520
521static bool
522rbf_channel_hook_deserialize(struct rbf_channel_payload *payload,
523 const char *buffer,
524 const jsmntok_t *toks)
525{
526 struct subd *dualopend = payload->dualopend;
527 struct channel *channel = payload->channel;
528
529 if (!dualopend) {
530 rbf_channel_hook_cb(payload);
531 return false;
532 }
533
534 /* FIXME: move to new json extraction */
535 const jsmntok_t *t_result = json_get_member(buffer, toks, "result");
536 if (!t_result)
537 fatal("Plugin returned an invalid response to the"
538 " rbf_channel hook: %.*s",
539 json_tok_full_len(toks),
540 json_tok_full(buffer, toks));
541
542 if (json_tok_streq(buffer, t_result, "reject")) {
543 if (json_get_member(buffer, toks, "psbt"))
544 fatal("Plugin rejected rbf_channel but"
545 " also set `psbt`");
546 if (json_get_member(buffer, toks, "our_funding_msat"))
547 fatal("Plugin rejected rbf_channel but"
548 " also set `our_funding_msat`");
549
550 const jsmntok_t *t_errmsg = json_get_member(buffer, toks,
551 "error_message");
552 if (t_errmsg)
553 payload->err_msg = json_strdup(payload, buffer,
554 t_errmsg);
555 else
556 payload->err_msg = "";
557
558 rbf_channel_hook_cb(payload);
559 return false;
560 } else if (!json_tok_streq(buffer, t_result, "continue"))
561 fatal("Plugin returned invalid response to rbf_channel hook:"
562 " %.*s", json_tok_full_len(toks),
563 json_tok_full(buffer, toks));
564
565 if (!hook_extract_psbt(payload, dualopend, buffer, toks,
566 "rbf_channel", true, &payload->psbt))
567 return false;
568
569 if (payload->psbt) {
570 enum tx_role our_role = channel->opener == LOCAL ?
571 TX_INITIATOR : TX_ACCEPTER;
572 psbt_add_serials(payload->psbt, our_role);
573 }
574
575 /* We require the PSBT to meet certain criteria such as
576 * extra, proprietary fields (`serial_id`s) or
577 * to have a `redeemscripts` iff the inputs are P2SH.
578 *

Callers

nothing calls this directly

Calls 13

rbf_channel_hook_cbFunction · 0.85
hook_extract_psbtFunction · 0.85
psbt_add_serialsFunction · 0.85
psbt_has_required_fieldsFunction · 0.85
hook_extract_amountFunction · 0.85
amount_sat_zeroFunction · 0.85
fatalFunction · 0.70
json_get_memberFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_tok_streqFunction · 0.50
json_strdupFunction · 0.50

Tested by

no test coverage detected