33#[ macro_use]
44extern crate serde_json;
55use cln_plugin:: options:: {
6- self , BooleanConfigOption , DefaultIntegerConfigOption , IntegerConfigOption ,
6+ self , BooleanConfigOption , DefaultIntegerArrayConfigOption , DefaultIntegerConfigOption ,
7+ DefaultStringArrayConfigOption , IntegerArrayConfigOption , IntegerConfigOption ,
8+ StringArrayConfigOption ,
79} ;
810use cln_plugin:: { messages, Builder , Error , Plugin } ;
9- use tokio;
1011
1112const TEST_NOTIF_TAG : & str = "test_custom_notification" ;
1213
@@ -19,6 +20,32 @@ const TEST_OPTION: DefaultIntegerConfigOption = DefaultIntegerConfigOption::new_
1920const TEST_OPTION_NO_DEFAULT : IntegerConfigOption =
2021 IntegerConfigOption :: new_i64_no_default ( "opt-option" , "An option without a default" ) ;
2122
23+ const TEST_MULTI_STR_OPTION : StringArrayConfigOption =
24+ StringArrayConfigOption :: new_str_arr_no_default (
25+ "multi-str-option" ,
26+ "An option that can have multiple string values" ,
27+ ) ;
28+
29+ const TEST_MULTI_STR_OPTION_DEFAULT : DefaultStringArrayConfigOption =
30+ DefaultStringArrayConfigOption :: new_str_arr_with_default (
31+ "multi-str-option-default" ,
32+ "Default1" ,
33+ "An option that can have multiple string values with defaults" ,
34+ ) ;
35+
36+ const TEST_MULTI_I64_OPTION : IntegerArrayConfigOption =
37+ IntegerArrayConfigOption :: new_i64_arr_no_default (
38+ "multi-i64-option" ,
39+ "An option that can have multiple i64 values" ,
40+ ) ;
41+
42+ const TEST_MULTI_I64_OPTION_DEFAULT : DefaultIntegerArrayConfigOption =
43+ DefaultIntegerArrayConfigOption :: new_i64_arr_with_default (
44+ "multi-i64-option-default" ,
45+ -42 ,
46+ "An option that can have multiple i64 values with defaults" ,
47+ ) ;
48+
2249#[ tokio:: main]
2350async fn main ( ) -> Result < ( ) , anyhow:: Error > {
2451 let state = ( ) ;
@@ -33,6 +60,10 @@ async fn main() -> Result<(), anyhow::Error> {
3360 . option ( TEST_OPTION )
3461 . option ( TEST_OPTION_NO_DEFAULT )
3562 . option ( test_dynamic_option)
63+ . option ( TEST_MULTI_STR_OPTION )
64+ . option ( TEST_MULTI_STR_OPTION_DEFAULT )
65+ . option ( TEST_MULTI_I64_OPTION )
66+ . option ( TEST_MULTI_I64_OPTION_DEFAULT )
3667 . setconfig_callback ( setconfig_callback)
3768 . rpcmethod ( "testmethod" , "This is a test" , testmethod)
3869 . rpcmethod (
@@ -79,10 +110,18 @@ async fn setconfig_callback(
79110async fn testoptions ( p : Plugin < ( ) > , _v : serde_json:: Value ) -> Result < serde_json:: Value , Error > {
80111 let test_option = p. option ( & TEST_OPTION ) ?;
81112 let test_option_no_default = p. option ( & TEST_OPTION_NO_DEFAULT ) ?;
113+ let test_multi_str_option = p. option ( & TEST_MULTI_STR_OPTION ) ?;
114+ let test_multi_str_option_default = p. option ( & TEST_MULTI_STR_OPTION_DEFAULT ) ?;
115+ let test_multi_i64_option = p. option ( & TEST_MULTI_I64_OPTION ) ?;
116+ let test_multi_i64_option_default = p. option ( & TEST_MULTI_I64_OPTION_DEFAULT ) ?;
82117
83118 Ok ( json ! ( {
84119 "test-option" : test_option,
85- "opt-option" : test_option_no_default
120+ "opt-option" : test_option_no_default,
121+ "multi-str-option" : test_multi_str_option,
122+ "multi-str-option-default" : test_multi_str_option_default,
123+ "multi-i64-option" : test_multi_i64_option,
124+ "multi-i64-option-default" : test_multi_i64_option_default,
86125 } ) )
87126}
88127
0 commit comments