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

Function rbf_channel_hook_deserialize

lightningd/dual_open_control.c:559–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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