mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 17:14:22 +01:00
cln-grpc: Add glue to get all pieces to work together
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"cln-rpc",
|
||||
"cln-grpc",
|
||||
]
|
||||
|
||||
@@ -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
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,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn msat(&self) -> u64 {
|
||||
self.msat
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)]
|
||||
|
||||
Reference in New Issue
Block a user