Skip to content

Commit

Permalink
cln-grpc: Add conversion from pb Amount to json Amount
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker authored and pull[bot] committed Jul 25, 2023
1 parent a580406 commit 3126884
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cln-grpc/src/pb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,20 @@ impl From<Amount> for JAmount {
JAmount::from_msat(a.msat)
}
}

impl From<&Amount> for JAmount {
fn from(a: &Amount) -> Self {
match a {
Amount {
unit: Some(amount::Unit::Millisatoshi(v)),
} => JAmount::Millisatoshi(*v),
Amount {
unit: Some(amount::Unit::Satoshi(v)),
} => JAmount::Satoshi(*v),
Amount {
unit: Some(amount::Unit::Bitcoin(v)),
} => JAmount::Bitcoin(*v),
o => panic!("Unhandled conversion from pb:Amount to json:Amount: {:?}", o),
}
}
}

0 comments on commit 3126884

Please sign in to comment.