| 38 | } |
| 39 | |
| 40 | static const char *init(struct command *init_cmd, |
| 41 | const char *buf UNUSED, const jsmntok_t *config UNUSED) |
| 42 | { |
| 43 | struct plugin *p = init_cmd->plugin; |
| 44 | size_t num_channel_updates_rejected = 0; |
| 45 | |
| 46 | tal_steal(p, pay_plugin); |
| 47 | pay_plugin->plugin = p; |
| 48 | pay_plugin->last_time = 0; |
| 49 | |
| 50 | rpc_scan(init_cmd, "getinfo", take(json_out_obj(NULL, NULL, NULL)), |
| 51 | "{id:%}", JSON_SCAN(json_to_node_id, &pay_plugin->my_id)); |
| 52 | |
| 53 | /* BOLT #4: |
| 54 | * ## `max_htlc_cltv` Selection |
| 55 | * |
| 56 | * This ... value is defined as 2016 blocks, based on historical value |
| 57 | * deployed by Lightning implementations. |
| 58 | */ |
| 59 | /* FIXME: Typo in spec for CLTV in descripton! But it breaks our spelling check, so we omit it above */ |
| 60 | pay_plugin->maxdelay_default = 2016; |
| 61 | pay_plugin->payment_map = tal(pay_plugin, struct payment_map); |
| 62 | payment_map_init(pay_plugin->payment_map); |
| 63 | |
| 64 | pay_plugin->pending_routes = tal(pay_plugin, struct route_map); |
| 65 | route_map_init(pay_plugin->pending_routes); |
| 66 | |
| 67 | pay_plugin->gossmap = gossmap_load(pay_plugin, |
| 68 | GOSSIP_STORE_FILENAME, |
| 69 | plugin_gossmap_logcb, |
| 70 | p); |
| 71 | |
| 72 | if (!pay_plugin->gossmap) |
| 73 | plugin_err(p, "Could not load gossmap %s: %s", |
| 74 | GOSSIP_STORE_FILENAME, strerror(errno)); |
| 75 | if (num_channel_updates_rejected) |
| 76 | plugin_log(p, LOG_DBG, |
| 77 | "gossmap ignored %zu channel updates", |
| 78 | num_channel_updates_rejected); |
| 79 | pay_plugin->uncertainty = uncertainty_new(pay_plugin); |
| 80 | int skipped_count = |
| 81 | uncertainty_update(pay_plugin->uncertainty, pay_plugin->gossmap); |
| 82 | if (skipped_count) |
| 83 | plugin_log(pay_plugin->plugin, LOG_UNUSUAL, |
| 84 | "%s: uncertainty was updated but %d channels have " |
| 85 | "been ignored.", |
| 86 | __func__, skipped_count); |
| 87 | |
| 88 | plugin_set_memleak_handler(p, memleak_mark); |
| 89 | return NULL; |
| 90 | } |
| 91 | |
| 92 | static struct command_result *json_renepaystatus(struct command *cmd, |
| 93 | const char *buf, |
no test coverage detected