| 2295 | } |
| 2296 | |
| 2297 | static void handle_validate_rbf(struct subd *dualopend, |
| 2298 | const u8 *msg) |
| 2299 | { |
| 2300 | struct wally_psbt *candidate_psbt; |
| 2301 | struct channel_inflight *inflight; |
| 2302 | struct channel *channel = dualopend->channel; |
| 2303 | bool *inputs_present; |
| 2304 | struct amount_sat candidate_fee, last_fee; |
| 2305 | |
| 2306 | if (!fromwire_dualopend_rbf_validate(tmpctx, msg, |
| 2307 | &candidate_psbt)) { |
| 2308 | channel_internal_error(channel, |
| 2309 | "Bad DUALOPEND_RBF_VALIDATE: %s", |
| 2310 | tal_hex(tmpctx, msg)); |
| 2311 | return; |
| 2312 | } |
| 2313 | |
| 2314 | inputs_present = tal_arr(tmpctx, bool, candidate_psbt->num_inputs); |
| 2315 | memset(inputs_present, true, tal_bytelen(inputs_present)); |
| 2316 | |
| 2317 | /* BOLT #2: |
| 2318 | * |
| 2319 | * - if this is an RBF attempt: |
| 2320 | * - MUST fail the negotiation if: |
| 2321 | * ... |
| 2322 | * - the transaction does not share at least one input with |
| 2323 | * each previous funding transaction |
| 2324 | */ |
| 2325 | list_for_each(&channel->inflights, inflight, list) { |
| 2326 | /* Remove every non-matching input from set */ |
| 2327 | for (size_t i = 0; i < candidate_psbt->num_inputs; i++) { |
| 2328 | const struct wally_psbt_input *input = |
| 2329 | &candidate_psbt->inputs[i]; |
| 2330 | struct bitcoin_outpoint outpoint; |
| 2331 | |
| 2332 | wally_psbt_input_get_outpoint(input, &outpoint); |
| 2333 | |
| 2334 | if (!psbt_has_input(inflight->funding_psbt, |
| 2335 | &outpoint)) |
| 2336 | inputs_present[i] = false; |
| 2337 | } |
| 2338 | } |
| 2339 | |
| 2340 | /* Are there any inputs that were present on all txs? */ |
| 2341 | if (memeqzero(inputs_present, tal_bytelen(inputs_present))) { |
| 2342 | char *errmsg; |
| 2343 | |
| 2344 | inflight = list_tail(&channel->inflights, |
| 2345 | struct channel_inflight, |
| 2346 | list); |
| 2347 | assert(inflight); |
| 2348 | |
| 2349 | errmsg = tal_fmt(tmpctx, "No overlapping input" |
| 2350 | " present. New: %s, last: %s", |
| 2351 | fmt_wally_psbt(tmpctx, |
| 2352 | candidate_psbt), |
| 2353 | fmt_wally_psbt(tmpctx, |
| 2354 | inflight->funding_psbt)); |
no test coverage detected