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

Function rbf_channel_hook_deserialize

lightningd/dual_open_control.c:558–645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556
557
558static bool
559rbf_channel_hook_deserialize(struct rbf_channel_payload *payload,
560 const char *buffer,
561 const jsmntok_t *toks)
562{
563 struct subd *dualopend = payload->dualopend;
564 struct channel *channel = payload->channel;
565
566 if (!dualopend) {
567 rbf_channel_hook_cb(payload);
568 return false;
569 }
570
571 /* FIXME: move to new json extraction */
572 const jsmntok_t *t_result = json_get_member(buffer, toks, "result");
573 if (!t_result)
574 fatal("Plugin returned an invalid response to the"
575 " rbf_channel hook: %.*s",
576 json_tok_full_len(toks),
577 json_tok_full(buffer, toks));
578
579 if (json_tok_streq(buffer, t_result, "reject")) {
580 if (json_get_member(buffer, toks, "psbt"))
581 fatal("Plugin rejected rbf_channel but"
582 " also set `psbt`");
583 if (json_get_member(buffer, toks, "our_funding_msat"))
584 fatal("Plugin rejected rbf_channel but"
585 " also set `our_funding_msat`");
586
587 const jsmntok_t *t_errmsg = json_get_member(buffer, toks,
588 "error_message");
589 if (t_errmsg)
590 payload->err_msg = json_strdup(payload, buffer,
591 t_errmsg);
592 else
593 payload->err_msg = "";
594
595 rbf_channel_hook_cb(payload);
596 return false;
597 } else if (!json_tok_streq(buffer, t_result, "continue"))
598 fatal("Plugin returned invalid response to rbf_channel hook:"
599 " %.*s", json_tok_full_len(toks),
600 json_tok_full(buffer, toks));
601
602 if (!hook_extract_psbt(payload, dualopend, buffer, toks,
603 "rbf_channel", true, &payload->psbt))
604 return false;
605
606 if (payload->psbt) {
607 enum tx_role our_role = channel->opener == LOCAL ?
608 TX_INITIATOR : TX_ACCEPTER;
609 psbt_add_serials(payload->psbt, our_role);
610 }
611
612 /* We require the PSBT to meet certain criteria such as
613 * extra, proprietary fields (`serial_id`s) or
614 * to have a `redeemscripts` iff the inputs are P2SH.
615 *

Callers

nothing calls this directly

Calls 13

rbf_channel_hook_cbFunction · 0.85
json_get_memberFunction · 0.85
json_tok_streqFunction · 0.85
hook_extract_psbtFunction · 0.85
psbt_add_serialsFunction · 0.85
psbt_has_required_fieldsFunction · 0.85
fmt_wally_psbtFunction · 0.85
hook_extract_amountFunction · 0.85
amount_sat_is_zeroFunction · 0.85
fatalFunction · 0.70
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected