Skip to content

Commit

Permalink
cln-grpc: Add glue to get all pieces to work together
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed Feb 28, 2022
1 parent 62dc078 commit 24e44ec
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
members = [
"cln-rpc",
"cln-grpc",
]
8 changes: 1 addition & 7 deletions cln-grpc/proto/primitives.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions cln-grpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod convert;
pub mod pb;
mod server;

pub use crate::server::Server;
15 changes: 15 additions & 0 deletions cln-grpc/src/pb.rs
Original file line number Diff line number Diff line change
@@ -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)
}
}
4 changes: 4 additions & 0 deletions cln-rpc/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 24e44ec

Please sign in to comment.