| 672 | } |
| 673 | |
| 674 | static struct command_result * |
| 675 | openchannel_update_ok(struct command *cmd, |
| 676 | const char *method, |
| 677 | const char *buf, |
| 678 | const jsmntok_t *result, |
| 679 | struct multifundchannel_destination *dest) |
| 680 | { |
| 681 | struct multifundchannel_command *mfc = dest->mfc; |
| 682 | const jsmntok_t *psbt_tok, *done_tok; |
| 683 | bool done; |
| 684 | |
| 685 | plugin_log(mfc->cmd->plugin, LOG_DBG, |
| 686 | "mfc %"PRIu64", dest %u: openchannel_update %s returned.", |
| 687 | mfc->id, dest->index, |
| 688 | fmt_node_id(tmpctx, &dest->id)); |
| 689 | |
| 690 | assert(!dest->updated_psbt); |
| 691 | psbt_tok = json_get_member(buf, result, "psbt"); |
| 692 | if (!psbt_tok) |
| 693 | plugin_err(cmd->plugin, |
| 694 | "`openchannel_update` did not return " |
| 695 | "'psbt': %.*s", |
| 696 | json_tok_full_len(result), |
| 697 | json_tok_full(buf, result)); |
| 698 | |
| 699 | dest->updated_psbt = json_to_psbt(dest->mfc, buf, psbt_tok); |
| 700 | if (!dest->updated_psbt) |
| 701 | plugin_err(cmd->plugin, |
| 702 | "`openchannel_update` returned invalid " |
| 703 | "'psbt': %.*s", |
| 704 | json_tok_full_len(result), |
| 705 | json_tok_full(buf, result)); |
| 706 | |
| 707 | /* FIXME: check that the channel id is correct? */ |
| 708 | done_tok = json_get_member(buf, result, "commitments_secured"); |
| 709 | if (!done_tok) |
| 710 | plugin_err(cmd->plugin, |
| 711 | "`openchannel_update` failed to return " |
| 712 | "'commitments_secured': %.*s", |
| 713 | json_tok_full_len(result), |
| 714 | json_tok_full(buf, result)); |
| 715 | |
| 716 | if (!json_to_bool(buf, done_tok, &done)) |
| 717 | plugin_err(cmd->plugin, |
| 718 | "`openchannel_update` returned invalid " |
| 719 | "'commitments_secured': %.*s", |
| 720 | json_tok_full_len(result), |
| 721 | json_tok_full(buf, result)); |
| 722 | |
| 723 | /* We loop through here several times. We may |
| 724 | * reach an intermediate state however, |
| 725 | * MULTIFUNDCHANNEL_SIGNED_NOT_SECURED, so we only update |
| 726 | * to UPDATED iff we're at the previous state (STARTED) */ |
| 727 | if (dest->state == MULTIFUNDCHANNEL_STARTED) |
| 728 | dest->state = MULTIFUNDCHANNEL_UPDATED; |
| 729 | |
| 730 | if (done) { |
| 731 | const jsmntok_t *outnum_tok, *close_to_tok; |
nothing calls this directly
no test coverage detected