| 519 | |
| 520 | |
| 521 | static bool |
| 522 | rbf_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 | * |
nothing calls this directly
no test coverage detected