| 527 | } |
| 528 | |
| 529 | static struct command_result *json_peer_sigs(struct command *cmd, |
| 530 | const char *buf, |
| 531 | const jsmntok_t *params) |
| 532 | { |
| 533 | struct channel_id cid; |
| 534 | const struct wally_psbt *psbt; |
| 535 | struct multifundchannel_destination *dest; |
| 536 | const char *err; |
| 537 | |
| 538 | err = json_scan(tmpctx, buf, params, |
| 539 | "{openchannel_peer_sigs:" |
| 540 | "{channel_id:%,signed_psbt:%}}", |
| 541 | JSON_SCAN(json_to_channel_id, &cid), |
| 542 | JSON_SCAN_TAL(cmd, json_to_psbt, &psbt)); |
| 543 | if (err) |
| 544 | plugin_err(cmd->plugin, |
| 545 | "`openchannel_peer_sigs` did not scan: %s. %*.s", |
| 546 | err, json_tok_full_len(params), |
| 547 | json_tok_full(buf, params)); |
| 548 | |
| 549 | /* Find the destination that's got this channel_id on it! */ |
| 550 | dest = find_dest_by_channel_id(&cid); |
| 551 | if (!dest) { |
| 552 | /* if there's no pending destination... whatever */ |
| 553 | plugin_log(cmd->plugin, LOG_DBG, |
| 554 | "mfc ??: `openchannel_peer_sigs` no " |
| 555 | "pending dest found for channel_id %s", |
| 556 | type_to_string(tmpctx, struct channel_id, &cid)); |
| 557 | return notification_handled(cmd); |
| 558 | } |
| 559 | |
| 560 | plugin_log(cmd->plugin, LOG_DBG, |
| 561 | "mfc %"PRIu64":`openchannel_peer_sigs` notice received for" |
| 562 | " channel %s", |
| 563 | dest->mfc->id, |
| 564 | tal_hexstr(tmpctx, &cid, sizeof(cid))); |
| 565 | |
| 566 | /* Combine with the parent. Unknown map dupes are ignored, |
| 567 | * so the updated serial_id should persist on the parent */ |
| 568 | tal_wally_start(); |
| 569 | if (wally_psbt_combine(dest->mfc->psbt, psbt) != WALLY_OK) |
| 570 | plugin_err(cmd->plugin, |
| 571 | "mfc %"PRIu64": Unable to combine signed " |
| 572 | "PSBT with roll-up. " |
| 573 | "Signed %s, prev %s", dest->mfc->id, |
| 574 | type_to_string(tmpctx, struct wally_psbt, psbt), |
| 575 | type_to_string(tmpctx, struct wally_psbt, |
| 576 | dest->mfc->psbt)); |
| 577 | |
| 578 | tal_wally_end(dest->mfc->psbt); |
| 579 | |
| 580 | /* Bit of a race is possible here. If we're still waiting for |
| 581 | * their commitment sigs to come back, we'll be in |
| 582 | * "UPDATED" still. We check that SIGNED is hit before |
| 583 | * we mark ourselves as ready to send the sigs, so it's ok |
| 584 | * to relax this check */ |
| 585 | if (dest->state == MULTIFUNDCHANNEL_UPDATED) |
| 586 | dest->state = MULTIFUNDCHANNEL_SIGNED_NOT_SECURED; |
nothing calls this directly
no test coverage detected