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. */
| 594 | * a slow feerate for min, and a normal one for all others. |
| 595 | */ |
| 596 | static struct command_result *estimatefees(struct command *cmd, |
| 597 | const char *buf UNUSED, |
| 598 | const jsmntok_t *toks UNUSED) |
| 599 | { |
| 600 | struct command_result *err; |
| 601 | u64 perkb_floor = 0; |
| 602 | u64 perkb[ARRAY_SIZE(estimatefee_params)]; |
| 603 | struct json_stream *response; |
| 604 | |
| 605 | if (!param(cmd, buf, toks, NULL)) |
| 606 | return command_param_failed(); |
| 607 | |
| 608 | err = get_feerate_floor(cmd, &perkb_floor); |
| 609 | if (err) |
| 610 | return err; |
| 611 | |
| 612 | for (size_t i = 0; i < ARRAY_SIZE(estimatefee_params); i++) { |
| 613 | err = get_feerate(cmd, estimatefee_params[i].blocks, |
| 614 | estimatefee_params[i].style, &perkb[i]); |
| 615 | if (err) |
| 616 | return err; |
| 617 | } |
| 618 | |
| 619 | response = jsonrpc_stream_success(cmd); |
| 620 | json_array_start(response, "feerates"); |
| 621 | for (size_t i = 0; i < ARRAY_SIZE(perkb); i++) { |
| 622 | if (!perkb[i]) |
| 623 | continue; |
| 624 | json_object_start(response, NULL); |
| 625 | json_add_u32(response, "blocks", estimatefee_params[i].blocks); |
| 626 | json_add_feerate(response, "feerate", cmd, perkb_floor, perkb[i]); |
| 627 | json_object_end(response); |
| 628 | } |
| 629 | json_array_end(response); |
| 630 | json_add_u64(response, "feerate_floor", perkb_floor); |
| 631 | return command_finished(cmd, response); |
| 632 | } |
| 633 | |
| 634 | /* Send a transaction to the Bitcoin network. |
| 635 | * Calls `sendrawtransaction` using the first parameter as the raw tx. |
nothing calls this directly
no test coverage detected