mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 09:04:22 +01:00
cln-grpc: Skip serializing fields when Option<Vec<T>> is empty too
The CLN API is rather strict about the fact that we should skip providing a field whenever it is empty. Checking for `is_none` would still include empty arrays. Changelog-Fixed cln-rpc: Optional empty arrays will no longer be serialized in requests
This commit is contained in:
committed by
Rusty Russell
parent
77f5eb556b
commit
12275d0bfe
@@ -106,6 +106,16 @@ impl ClnRpc {
|
||||
}
|
||||
}
|
||||
|
||||
/// Used to skip optional arrays when serializing requests.
|
||||
fn is_none_or_empty<T>(f: &Option<Vec<T>>) -> bool
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
// TODO Find a better way to check, possibly without cloning
|
||||
let f = f.clone();
|
||||
f.is_none() || f.unwrap().is_empty()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user