cln-grpc: Add glue to get all pieces to work together

This commit is contained in:
Christian Decker 2022-01-16 16:39:47 +01:00
parent 62dc078271
commit 24e44ecbb6
5 changed files with 26 additions and 7 deletions

View file

@ -1,4 +1,5 @@
[workspace]
members = [
"cln-rpc",
"cln-grpc",
]

View file

@ -2,13 +2,7 @@ syntax = "proto3";
package cln;
message Amount {
oneof unit {
uint64 millisatoshi = 1;
uint64 satoshi = 2;
uint64 bitcoin = 3;
bool all = 4;
bool any = 5;
}
uint64 msat = 1;
}
enum ChannelSide {

5
cln-grpc/src/lib.rs Normal file
View file

@ -0,0 +1,5 @@
mod convert;
pub mod pb;
mod server;
pub use crate::server::Server;

15
cln-grpc/src/pb.rs Normal file
View file

@ -0,0 +1,15 @@
tonic::include_proto!("cln");
use cln_rpc::primitives::Amount as JAmount;
impl From<JAmount> for Amount {
fn from(a: JAmount) -> Self {
Amount { msat: a.msat() }
}
}
impl From<Amount> for JAmount {
fn from(a: Amount) -> Self {
JAmount::from_msat(a.msat)
}
}

View file

@ -62,6 +62,10 @@ impl Amount {
msat: 100_000_000_000 * btc,
}
}
pub fn msat(&self) -> u64 {
self.msat
}
}
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)]