Get the current feerates. We use an urgent feerate for unilateral_close and max, * a slightly less urgent feerate for htlc_resolution and penalty transactions, * a slow feerate for min, and a normal one for all others. */
| 601 | * a slow feerate for min, and a normal one for all others. |
| 602 | */ |
| 603 | static struct command_result *estimatefees(struct command *cmd, |
| 604 | const char *buf UNUSED, |
| 605 | const jsmntok_t *toks UNUSED) |
| 606 | { |
| 607 | struct command_result *err; |
| 608 | u64 perkb_floor = 0; |
| 609 | u64 perkb[ARRAY_SIZE(estimatefee_params)]; |
| 610 | struct json_stream *response; |
| 611 | |
| 612 | if (!param(cmd, buf, toks, NULL)) |
| 613 | return command_param_failed(); |
| 614 | |
| 615 | err = get_feerate_floor(cmd, &perkb_floor); |
| 616 | if (err) |
| 617 | return err; |
| 618 | |
| 619 | for (size_t i = 0; i < ARRAY_SIZE(estimatefee_params); i++) { |
| 620 | err = get_feerate(cmd, estimatefee_params[i].blocks, |
| 621 | estimatefee_params[i].style, &perkb[i]); |
| 622 | if (err) |
| 623 | return err; |
| 624 | } |
| 625 | |
| 626 | response = jsonrpc_stream_success(cmd); |
| 627 | json_array_start(response, "feerates"); |
| 628 | for (size_t i = 0; i < ARRAY_SIZE(perkb); i++) { |
| 629 | if (!perkb[i]) |
| 630 | continue; |
| 631 | json_object_start(response, NULL); |
| 632 | json_add_u32(response, "blocks", estimatefee_params[i].blocks); |
| 633 | json_add_feerate(response, "feerate", cmd, perkb_floor, perkb[i]); |
| 634 | json_object_end(response); |
| 635 | } |
| 636 | json_array_end(response); |
| 637 | json_add_u64(response, "feerate_floor", perkb_floor); |
| 638 | return command_finished(cmd, response); |
| 639 | } |
| 640 | |
| 641 | /* Send a transaction to the Bitcoin network. |
| 642 | * Calls `sendrawtransaction` using the first parameter as the raw tx. |
nothing calls this directly
no test coverage detected