| 2497 | } |
| 2498 | |
| 2499 | static void handle_validate_rbf(struct subd *dualopend, |
| 2500 | const u8 *msg) |
| 2501 | { |
| 2502 | struct wally_psbt *candidate_psbt; |
| 2503 | struct channel_inflight *inflight; |
| 2504 | struct channel *channel = dualopend->channel; |
| 2505 | bool *inputs_present; |
| 2506 | struct amount_sat candidate_fee, last_fee; |
| 2507 | |
| 2508 | if (!fromwire_dualopend_rbf_validate(tmpctx, msg, |
| 2509 | &candidate_psbt)) { |
| 2510 | channel_internal_error(channel, |
| 2511 | "Bad DUALOPEND_RBF_VALIDATE: %s", |
| 2512 | tal_hex(tmpctx, msg)); |
| 2513 | return; |
| 2514 | } |
| 2515 | |
| 2516 | inputs_present = tal_arr(tmpctx, bool, candidate_psbt->num_inputs); |
| 2517 | memset(inputs_present, true, tal_bytelen(inputs_present)); |
| 2518 | |
| 2519 | /* BOLT #2: |
| 2520 | * |
| 2521 | * - if this is an RBF attempt: |
| 2522 | * - MUST fail the negotiation if: |
| 2523 | * ... |
| 2524 | * - the transaction does not share at least one input with |
| 2525 | * each previous funding transaction |
| 2526 | */ |
| 2527 | list_for_each(&channel->inflights, inflight, list) { |
| 2528 | /* Remove every non-matching input from set */ |
| 2529 | for (size_t i = 0; i < candidate_psbt->num_inputs; i++) { |
| 2530 | const struct wally_psbt_input *input = |
| 2531 | &candidate_psbt->inputs[i]; |
| 2532 | struct bitcoin_outpoint outpoint; |
| 2533 | |
| 2534 | wally_psbt_input_get_outpoint(input, &outpoint); |
| 2535 | |
| 2536 | if (!psbt_has_input(inflight->funding_psbt, |
| 2537 | &outpoint)) |
| 2538 | inputs_present[i] = false; |
| 2539 | } |
| 2540 | } |
| 2541 | |
| 2542 | /* Are there any inputs that were present on all txs? */ |
| 2543 | if (memeqzero(inputs_present, tal_bytelen(inputs_present))) { |
| 2544 | char *errmsg; |
| 2545 | |
| 2546 | inflight = list_tail(&channel->inflights, |
| 2547 | struct channel_inflight, |
| 2548 | list); |
| 2549 | assert(inflight); |
| 2550 | |
| 2551 | errmsg = tal_fmt(tmpctx, "No overlapping input" |
| 2552 | " present. New: %s, last: %s", |
| 2553 | fmt_wally_psbt(tmpctx, |
| 2554 | candidate_psbt), |
| 2555 | fmt_wally_psbt(tmpctx, |
| 2556 | inflight->funding_psbt)); |
no test coverage detected