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