| 436 | } |
| 437 | |
| 438 | static void adjust_feerange(struct feerange *feerange, |
| 439 | struct amount_sat offer, enum side side) |
| 440 | { |
| 441 | bool ok; |
| 442 | |
| 443 | /* FIXME: BOLT 2 previously said that we have to set it to less than |
| 444 | * the final commit fee: we do this for now, still: |
| 445 | * |
| 446 | * - MUST propose a value "strictly between" the received |
| 447 | * `fee_satoshis` and its previously-sent `fee_satoshis`. |
| 448 | */ |
| 449 | if (side == feerange->higher_side) |
| 450 | ok = amount_sat_sub(&feerange->max, offer, AMOUNT_SAT(1)); |
| 451 | else |
| 452 | ok = amount_sat_add(&feerange->min, offer, AMOUNT_SAT(1)); |
| 453 | |
| 454 | status_debug("Feerange %s update %s: now %s-%s", |
| 455 | side == LOCAL ? "local" : "remote", |
| 456 | fmt_amount_sat(tmpctx, offer), |
| 457 | fmt_amount_sat(tmpctx, feerange->min), |
| 458 | fmt_amount_sat(tmpctx, feerange->max)); |
| 459 | |
| 460 | if (!ok) |
| 461 | status_failed(STATUS_FAIL_INTERNAL_ERROR, |
| 462 | "Overflow in updating fee range"); |
| 463 | } |
| 464 | |
| 465 | /* Do these two ranges overlap? If so, return that range. */ |
| 466 | static bool get_overlap(const struct tlv_closing_signed_tlvs_fee_range *r1, |
no test coverage detected