Skip to content

Commit 7097f2d

Browse files
authored
Merge pull request #87 from lightning-signer/2023-04-fix-routehints
cln: Fix routehints conversion from cln-rpc and cln-grpc
2 parents d777a11 + 3d89d13 commit 7097f2d

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

cln-rpc/src/primitives.rs

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,16 +652,62 @@ pub struct Routehop {
652652
pub expirydelta: u16,
653653
}
654654

655-
#[derive(Clone, Debug, Serialize, Deserialize)]
655+
#[derive(Clone, Debug)]
656656
pub struct Routehint {
657657
pub hops: Vec<Routehop>,
658658
}
659659

660-
#[derive(Clone, Debug, Serialize, Deserialize)]
660+
#[derive(Clone, Debug)]
661661
pub struct RoutehintList {
662662
pub hints: Vec<Routehint>,
663663
}
664664

665+
use serde::ser::SerializeSeq;
666+
667+
impl Serialize for Routehint {
668+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
669+
where
670+
S: Serializer,
671+
{
672+
let mut seq = serializer.serialize_seq(Some(self.hops.len()))?;
673+
for e in self.hops.iter() {
674+
seq.serialize_element(e)?;
675+
}
676+
seq.end()
677+
}
678+
}
679+
680+
impl Serialize for RoutehintList {
681+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
682+
where
683+
S: Serializer,
684+
{
685+
let mut seq = serializer.serialize_seq(Some(self.hints.len()))?;
686+
for e in self.hints.iter() {
687+
seq.serialize_element(e)?;
688+
}
689+
seq.end()
690+
}
691+
}
692+
693+
impl<'de> Deserialize<'de> for RoutehintList {
694+
fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
695+
where
696+
D: Deserializer<'de>,
697+
{
698+
todo!("Required once we roundtrip, but not necessary for cln-rpc itself")
699+
}
700+
}
701+
702+
impl<'de> Deserialize<'de> for Routehint {
703+
fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
704+
where
705+
D: Deserializer<'de>,
706+
{
707+
todo!("Required once we roundtrip, but not necessary for cln-rpc itself")
708+
}
709+
}
710+
665711
/// An error returned by the lightningd RPC consisting of a code and a
666712
/// message
667713
#[derive(Clone, Serialize, Deserialize, Debug)]

0 commit comments

Comments
 (0)