mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 10:39:49 +01:00
74d13bb334
In the old version requesting the config-value of an option was a little bit tricky. Let's say we want to have a plugin which uses a default port of 1234. ```rust let value = plugin.option("plugin-port"); match value { Some(Value::Integer(_)) => {}, Some(Value::String(_)) => {}, // Can never happen Some(Value::Boolean(_)) => {}, // Can never happen None => {}, // Can never happen } ``` Many users of the `cln_plugin` crate are overly cautious and handle all these error scenario's. Which is completely unneeded. Core Lightning will complain if you put a `String` where an `Integer` is expected and will never send the value to the plug-in. This change makes the API much more ergonomical and actually motivates some of the changes in previous commits. ``` const MY_OPTION : ConfigOption<i64> = ConfigOption::new_i64_with_default( "plugin-port', 1235, "Description"); let value : Result<i64> = plugin.option(MY_OPTION); ``` The result will provide a proper error-message. It is also safe to `unwrap` the result because it will only be triggered if the user neglected to provide the option to the `Builder`. |
||
---|---|---|
.. | ||
bkpr | ||
clnrest | ||
examples | ||
grpc-plugin | ||
renepay | ||
spender | ||
src | ||
test | ||
.gitignore | ||
autoclean.c | ||
bcli.c | ||
Cargo.toml | ||
chanbackup.c | ||
commando.c | ||
fetchinvoice.c | ||
funder_policy.c | ||
funder_policy.h | ||
funder.c | ||
keysend.c | ||
libplugin-pay.c | ||
libplugin-pay.h | ||
libplugin.c | ||
libplugin.h | ||
Makefile | ||
offers_inv_hook.c | ||
offers_inv_hook.h | ||
offers_invreq_hook.c | ||
offers_invreq_hook.h | ||
offers_offer.c | ||
offers_offer.h | ||
offers.c | ||
offers.h | ||
pay.c | ||
README.md | ||
sql.c | ||
topology.c | ||
txprepare.c |
Plugin Directory
Any file in this directory which is executable and whose name only consists of alphanumeric characters, space, '.', '-' or '_' will be automatically loaded when lightningd starts (unless suppressed with commandline options).