diff --git a/Cargo.lock b/Cargo.lock index ac0a114dd..5e49e08d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -369,6 +369,12 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bech32" +version = "0.10.0-beta" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" + [[package]] name = "bip39" version = "2.0.0" @@ -393,7 +399,7 @@ version = "0.29.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0694ea59225b0c5f3cb405ff3f670e4828358ed26aec49dc352f730f0cb1a8a3" dependencies = [ - "bech32", + "bech32 0.9.1", "bitcoin_hashes 0.11.0", "bitcoinconsensus", "secp256k1 0.24.3", @@ -402,15 +408,16 @@ dependencies = [ [[package]] name = "bitcoin" -version = "0.30.2" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1945a5048598e4189e239d3f809b19bdad4845c4b2ba400d304d2dcf26d2c462" +checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae" dependencies = [ - "bech32", - "bitcoin-private", - "bitcoin_hashes 0.12.0", + "bech32 0.10.0-beta", + "bitcoin-internals", + "bitcoin_hashes 0.13.0", + "hex-conservative", "hex_lit", - "secp256k1 0.27.0", + "secp256k1 0.28.2", "serde", ] @@ -425,6 +432,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "bitcoin-internals" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" +dependencies = [ + "serde", +] + [[package]] name = "bitcoin-private" version = "0.1.0" @@ -457,6 +473,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d7066118b13d4b20b23645932dfb3a81ce7e29f95726c2036fa33cd7b092501" dependencies = [ "bitcoin-private", +] + +[[package]] +name = "bitcoin_hashes" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" +dependencies = [ + "bitcoin-internals", + "hex-conservative", "serde", ] @@ -687,19 +713,23 @@ dependencies = [ [[package]] name = "cln-grpc" -version = "0.1.8" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b7b9e8de980dba797a0885b99fda797638d8a207089cb98710d94285e871df" +checksum = "1f3a50be955808d07d6f33f05bb11ce5a3875d92b4d1fff5623f9458feb5164c" dependencies = [ "anyhow", - "bitcoin 0.30.2", + "bitcoin 0.31.2", "cln-rpc", + "futures-core", "hex", "log", - "prost 0.11.9", + "prost 0.12.6", "serde", - "tonic 0.8.3", - "tonic-build 0.8.4", + "tokio 1.43.0", + "tokio-stream", + "tokio-util 0.7.11", + "tonic 0.11.0", + "tonic-build 0.11.0", ] [[package]] @@ -723,12 +753,12 @@ dependencies = [ [[package]] name = "cln-rpc" -version = "0.1.8" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2653217d27aee65a670f0c4f340b8f70b1f0b4e1c2fa085afe1b8e24ba12c069" +checksum = "f4436e58f1fccb1faf69df9ac436ae9304b5c200c7d92e6c4229826bdd0a8d0d" dependencies = [ "anyhow", - "bitcoin 0.30.2", + "bitcoin 0.31.2", "bytes 1.6.0", "futures-util", "hex", @@ -1329,7 +1359,7 @@ dependencies = [ "async-stream 0.3.5", "async-trait", "base64 0.21.7", - "bech32", + "bech32 0.9.1", "bytes 1.6.0", "chacha20poly1305", "chrono", @@ -1344,14 +1374,14 @@ dependencies = [ "picky-asn1-der 0.4.1", "picky-asn1-x509 0.12.0", "pin-project 1.1.5", - "prost 0.11.9", - "prost-derive 0.11.9", + "prost 0.12.6", + "prost-derive 0.12.6", "rand 0.8.5", "rcgen", "reqwest", "ring 0.16.20", "runeauth", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "secp256k1 0.26.0", "serde", "serde_json", @@ -1361,8 +1391,8 @@ dependencies = [ "time", "tokio 1.43.0", "tokio-stream", - "tonic 0.8.3", - "tonic-build 0.8.4", + "tonic 0.11.0", + "tonic-build 0.11.0", "tower 0.4.13", "url", "uuid", @@ -1384,13 +1414,13 @@ dependencies = [ "hex", "log", "once_cell", - "prost 0.11.9", + "prost 0.12.6", "pyo3", "runeauth", "serde_json", "thiserror 1.0.61", "tokio 1.43.0", - "tonic 0.8.3", + "tonic 0.11.0", ] [[package]] @@ -1428,7 +1458,7 @@ dependencies = [ "linemux", "log", "nix", - "prost 0.11.9", + "prost 0.12.6", "serde", "serde_json", "sled", @@ -1436,8 +1466,8 @@ dependencies = [ "tokio 1.43.0", "tokio-stream", "tokio-util 0.7.11", - "tonic 0.8.3", - "tonic-build 0.8.4", + "tonic 0.11.0", + "tonic-build 0.11.0", "tower 0.4.13", "vls-protocol", ] @@ -1544,12 +1574,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -1577,6 +1601,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-conservative" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" + [[package]] name = "hex_lit" version = "0.1.1" @@ -1992,7 +2022,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3eb24878b0f4ef75f020976c886d9ad1503867802329cc963e0ab4623ea3b25c" dependencies = [ - "bech32", + "bech32 0.9.1", "bitcoin 0.29.2", "bitcoin_hashes 0.11.0", "lightning", @@ -2738,12 +2768,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.1.25" +version = "0.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" dependencies = [ "proc-macro2", - "syn 1.0.109", + "syn 2.0.96", ] [[package]] @@ -2767,12 +2797,12 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.9" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes 1.6.0", - "prost-derive 0.11.9", + "prost-derive 0.12.6", ] [[package]] @@ -2795,24 +2825,23 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.11.9" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes 1.6.0", - "heck 0.4.1", + "heck 0.5.0", "itertools 0.10.5", - "lazy_static", "log", "multimap", + "once_cell", "petgraph 0.6.5", "prettyplease", - "prost 0.11.9", - "prost-types 0.11.9", + "prost 0.12.6", + "prost-types 0.12.6", "regex", - "syn 1.0.109", + "syn 2.0.96", "tempfile", - "which 4.4.2", ] [[package]] @@ -2830,15 +2859,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.9" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", "itertools 0.10.5", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.96", ] [[package]] @@ -2853,11 +2882,11 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.11.9" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost 0.11.9", + "prost 0.12.6", ] [[package]] @@ -3137,7 +3166,7 @@ dependencies = [ "pin-project-lite 0.2.14", "rustls 0.21.12", "rustls-native-certs", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", @@ -3257,31 +3286,33 @@ dependencies = [ "log", "ring 0.16.20", "sct 0.6.1", - "webpki 0.21.4", + "webpki", ] [[package]] name = "rustls" -version = "0.20.9" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", - "ring 0.16.20", + "ring 0.17.8", + "rustls-webpki 0.101.7", "sct 0.7.1", - "webpki 0.22.4", ] [[package]] name = "rustls" -version = "0.21.12" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", "ring 0.17.8", - "rustls-webpki", - "sct 0.7.1", + "rustls-pki-types", + "rustls-webpki 0.102.8", + "subtle", + "zeroize", ] [[package]] @@ -3291,7 +3322,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "schannel", "security-framework", ] @@ -3305,6 +3336,21 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -3315,6 +3361,17 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "ring 0.17.8", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.17" @@ -3394,12 +3451,12 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.27.0" +version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ "bitcoin_hashes 0.12.0", - "secp256k1-sys 0.8.1", + "secp256k1-sys 0.9.2", "serde", ] @@ -3421,6 +3478,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" +dependencies = [ + "cc", +] + [[package]] name = "security-framework" version = "2.11.0" @@ -3996,27 +4062,27 @@ dependencies = [ "futures-core", "rustls 0.18.1", "tokio 0.2.25", - "webpki 0.21.4", + "webpki", ] [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.20.9", + "rustls 0.21.12", "tokio 1.43.0", - "webpki 0.22.4", ] [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.21.12", + "rustls 0.22.4", + "rustls-pki-types", "tokio 1.43.0", ] @@ -4029,6 +4095,7 @@ dependencies = [ "futures-core", "pin-project-lite 0.2.14", "tokio 1.43.0", + "tokio-util 0.7.11", ] [[package]] @@ -4091,17 +4158,15 @@ dependencies = [ [[package]] name = "tonic" -version = "0.8.3" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" dependencies = [ "async-stream 0.3.5", "async-trait", "axum", - "base64 0.13.1", + "base64 0.21.7", "bytes 1.6.0", - "futures-core", - "futures-util", "h2 0.3.26", "http", "http-body 0.4.6", @@ -4109,18 +4174,16 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project 1.1.5", - "prost 0.11.9", - "prost-derive 0.11.9", - "rustls-pemfile", + "prost 0.12.6", + "rustls-pemfile 2.2.0", + "rustls-pki-types", "tokio 1.43.0", - "tokio-rustls 0.23.4", + "tokio-rustls 0.25.0", "tokio-stream", - "tokio-util 0.7.11", "tower 0.4.13", "tower-layer", "tower-service", "tracing", - "tracing-futures", ] [[package]] @@ -4137,15 +4200,15 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.8.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4" +checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" dependencies = [ "prettyplease", "proc-macro2", - "prost-build 0.11.9", + "prost-build 0.12.6", "quote", - "syn 1.0.109", + "syn 2.0.96", ] [[package]] @@ -4740,16 +4803,6 @@ dependencies = [ "untrusted 0.7.1", ] -[[package]] -name = "webpki" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" -dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", -] - [[package]] name = "which" version = "3.1.1" diff --git a/Cargo.toml b/Cargo.toml index c79ba1246..b92e6411a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,21 +11,21 @@ lto = "thin" [workspace] resolver = "2" -members = [ - "examples/rust", - "libs/gl-client", - "libs/gl-client-py", - "libs/gl-plugin", - "libs/gl-signerproxy", - "libs/gl-cli", +members = [ + "examples/rust", + "libs/gl-client", + "libs/gl-client-py", + "libs/gl-plugin", + "libs/gl-signerproxy", + "libs/gl-cli", ] [workspace.dependencies] anyhow = "1" env_logger = "0.10" -cln-grpc = "=0.1.8" -cln-rpc = "0.1.8" -cln-plugin = "0.1.8" +cln-grpc = "0.4" +cln-rpc = "0.4" +cln-plugin = "0.4" vls-core = "^0.12" vls-persist = "^0.12" @@ -43,9 +43,9 @@ ci = ["github"] installers = [] # Target platforms to build apps for (Rust target-triple syntax) targets = [ - "x86_64-unknown-linux-gnu", - "aarch64-apple-darwin", - "x86_64-apple-darwin", + "x86_64-unknown-linux-gnu", + "aarch64-apple-darwin", + "x86_64-apple-darwin", ] # Publish jobs to run in CI pr-run-mode = "upload" diff --git a/libs/gl-cli/src/node.rs b/libs/gl-cli/src/node.rs index c7075585a..25c154f14 100644 --- a/libs/gl-cli/src/node.rs +++ b/libs/gl-cli/src/node.rs @@ -316,6 +316,7 @@ async fn invoice_handler>( let mut node: gl_client::node::ClnClient = scheduler.node().await.map_err(Error::custom)?; let res = node .invoice(cln::InvoiceRequest { + exposeprivatechannels: vec![], amount_msat: amount_msat.map(|v| v.into()), description, label, @@ -387,6 +388,9 @@ async fn listpays_handler>( let mut node: gl_client::node::ClnClient = scheduler.node().await.map_err(Error::custom)?; let res = node .list_pays(cln::ListpaysRequest { + index: None, + start: None, + limit: None, bolt11, payment_hash, status, @@ -443,6 +447,7 @@ async fn pay_handler>( exclude: exclude.unwrap_or_default(), maxfee: maxfee.map(|msat| cln::Amount { msat }), description, + partial_msat: None, }) .await .map_err(|e| Error::custom(e.message()))? diff --git a/libs/gl-client-py/Cargo.toml b/libs/gl-client-py/Cargo.toml index 8315cd91c..38d94e1ba 100644 --- a/libs/gl-client-py/Cargo.toml +++ b/libs/gl-client-py/Cargo.toml @@ -2,10 +2,7 @@ name = "gl-client-py" version = "0.3.0" edition = "2018" -authors = [ - "Christian Decker", - "The Greenlight Team" -] +authors = ["Christian Decker", "The Greenlight Team"] description = "Python bindings for the Greenlight client library." repository = "https://github.com/Blockstream/greenlight" license = "MIT" @@ -18,15 +15,21 @@ crate-type = ["cdylib"] anyhow = { workspace = true } bytes = "1.6" env_logger = { workspace = true } -gl-client = { path = "../gl-client", default-features = false, features = [ "export" ] } +gl-client = { path = "../gl-client", default-features = false, features = [ + "export", +] } hex = "*" log = "*" once_cell = "*" -prost = "0.11" -pyo3 = {version = "0.18", features = ["extension-module", "serde", "abi3-py37"]} +prost = "0.12" +pyo3 = { version = "0.18", features = [ + "extension-module", + "serde", + "abi3-py37", +] } runeauth = "0.1" tokio = { version = "1", features = ["full"] } -tonic = { version = "^0.8", features = ["tls", "transport"] } +tonic = { version = "0.11", features = ["tls", "transport"] } serde_json = "^1.0" thiserror = "1" diff --git a/libs/gl-client/Cargo.toml b/libs/gl-client/Cargo.toml index d1d923ffd..61189f80f 100644 --- a/libs/gl-client/Cargo.toml +++ b/libs/gl-client/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "gl-client" version = "0.3.0" -edition = "2018" +edition = "2021" authors = ["Christian Decker", "The Greenlight Team"] description = "Client library for Greenlight, and basis for language bindings." repository = "https://github.com/Blockstream/greenlight" @@ -27,11 +27,11 @@ picky = "6.3" picky-asn1-x509 = "0.12" picky-asn1-der = "0.4" pin-project = "1.1.5" -prost = "0.11" -prost-derive = "0.11" +prost = "0.12" +prost-derive = "0.12" reqwest = { version = "^0.11", features = [ - "json", - "rustls-tls-native-roots", + "json", + "rustls-tls-native-roots", ], default-features = false } ring = "~0.16.20" runeauth = "0.1" @@ -39,7 +39,7 @@ rustls-pemfile = "1.0.4" sha256 = "1.5.0" tokio = { version = "1", features = ["full"] } tokio-stream = "0.1" -tonic = { version = "^0.8", features = ["tls", "transport"] } +tonic = { version = "0.11", features = ["tls", "transport"] } tower = { version = "0.4" } tempfile = "3.10.1" url = "2.5.0" @@ -63,5 +63,5 @@ time = { version = "0.3", features = ["macros"] } x509-certificate = "0.23.1" [build-dependencies] -tonic-build = "^0.8" +tonic-build = "0.11" serde = { version = "1", features = ["derive"] } diff --git a/libs/gl-client/rustfmt.toml b/libs/gl-client/rustfmt.toml deleted file mode 100644 index 5f22f2e64..000000000 --- a/libs/gl-client/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -edition="2021" \ No newline at end of file diff --git a/libs/gl-client/src/signer/model/cln.rs b/libs/gl-client/src/signer/model/cln.rs index 16af20a0e..b88d19712 100644 --- a/libs/gl-client/src/signer/model/cln.rs +++ b/libs/gl-client/src/signer/model/cln.rs @@ -3,64 +3,70 @@ // Do not edit this file. // +use super::Request; +pub use crate::pb::cln::*; use anyhow::anyhow; use prost::Message; -pub use crate::pb::cln::*; -use super::Request; pub fn decode_request(uri: &str, p: &[u8]) -> anyhow::Result { Ok(match uri { - "/cln.Node/Getinfo" => Request::Getinfo(GetinfoRequest::decode(p)?), - "/cln.Node/ListPeers" => Request::ListPeers(ListpeersRequest::decode(p)?), - "/cln.Node/ListFunds" => Request::ListFunds(ListfundsRequest::decode(p)?), - "/cln.Node/SendPay" => Request::SendPay(SendpayRequest::decode(p)?), - "/cln.Node/ListChannels" => Request::ListChannels(ListchannelsRequest::decode(p)?), - "/cln.Node/AddGossip" => Request::AddGossip(AddgossipRequest::decode(p)?), - "/cln.Node/AutoCleanInvoice" => Request::AutoCleanInvoice(AutocleaninvoiceRequest::decode(p)?), - "/cln.Node/CheckMessage" => Request::CheckMessage(CheckmessageRequest::decode(p)?), - "/cln.Node/Close" => Request::Close(CloseRequest::decode(p)?), - "/cln.Node/ConnectPeer" => Request::Connect(ConnectRequest::decode(p)?), - "/cln.Node/CreateInvoice" => Request::CreateInvoice(CreateinvoiceRequest::decode(p)?), - "/cln.Node/Datastore" => Request::Datastore(DatastoreRequest::decode(p)?), - "/cln.Node/CreateOnion" => Request::CreateOnion(CreateonionRequest::decode(p)?), - "/cln.Node/DelDatastore" => Request::DelDatastore(DeldatastoreRequest::decode(p)?), - "/cln.Node/DelExpiredInvoice" => Request::DelExpiredInvoice(DelinvoiceRequest::decode(p)?), - "/cln.Node/DelInvoice" => Request::DelInvoice(DelinvoiceRequest::decode(p)?), - "/cln.Node/Invoice" => Request::Invoice(InvoiceRequest::decode(p)?), - "/cln.Node/ListDatastore" => Request::ListDatastore(ListdatastoreRequest::decode(p)?), - "/cln.Node/ListInvoices" => Request::ListInvoices(ListinvoicesRequest::decode(p)?), - "/cln.Node/SendOnion" => Request::SendOnion(SendonionRequest::decode(p)?), - "/cln.Node/ListSendPays" => Request::ListSendPays(ListsendpaysRequest::decode(p)?), - "/cln.Node/ListTransactions" => Request::ListTransactions(ListtransactionsRequest::decode(p)?), - "/cln.Node/Pay" => Request::Pay(PayRequest::decode(p)?), - "/cln.Node/ListNodes" => Request::ListNodes(ListnodesRequest::decode(p)?), - "/cln.Node/WaitAnyInvoice" => Request::WaitAnyInvoice(WaitanyinvoiceRequest::decode(p)?), - "/cln.Node/WaitInvoice" => Request::WaitInvoice(WaitinvoiceRequest::decode(p)?), - "/cln.Node/WaitSendPay" => Request::WaitSendPay(WaitsendpayRequest::decode(p)?), - "/cln.Node/NewAddr" => Request::NewAddr(NewaddrRequest::decode(p)?), - "/cln.Node/Withdraw" => Request::Withdraw(WithdrawRequest::decode(p)?), - "/cln.Node/KeySend" => Request::KeySend(KeysendRequest::decode(p)?), - "/cln.Node/FundPsbt" => Request::FundPsbt(FundpsbtRequest::decode(p)?), - "/cln.Node/SendPsbt" => Request::SendPsbt(SendpsbtRequest::decode(p)?), - "/cln.Node/SignPsbt" => Request::SignPsbt(SignpsbtRequest::decode(p)?), - "/cln.Node/UtxoPsbt" => Request::UtxoPsbt(UtxopsbtRequest::decode(p)?), - "/cln.Node/TxDiscard" => Request::TxDiscard(TxdiscardRequest::decode(p)?), - "/cln.Node/TxPrepare" => Request::TxPrepare(TxprepareRequest::decode(p)?), - "/cln.Node/TxSend" => Request::TxSend(TxsendRequest::decode(p)?), - "/cln.Node/Disconnect" => Request::Disconnect(DisconnectRequest::decode(p)?), - "/cln.Node/Feerates" => Request::Feerates(FeeratesRequest::decode(p)?), - "/cln.Node/FundChannel" => Request::FundChannel(FundchannelRequest::decode(p)?), - "/cln.Node/GetRoute" => Request::GetRoute(GetrouteRequest::decode(p)?), - "/cln.Node/ListForwards" => Request::ListForwards(ListforwardsRequest::decode(p)?), - "/cln.Node/ListPays" => Request::ListPays(ListpaysRequest::decode(p)?), - "/cln.Node/Ping" => Request::Ping(PingRequest::decode(p)?), - "/cln.Node/SetChannel" => Request::SetChannel(SetchannelRequest::decode(p)?), - "/cln.Node/SignMessage" => Request::SignMessage(SignmessageRequest::decode(p)?), - "/cln.Node/FetchInvoice" => Request::FetchInvoice(FetchinvoiceRequest::decode(p)?), - "/cln.Node/Stop" => Request::Stop(StopRequest::decode(p)?), - "/cln.Node/ListClosedChannels" => Request::ListClosedChannels(ListclosedchannelsRequest::decode(p)?), - "/cln.Node/StaticBackup" => Request::StaticBackup(StaticbackupRequest::decode(p)?), - "/cln.Node/PreApproveInvoice" => Request::PreApproveInvoice(PreapproveinvoiceRequest::decode(p)?), + "/cln.Node/Getinfo" => Request::Getinfo(GetinfoRequest::decode(p)?), + "/cln.Node/ListPeers" => Request::ListPeers(ListpeersRequest::decode(p)?), + "/cln.Node/ListFunds" => Request::ListFunds(ListfundsRequest::decode(p)?), + "/cln.Node/SendPay" => Request::SendPay(SendpayRequest::decode(p)?), + "/cln.Node/ListChannels" => Request::ListChannels(ListchannelsRequest::decode(p)?), + "/cln.Node/AddGossip" => Request::AddGossip(AddgossipRequest::decode(p)?), + "/cln.Nonde/AutoCleanOnce" => Request::AutoCleanOnce(AutocleanonceRequest::decode(p)?), + "/cln.Node/CheckMessage" => Request::CheckMessage(CheckmessageRequest::decode(p)?), + "/cln.Node/Close" => Request::Close(CloseRequest::decode(p)?), + "/cln.Node/ConnectPeer" => Request::Connect(ConnectRequest::decode(p)?), + "/cln.Node/CreateInvoice" => Request::CreateInvoice(CreateinvoiceRequest::decode(p)?), + "/cln.Node/Datastore" => Request::Datastore(DatastoreRequest::decode(p)?), + "/cln.Node/CreateOnion" => Request::CreateOnion(CreateonionRequest::decode(p)?), + "/cln.Node/DelDatastore" => Request::DelDatastore(DeldatastoreRequest::decode(p)?), + "/cln.Node/DelExpiredInvoice" => Request::DelExpiredInvoice(DelinvoiceRequest::decode(p)?), + "/cln.Node/DelInvoice" => Request::DelInvoice(DelinvoiceRequest::decode(p)?), + "/cln.Node/Invoice" => Request::Invoice(InvoiceRequest::decode(p)?), + "/cln.Node/ListDatastore" => Request::ListDatastore(ListdatastoreRequest::decode(p)?), + "/cln.Node/ListInvoices" => Request::ListInvoices(ListinvoicesRequest::decode(p)?), + "/cln.Node/SendOnion" => Request::SendOnion(SendonionRequest::decode(p)?), + "/cln.Node/ListSendPays" => Request::ListSendPays(ListsendpaysRequest::decode(p)?), + "/cln.Node/ListTransactions" => { + Request::ListTransactions(ListtransactionsRequest::decode(p)?) + } + "/cln.Node/Pay" => Request::Pay(PayRequest::decode(p)?), + "/cln.Node/ListNodes" => Request::ListNodes(ListnodesRequest::decode(p)?), + "/cln.Node/WaitAnyInvoice" => Request::WaitAnyInvoice(WaitanyinvoiceRequest::decode(p)?), + "/cln.Node/WaitInvoice" => Request::WaitInvoice(WaitinvoiceRequest::decode(p)?), + "/cln.Node/WaitSendPay" => Request::WaitSendPay(WaitsendpayRequest::decode(p)?), + "/cln.Node/NewAddr" => Request::NewAddr(NewaddrRequest::decode(p)?), + "/cln.Node/Withdraw" => Request::Withdraw(WithdrawRequest::decode(p)?), + "/cln.Node/KeySend" => Request::KeySend(KeysendRequest::decode(p)?), + "/cln.Node/FundPsbt" => Request::FundPsbt(FundpsbtRequest::decode(p)?), + "/cln.Node/SendPsbt" => Request::SendPsbt(SendpsbtRequest::decode(p)?), + "/cln.Node/SignPsbt" => Request::SignPsbt(SignpsbtRequest::decode(p)?), + "/cln.Node/UtxoPsbt" => Request::UtxoPsbt(UtxopsbtRequest::decode(p)?), + "/cln.Node/TxDiscard" => Request::TxDiscard(TxdiscardRequest::decode(p)?), + "/cln.Node/TxPrepare" => Request::TxPrepare(TxprepareRequest::decode(p)?), + "/cln.Node/TxSend" => Request::TxSend(TxsendRequest::decode(p)?), + "/cln.Node/Disconnect" => Request::Disconnect(DisconnectRequest::decode(p)?), + "/cln.Node/Feerates" => Request::Feerates(FeeratesRequest::decode(p)?), + "/cln.Node/FundChannel" => Request::FundChannel(FundchannelRequest::decode(p)?), + "/cln.Node/GetRoute" => Request::GetRoute(GetrouteRequest::decode(p)?), + "/cln.Node/ListForwards" => Request::ListForwards(ListforwardsRequest::decode(p)?), + "/cln.Node/ListPays" => Request::ListPays(ListpaysRequest::decode(p)?), + "/cln.Node/Ping" => Request::Ping(PingRequest::decode(p)?), + "/cln.Node/SetChannel" => Request::SetChannel(SetchannelRequest::decode(p)?), + "/cln.Node/SignMessage" => Request::SignMessage(SignmessageRequest::decode(p)?), + "/cln.Node/FetchInvoice" => Request::FetchInvoice(FetchinvoiceRequest::decode(p)?), + "/cln.Node/Stop" => Request::Stop(StopRequest::decode(p)?), + "/cln.Node/ListClosedChannels" => { + Request::ListClosedChannels(ListclosedchannelsRequest::decode(p)?) + } + "/cln.Node/StaticBackup" => Request::StaticBackup(StaticbackupRequest::decode(p)?), + "/cln.Node/PreApproveInvoice" => { + Request::PreApproveInvoice(PreapproveinvoiceRequest::decode(p)?) + } uri => return Err(anyhow!("Unknown URI {}, can't decode payload", uri)), }) } diff --git a/libs/gl-client/src/signer/model/mod.rs b/libs/gl-client/src/signer/model/mod.rs index 1b8fdce6f..9dcffb62e 100644 --- a/libs/gl-client/src/signer/model/mod.rs +++ b/libs/gl-client/src/signer/model/mod.rs @@ -15,7 +15,7 @@ pub enum Request { SendPay(cln::SendpayRequest), ListChannels(cln::ListchannelsRequest), AddGossip(cln::AddgossipRequest), - AutoCleanInvoice(cln::AutocleaninvoiceRequest), + AutoCleanOnce(cln::AutocleanonceRequest), CheckMessage(cln::CheckmessageRequest), Close(cln::CloseRequest), Connect(cln::ConnectRequest), diff --git a/libs/gl-client/src/signer/resolve.rs b/libs/gl-client/src/signer/resolve.rs index b240ce9fd..f02a2e7a9 100644 --- a/libs/gl-client/src/signer/resolve.rs +++ b/libs/gl-client/src/signer/resolve.rs @@ -94,7 +94,7 @@ impl Resolver { // Manually calling preapproveinvoice should // always be allowed. The bolt11 string have to // match. - l.invstring.0 == r.bolt11().as_bytes() + l.invstring.0 == r.bolt11.as_bytes() } (Message::PreapproveInvoice(l), Request::TrampolinePay(r)) => { l.invstring.0 == r.bolt11.as_bytes() diff --git a/libs/gl-plugin/Cargo.toml b/libs/gl-plugin/Cargo.toml index 16174ebd8..cde38e96c 100644 --- a/libs/gl-plugin/Cargo.toml +++ b/libs/gl-plugin/Cargo.toml @@ -2,10 +2,7 @@ name = "gl-plugin" version = "0.3.0" edition = "2021" -authors = [ - "Christian Decker", - "The Greenlight Team" -] +authors = ["Christian Decker", "The Greenlight Team"] description = "Python bindings for the Greenlight client library." repository = "https://github.com/Blockstream/greenlight" license = "MIT" @@ -33,7 +30,7 @@ lazy_static = "^1.4.0" linemux = "0.2" log = "0.4" nix = "^0" -prost = "0.11" +prost = "0.12" serde = { version = "1.0", features = ["derive"] } serde_json = "1" sled = "0.34" @@ -41,9 +38,9 @@ thiserror = "1" tokio = { version = "1", features = ["full"] } tokio-stream = { version = "0.1", features = ["net"] } tokio-util = { version = "0.7", features = ["codec"] } -tonic = { version = "^0.8", features = ["tls", "transport"] } +tonic = { version = "0.11", features = ["tls", "transport"] } tower = { version = "0.4" } vls-protocol = { workspace = true } [build-dependencies] -tonic-build = "^0.8" +tonic-build = "0.11" diff --git a/libs/gl-plugin/src/awaitables.rs b/libs/gl-plugin/src/awaitables.rs index 75997b030..4fae28150 100644 --- a/libs/gl-plugin/src/awaitables.rs +++ b/libs/gl-plugin/src/awaitables.rs @@ -1,9 +1,6 @@ use cln_rpc::{ model::{ - requests::{ - ConnectRequest, GetinfoRequest, GetrouteRequest, ListpeerchannelsRequest, - ListpeersRequest, - }, + requests::{ConnectRequest, GetinfoRequest, GetrouteRequest, ListpeerchannelsRequest}, responses::GetrouteResponse, }, primitives::{Amount, PublicKey, ShortChannelId}, @@ -311,7 +308,6 @@ async fn billboard( .await .map_err(|e| Error::Rpc(e))? .channels - .ok_or(Error::Channel("No channels found"))? .into_iter() .filter(|c| { c.short_channel_id == Some(scid) @@ -324,28 +320,10 @@ async fn billboard( .status .ok_or(Error::Channel("Status not found"))?) } else { - #[allow(deprecated)] - Ok(rpc - .call_typed(&ListpeersRequest { - id: Some(peer_id), - level: None, - }) - .await - .map_err(|e| Error::Rpc(e))? - .peers - .into_iter() - .nth(0) - .ok_or(Error::Channel("Has no peers list"))? - .channels - .into_iter() - .nth(0) - .ok_or(Error::Channel("Has no channels list"))? - .into_iter() - .filter(|c| c.short_channel_id == Some(scid)) - .nth(0) - .ok_or(Error::Channel("No channel with scid"))? - .status - .ok_or(Error::Channel("No amount found"))?) + return Err(Error::Service(format!( + "Not supported in this version of core-lightning: {}, need at least v23.05gl1", + version, + ))); } } @@ -381,7 +359,6 @@ async fn spendable_msat( .await .map_err(|e| Error::Rpc(e))? .channels - .ok_or(Error::Channel("No channels found"))? .into_iter() .filter(|c| { c.short_channel_id == Some(scid) @@ -394,28 +371,10 @@ async fn spendable_msat( .spendable_msat .ok_or(Error::Channel("No amount found"))?) } else { - #[allow(deprecated)] - Ok(rpc - .call_typed(&ListpeersRequest { - id: Some(peer_id), - level: None, - }) - .await - .map_err(|e| Error::Rpc(e))? - .peers - .into_iter() - .nth(0) - .ok_or(Error::Channel("Has no peers list"))? - .channels - .into_iter() - .nth(0) - .ok_or(Error::Channel("Has no channels list"))? - .into_iter() - .filter(|c| c.short_channel_id == Some(scid)) - .nth(0) - .ok_or(Error::Channel("No channel with scid"))? - .spendable_msat - .ok_or(Error::Channel("No amount found"))?) + return Err(Error::Service(format!( + "Not supported in this version of core-lightning: {}, need at least v23.05gl1", + version, + ))); } } diff --git a/libs/gl-plugin/src/bin/plugin.rs b/libs/gl-plugin/src/bin/plugin.rs index d2dabbb60..121f5437c 100644 --- a/libs/gl-plugin/src/bin/plugin.rs +++ b/libs/gl-plugin/src/bin/plugin.rs @@ -21,10 +21,18 @@ async fn main() -> Result<(), Error> { let config = Config::new().context("loading config")?; let stage = Arc::new(Stage::new()); let (events, _) = tokio::sync::broadcast::channel(16); + let (notifications, _) = tokio::sync::broadcast::channel(16); let state_store = get_signer_store().await?; start_hsm_server(config.clone(), stage.clone())?; - start_node_server(config, stage.clone(), events.clone(), state_store).await?; + start_node_server( + config, + stage.clone(), + events.clone(), + notifications, + state_store, + ) + .await?; let plugin = gl_plugin::init(stage, events).await?; if let Some(plugin) = plugin.start().await? { @@ -38,6 +46,7 @@ async fn start_node_server( config: Config, stage: Arc, events: tokio::sync::broadcast::Sender, + notifications: tokio::sync::broadcast::Sender, signer_state_store: Box, ) -> Result<(), Error> { let addr: SocketAddr = config @@ -62,6 +71,7 @@ async fn start_node_server( stage.clone(), config.clone(), events.clone(), + notifications.clone(), signer_state_store, ) .await?; diff --git a/libs/gl-plugin/src/node/mod.rs b/libs/gl-plugin/src/node/mod.rs index 46ad26955..a05af6f03 100644 --- a/libs/gl-plugin/src/node/mod.rs +++ b/libs/gl-plugin/src/node/mod.rs @@ -6,6 +6,7 @@ use crate::{stager, tramp}; use anyhow::{Context, Error, Result}; use base64::{engine::general_purpose, Engine as _}; use bytes::BufMut; +use cln_rpc::Notification; use gl_client::persist::State; use governor::{ clock::MonotonicClock, state::direct::NotKeyed, state::InMemoryState, Quota, RateLimiter, @@ -85,6 +86,7 @@ pub struct PluginNodeServer { grpc_binding: String, signer_state_store: Arc>>, pub ctx: crate::context::Context, + notifications: tokio::sync::broadcast::Sender, } impl PluginNodeServer { @@ -92,6 +94,7 @@ impl PluginNodeServer { stage: Arc, config: Config, events: tokio::sync::broadcast::Sender, + notifications: tokio::sync::broadcast::Sender, signer_state_store: Box, ) -> Result { let tls = ServerTlsConfig::new() @@ -126,6 +129,7 @@ impl PluginNodeServer { signer_state: Arc::new(Mutex::new(signer_state)), signer_state_store: Arc::new(Mutex::new(signer_state_store)), grpc_binding: config.node_grpc_binding, + notifications, }; tokio::spawn(async move { diff --git a/libs/gl-plugin/src/node/rpcwait.rs b/libs/gl-plugin/src/node/rpcwait.rs index 7fab398ee..326ddf923 100644 --- a/libs/gl-plugin/src/node/rpcwait.rs +++ b/libs/gl-plugin/src/node/rpcwait.rs @@ -1,5 +1,5 @@ -use tonic::transport::NamedService; use log::warn; +use tonic::server::NamedService; use tower::Service; /// The RPC socket will not be available right away, so we wrap the diff --git a/libs/gl-plugin/src/node/wrapper.rs b/libs/gl-plugin/src/node/wrapper.rs index 0503c05b7..6165789c1 100644 --- a/libs/gl-plugin/src/node/wrapper.rs +++ b/libs/gl-plugin/src/node/wrapper.rs @@ -2,9 +2,12 @@ use std::collections::HashMap; use std::str::FromStr; use anyhow::Error; +use cln_grpc; use cln_grpc::pb::{self, node_server::Node}; -use cln_rpc::{self, model::responses::ListpeerchannelsChannelsState}; +use cln_rpc::primitives::ChannelState; +use cln_rpc::{self}; use log::debug; +use tokio_stream::wrappers::ReceiverStream; use tonic::{Request, Response, Status}; use super::PluginNodeServer; @@ -23,7 +26,8 @@ pub struct WrappedNodeServer { // TODO Make node into a module and add the WrappedNodeServer as a submodule. impl WrappedNodeServer { pub async fn new(node_server: PluginNodeServer) -> anyhow::Result { - let inner = cln_grpc::Server::new(&node_server.rpc_path).await?; + let inner = + cln_grpc::Server::new(&node_server.rpc_path, node_server.notifications.clone()).await?; Ok(WrappedNodeServer { inner, node_server }) } } @@ -218,13 +222,6 @@ impl Node for WrappedNodeServer { self.inner.add_gossip(r).await } - async fn auto_clean_invoice( - &self, - r: Request, - ) -> Result, Status> { - self.inner.auto_clean_invoice(r).await - } - async fn check_message( &self, r: Request, @@ -274,13 +271,6 @@ impl Node for WrappedNodeServer { self.inner.del_datastore(r).await } - async fn del_expired_invoice( - &self, - r: Request, - ) -> Result, Status> { - self.inner.del_expired_invoice(r).await - } - async fn del_invoice( &self, r: Request, @@ -556,13 +546,574 @@ impl Node for WrappedNodeServer { ) -> Result, tonic::Status> { self.inner.wait(request).await } -} -fn check_option(opt: Option, condition: F) -> bool -where - F: FnOnce(&T) -> bool, -{ - opt.as_ref().map_or(false, condition) + async fn add_psbt_output( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.add_psbt_output(request).await + } + + async fn auto_clean_once( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.auto_clean_once(request).await + } + + async fn auto_clean_status( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.auto_clean_status(request).await + } + + async fn dev_forget_channel( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.dev_forget_channel(request).await + } + + async fn emergency_recover( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.emergency_recover(request).await + } + + async fn get_emergency_recover_data( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.get_emergency_recover_data(request).await + } + + async fn expose_secret( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.expose_secret(request).await + } + + async fn recover( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.recover(request).await + } + + async fn recover_channel( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.recover_channel(request).await + } + + async fn create_invoice_request( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.create_invoice_request(request).await + } + + async fn disable_invoice_request( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.disable_invoice_request(request).await + } + + async fn list_invoice_requests( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.list_invoice_requests(request).await + } + + async fn make_secret( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.make_secret(request).await + } + + async fn del_pay( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.del_pay(request).await + } + + async fn del_forward( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.del_forward(request).await + } + + async fn disable_offer( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.disable_offer(request).await + } + + async fn enable_offer( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.enable_offer(request).await + } + + async fn fund_channel_cancel( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.fund_channel_cancel(request).await + } + + async fn fund_channel_complete( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.fund_channel_complete(request).await + } + + async fn fund_channel_start( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.fund_channel_start(request).await + } + + async fn get_log( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.get_log(request).await + } + + async fn funder_update( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.funder_update(request).await + } + + async fn list_addresses( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.list_addresses(request).await + } + + async fn multi_fund_channel( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.multi_fund_channel(request).await + } + + async fn multi_withdraw( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.multi_withdraw(request).await + } + + async fn open_channel_abort( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.open_channel_abort(request).await + } + + async fn open_channel_bump( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.open_channel_bump(request).await + } + + async fn open_channel_init( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.open_channel_init(request).await + } + + async fn open_channel_signed( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.open_channel_signed(request).await + } + + async fn open_channel_update( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.open_channel_update(request).await + } + + async fn plugin( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.plugin(request).await + } + + async fn rene_pay_status( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.rene_pay_status(request).await + } + + async fn rene_pay( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.rene_pay(request).await + } + + async fn reserve_inputs( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.reserve_inputs(request).await + } + + async fn send_invoice( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.send_invoice(request).await + } + + async fn set_config( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.set_config(request).await + } + + async fn set_psbt_version( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.set_psbt_version(request).await + } + + async fn splice_init( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.splice_init(request).await + } + + async fn splice_signed( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.splice_signed(request).await + } + + async fn splice_update( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.splice_update(request).await + } + + async fn dev_splice( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.dev_splice(request).await + } + + async fn unreserve_inputs( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.unreserve_inputs(request).await + } + + async fn upgrade_wallet( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.upgrade_wallet(request).await + } + + async fn list_configs( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.list_configs(request).await + } + + async fn help( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.help(request).await + } + + async fn bkpr_channels_apy( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.bkpr_channels_apy(request).await + } + + async fn bkpr_dump_income_csv( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.bkpr_dump_income_csv(request).await + } + + async fn bkpr_inspect( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.bkpr_inspect(request).await + } + + async fn bkpr_list_account_events( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.bkpr_list_account_events(request).await + } + + async fn bkpr_list_balances( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.bkpr_list_balances(request).await + } + + async fn bkpr_edit_description_by_outpoint( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.bkpr_edit_description_by_outpoint(request).await + } + + async fn bkpr_edit_description_by_payment_id( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner + .bkpr_edit_description_by_payment_id(request) + .await + } + + async fn blacklist_rune( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.blacklist_rune(request).await + } + + async fn check_rune( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.check_rune(request).await + } + + async fn create_rune( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.create_rune(request).await + } + + async fn show_runes( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.show_runes(request).await + } + + async fn ask_rene_unreserve( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_unreserve(request).await + } + + async fn ask_rene_list_layers( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_list_layers(request).await + } + + async fn ask_rene_create_layer( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_create_layer(request).await + } + + async fn ask_rene_remove_layer( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_remove_layer(request).await + } + + async fn ask_rene_reserve( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_reserve(request).await + } + + async fn ask_rene_age( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_age(request).await + } + + async fn get_routes( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.get_routes(request).await + } + + async fn ask_rene_disable_node( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_disable_node(request).await + } + + async fn ask_rene_inform_channel( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_inform_channel(request).await + } + + async fn ask_rene_create_channel( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_create_channel(request).await + } + + async fn ask_rene_update_channel( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_update_channel(request).await + } + + async fn ask_rene_bias_channel( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_bias_channel(request).await + } + + async fn ask_rene_list_reservations( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.ask_rene_list_reservations(request).await + } + + async fn inject_payment_onion( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.inject_payment_onion(request).await + } + + async fn inject_onion_message( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.inject_onion_message(request).await + } + + async fn xpay( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.xpay(request).await + } + + type SubscribeBlockAddedStream = + ReceiverStream>; + + async fn subscribe_block_added( + &self, + _request: tonic::Request, + ) -> Result, tonic::Status> { + // TODO: Implement this once `cln_grpc::server::NotificationStream is public + unimplemented!(); + } + + type SubscribeChannelOpenFailedStream = + ReceiverStream>; + + async fn subscribe_channel_open_failed( + &self, + _request: tonic::Request, + ) -> Result, tonic::Status> { + // TODO: Implement this once `cln_grpc::server::NotificationStream is public + unimplemented!(); + } + + type SubscribeChannelOpenedStream = + ReceiverStream>; + async fn subscribe_channel_opened( + &self, + _request: tonic::Request, + ) -> Result, tonic::Status> { + // TODO: Implement this once `cln_grpc::server::NotificationStream is public + unimplemented!(); + } + + type SubscribeConnectStream = + ReceiverStream>; + async fn subscribe_connect( + &self, + _request: tonic::Request, + ) -> Result, tonic::Status> { + // TODO: Implement this once `cln_grpc::server::NotificationStream is public + unimplemented!(); + } + + type SubscribeCustomMsgStream = + ReceiverStream>; + async fn subscribe_custom_msg( + &self, + _request: tonic::Request, + ) -> Result, tonic::Status> { + // TODO: Implement this once `cln_grpc::server::NotificationStream is public + unimplemented!(); + } + + type SubscribeChannelStateChangedStream = + ReceiverStream>; + async fn subscribe_channel_state_changed( + &self, + _request: tonic::Request, + ) -> Result, tonic::Status> { + // TODO: Implement this once `cln_grpc::server::NotificationStream is public + unimplemented!(); + } } impl WrappedNodeServer { @@ -578,15 +1129,12 @@ impl WrappedNodeServer { let active_channels: HashMap< cln_rpc::primitives::ShortChannelId, cln_rpc::primitives::ShortChannelId, - > = match res.channels { - Some(channels) => channels + > = match res.channels.len() { + 0 => HashMap::new(), + _ => res + .channels .into_iter() - .filter(|c| { - check_option(c.peer_connected, |&c| c) - && check_option(c.state, |&state| { - state == ListpeerchannelsChannelsState::CHANNELD_NORMAL - }) - }) + .filter(|c| c.peer_connected && c.state == ChannelState::CHANNELD_NORMAL) .filter_map(|c| { c.short_channel_id.map(|scid| { let value = c @@ -598,7 +1146,6 @@ impl WrappedNodeServer { }) }) .collect(), - None => HashMap::new(), }; let res: crate::responses::ListIncoming = rpc @@ -630,7 +1177,7 @@ impl WrappedNodeServer { pb::Routehint { hops: vec![pb::RouteHop { id: hex::decode(i.id).expect("hex-decoding node_id"), - short_channel_id: alias_str, + scid: alias_str, feebase: base.map(|b| b.into()), feeprop: i.fee_proportional_millionths, expirydelta: i.cltv_expiry_delta, @@ -647,7 +1194,6 @@ use crate::pb::{ node_server::Node as GlNode, Custommsg, Empty, HsmRequest, HsmResponse, IncomingPayment, LogEntry, StreamCustommsgRequest, StreamIncomingFilter, StreamLogRequest, }; -use tokio_stream::wrappers::ReceiverStream; #[tonic::async_trait] impl GlNode for WrappedNodeServer { diff --git a/libs/gl-plugin/src/pb.rs b/libs/gl-plugin/src/pb.rs index b0f6d5fc1..55969a95c 100644 --- a/libs/gl-plugin/src/pb.rs +++ b/libs/gl-plugin/src/pb.rs @@ -29,7 +29,7 @@ impl From for requests::RoutehintHopDev { fn from(r: cln_grpc::pb::RouteHop) -> requests::RoutehintHopDev { requests::RoutehintHopDev { id: hex::encode(r.id), - short_channel_id: r.short_channel_id, + short_channel_id: r.scid, fee_base_msat: r.feebase.map(|f| f.msat), fee_proportional_millionths: r.feeprop, cltv_expiry_delta: r.expirydelta as u16, diff --git a/libs/gl-plugin/src/tramp.rs b/libs/gl-plugin/src/tramp.rs index 60d49bb0c..b9a8b7d1c 100644 --- a/libs/gl-plugin/src/tramp.rs +++ b/libs/gl-plugin/src/tramp.rs @@ -196,7 +196,6 @@ pub async fn trampolinepay( .call_typed(&cln_rpc::model::requests::ListpeerchannelsRequest { id: Some(node_id) }) .await? .channels - .unwrap_or_default() .into_iter() .filter_map(|ch| { let short_channel_id = ch.short_channel_id.or(ch.alias.and_then(|a| a.local)); @@ -262,7 +261,7 @@ pub async fn trampolinepay( // All set we can preapprove the invoice let _ = rpc .call_typed(&cln_rpc::model::requests::PreapproveinvoiceRequest { - bolt11: Some(req.bolt11.clone()), + bolt11: req.bolt11.clone(), }) .await?; @@ -397,7 +396,7 @@ async fn do_pay( let route = cln_rpc::model::requests::SendpayRoute { amount_msat: cln_rpc::primitives::Amount::from_msat(part_amt), id: node_id.clone(), - delay: max_delay.unwrap_or(MAX_DELAY_DEFAULT) as u16, + delay: max_delay.unwrap_or(MAX_DELAY_DEFAULT), channel: scid, };