This can set **feerate to 0, if it's unknown. */
| 47 | |
| 48 | /* This can set **feerate to 0, if it's unknown. */ |
| 49 | static struct command_result *param_feerate_unchecked(struct command *cmd, |
| 50 | const char *name, |
| 51 | const char *buffer, |
| 52 | const jsmntok_t *tok, |
| 53 | u32 **feerate) |
| 54 | { |
| 55 | *feerate = tal(cmd, u32); |
| 56 | |
| 57 | if (json_tok_streq(buffer, tok, "opening")) { |
| 58 | **feerate = opening_feerate(cmd->ld->topology); |
| 59 | return NULL; |
| 60 | } |
| 61 | if (json_tok_streq(buffer, tok, "mutual_close")) { |
| 62 | **feerate = mutual_close_feerate(cmd->ld->topology); |
| 63 | return NULL; |
| 64 | } |
| 65 | if (json_tok_streq(buffer, tok, "penalty")) { |
| 66 | **feerate = penalty_feerate(cmd->ld->topology); |
| 67 | return NULL; |
| 68 | } |
| 69 | if (json_tok_streq(buffer, tok, "unilateral_close")) { |
| 70 | **feerate = unilateral_feerate(cmd->ld->topology, false); |
| 71 | return NULL; |
| 72 | } |
| 73 | if (json_tok_streq(buffer, tok, "unilateral_anchor_close")) { |
| 74 | **feerate = unilateral_feerate(cmd->ld->topology, true); |
| 75 | return NULL; |
| 76 | } |
| 77 | |
| 78 | /* We used SLOW, NORMAL, and URGENT as feerate targets previously, |
| 79 | * and many commands rely on this syntax now. |
| 80 | * It's also really more natural for an user interface. */ |
| 81 | if (json_tok_streq(buffer, tok, "slow")) { |
| 82 | **feerate = feerate_for_deadline(cmd->ld->topology, 100); |
| 83 | return NULL; |
| 84 | } else if (json_tok_streq(buffer, tok, "normal")) { |
| 85 | **feerate = feerate_for_deadline(cmd->ld->topology, 12); |
| 86 | return NULL; |
| 87 | } else if (json_tok_streq(buffer, tok, "urgent")) { |
| 88 | **feerate = feerate_for_deadline(cmd->ld->topology, 6); |
| 89 | return NULL; |
| 90 | } else if (json_tok_streq(buffer, tok, "minimum")) { |
| 91 | **feerate = get_feerate_floor(cmd->ld->topology); |
| 92 | return NULL; |
| 93 | } |
| 94 | |
| 95 | /* Can specify number of blocks as a target */ |
| 96 | if (json_tok_endswith(buffer, tok, "blocks")) { |
| 97 | jsmntok_t base = *tok; |
| 98 | base.end -= strlen("blocks"); |
| 99 | u32 numblocks; |
| 100 | |
| 101 | if (!json_to_number(buffer, &base, &numblocks)) { |
| 102 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 103 | "'%s' should be an integer not '%.*s'", |
| 104 | name, base.end - base.start, |
| 105 | buffer + base.start); |
| 106 | } |
no test coverage detected