mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
cln-grpc: Add conversion from pb Amount to json Amount
This commit is contained in:
parent
bb4946a6e6
commit
d95c9d2990
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user