| 390 | } |
| 391 | |
| 392 | char *process_interactivetx_updates(const tal_t *ctx, |
| 393 | struct interactivetx_context *ictx, |
| 394 | bool *received_tx_complete, |
| 395 | u8 **abort_msg) |
| 396 | { |
| 397 | bool we_complete = false, they_complete = false; |
| 398 | u8 *msg; |
| 399 | char *error = NULL; |
| 400 | struct wally_psbt *next_psbt; |
| 401 | |
| 402 | *abort_msg = NULL; |
| 403 | |
| 404 | if (received_tx_complete) |
| 405 | they_complete = *received_tx_complete; |
| 406 | |
| 407 | /* Build change_set and handle PSBT variables */ |
| 408 | ictx->change_set = tal_free(ictx->change_set); |
| 409 | |
| 410 | /* Call next_update_fn or default to 'desired_psbt' */ |
| 411 | next_psbt = ictx->next_update_fn(ictx, ictx); |
| 412 | |
| 413 | /* Returning NULL from next_update_fn is the same as using `current_psbt` |
| 414 | * with no changes -- both indicate no changes */ |
| 415 | if (!next_psbt) |
| 416 | next_psbt = ictx->current_psbt; |
| 417 | |
| 418 | SUPERVERBOSE("itx get_changes %zu inputs -> %zu inputs", |
| 419 | ictx->current_psbt->num_inputs, |
| 420 | next_psbt->num_inputs); |
| 421 | |
| 422 | SUPERVERBOSE("current_psbt inputs:"); |
| 423 | for(size_t i = 0; i < ictx->current_psbt->num_inputs; i++) { |
| 424 | u64 serial_id; |
| 425 | if (!psbt_get_serial_id(&ictx->current_psbt->inputs[i].unknowns, |
| 426 | &serial_id)) |
| 427 | return "interactivetx ADD_INPUT PSBT has invalid" |
| 428 | " serial_id."; |
| 429 | SUPERVERBOSE("txhash: "SHA_FMT", index: %"PRIu32", serial_id: %s", |
| 430 | SHA_VALS(ictx->current_psbt->inputs[i].txhash), |
| 431 | ictx->current_psbt->inputs[i].index, |
| 432 | tal_hexstr(ctx, &serial_id, sizeof(serial_id))); |
| 433 | } |
| 434 | |
| 435 | SUPERVERBOSE("next_psbt inputs:"); |
| 436 | for(size_t i = 0; i < next_psbt->num_inputs; i++) { |
| 437 | u64 serial_id; |
| 438 | if (!psbt_get_serial_id(&next_psbt->inputs[i].unknowns, |
| 439 | &serial_id)) |
| 440 | return "interactivetx ADD_INPUT PSBT has invalid" |
| 441 | " serial_id."; |
| 442 | SUPERVERBOSE("txhash: "SHA_FMT", index: %"PRIu32", serial_id: %s", |
| 443 | SHA_VALS(next_psbt->inputs[i].txhash), |
| 444 | next_psbt->inputs[i].index, |
| 445 | tal_hexstr(ctx, &serial_id, sizeof(serial_id))); |
| 446 | } |
| 447 | |
| 448 | ictx->change_set = get_changes(ctx, ictx, next_psbt); |
| 449 |
no test coverage detected