mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
cln-grpc: Add glue to get all pieces to work together
This commit is contained in:
parent
62dc078271
commit
24e44ecbb6
5 changed files with 26 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"cln-rpc",
|
"cln-rpc",
|
||||||
|
"cln-grpc",
|
||||||
]
|
]
|
||||||
|
|
|
@ -2,13 +2,7 @@ syntax = "proto3";
|
||||||
package cln;
|
package cln;
|
||||||
|
|
||||||
message Amount {
|
message Amount {
|
||||||
oneof unit {
|
uint64 msat = 1;
|
||||||
uint64 millisatoshi = 1;
|
|
||||||
uint64 satoshi = 2;
|
|
||||||
uint64 bitcoin = 3;
|
|
||||||
bool all = 4;
|
|
||||||
bool any = 5;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ChannelSide {
|
enum ChannelSide {
|
||||||
|
|
5
cln-grpc/src/lib.rs
Normal file
5
cln-grpc/src/lib.rs
Normal 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
15
cln-grpc/src/pb.rs
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -62,6 +62,10 @@ impl Amount {
|
||||||
msat: 100_000_000_000 * btc,
|
msat: 100_000_000_000 * btc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn msat(&self) -> u64 {
|
||||||
|
self.msat
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)]
|
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue