mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
msggen: Add fundchannel request
This commit is contained in:
committed by
Rusty Russell
parent
b8bcc7d13f
commit
77f5eb556b
20
.msggen.json
20
.msggen.json
@@ -381,6 +381,26 @@
|
|||||||
"Feerates.perkw": 3,
|
"Feerates.perkw": 3,
|
||||||
"Feerates.warning_missing_feerates": 1
|
"Feerates.warning_missing_feerates": 1
|
||||||
},
|
},
|
||||||
|
"FundchannelRequest": {
|
||||||
|
"FundChannel.amount": 1,
|
||||||
|
"FundChannel.announce": 3,
|
||||||
|
"FundChannel.close_to": 6,
|
||||||
|
"FundChannel.compact_lease": 8,
|
||||||
|
"FundChannel.feerate": 2,
|
||||||
|
"FundChannel.id": 9,
|
||||||
|
"FundChannel.minconf": 10,
|
||||||
|
"FundChannel.minconf[]": 4,
|
||||||
|
"FundChannel.push_msat": 5,
|
||||||
|
"FundChannel.request_amt": 7,
|
||||||
|
"FundChannel.utxos[]": 11
|
||||||
|
},
|
||||||
|
"FundchannelResponse": {
|
||||||
|
"FundChannel.channel_id": 4,
|
||||||
|
"FundChannel.close_to": 5,
|
||||||
|
"FundChannel.outnum": 3,
|
||||||
|
"FundChannel.tx": 1,
|
||||||
|
"FundChannel.txid": 2
|
||||||
|
},
|
||||||
"FundpsbtRequest": {
|
"FundpsbtRequest": {
|
||||||
"FundPsbt.excess_as_change": 8,
|
"FundPsbt.excess_as_change": 8,
|
||||||
"FundPsbt.feerate": 2,
|
"FundPsbt.feerate": 2,
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ service Node {
|
|||||||
rpc TxSend(TxsendRequest) returns (TxsendResponse) {}
|
rpc TxSend(TxsendRequest) returns (TxsendResponse) {}
|
||||||
rpc Disconnect(DisconnectRequest) returns (DisconnectResponse) {}
|
rpc Disconnect(DisconnectRequest) returns (DisconnectResponse) {}
|
||||||
rpc Feerates(FeeratesRequest) returns (FeeratesResponse) {}
|
rpc Feerates(FeeratesRequest) returns (FeeratesResponse) {}
|
||||||
|
rpc FundChannel(FundchannelRequest) returns (FundchannelResponse) {}
|
||||||
rpc GetRoute(GetrouteRequest) returns (GetrouteResponse) {}
|
rpc GetRoute(GetrouteRequest) returns (GetrouteResponse) {}
|
||||||
rpc ListForwards(ListforwardsRequest) returns (ListforwardsResponse) {}
|
rpc ListForwards(ListforwardsRequest) returns (ListforwardsResponse) {}
|
||||||
rpc ListPays(ListpaysRequest) returns (ListpaysResponse) {}
|
rpc ListPays(ListpaysRequest) returns (ListpaysResponse) {}
|
||||||
@@ -1138,6 +1139,27 @@ message FeeratesOnchain_fee_estimates {
|
|||||||
uint64 htlc_success_satoshis = 5;
|
uint64 htlc_success_satoshis = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message FundchannelRequest {
|
||||||
|
bytes id = 9;
|
||||||
|
AmountOrAll amount = 1;
|
||||||
|
optional Feerate feerate = 2;
|
||||||
|
optional bool announce = 3;
|
||||||
|
optional double minconf = 10;
|
||||||
|
optional Amount push_msat = 5;
|
||||||
|
optional string close_to = 6;
|
||||||
|
optional Amount request_amt = 7;
|
||||||
|
optional string compact_lease = 8;
|
||||||
|
repeated Outpoint utxos = 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FundchannelResponse {
|
||||||
|
bytes tx = 1;
|
||||||
|
bytes txid = 2;
|
||||||
|
uint32 outnum = 3;
|
||||||
|
bytes channel_id = 4;
|
||||||
|
optional bytes close_to = 5;
|
||||||
|
}
|
||||||
|
|
||||||
message GetrouteRequest {
|
message GetrouteRequest {
|
||||||
bytes id = 1;
|
bytes id = 1;
|
||||||
Amount amount_msat = 9;
|
Amount amount_msat = 9;
|
||||||
|
|||||||
@@ -853,6 +853,19 @@ impl From<&responses::FeeratesResponse> for pb::FeeratesResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
impl From<&responses::FundchannelResponse> for pb::FundchannelResponse {
|
||||||
|
fn from(c: &responses::FundchannelResponse) -> Self {
|
||||||
|
Self {
|
||||||
|
tx: hex::decode(&c.tx).unwrap(), // Rule #2 for type hex
|
||||||
|
txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid
|
||||||
|
outnum: c.outnum.clone(), // Rule #2 for type u32
|
||||||
|
channel_id: hex::decode(&c.channel_id).unwrap(), // Rule #2 for type hex
|
||||||
|
close_to: c.close_to.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
impl From<&responses::GetrouteRoute> for pb::GetrouteRoute {
|
impl From<&responses::GetrouteRoute> for pb::GetrouteRoute {
|
||||||
fn from(c: &responses::GetrouteRoute) -> Self {
|
fn from(c: &responses::GetrouteRoute) -> Self {
|
||||||
@@ -1424,6 +1437,24 @@ impl From<&pb::FeeratesRequest> for requests::FeeratesRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
impl From<&pb::FundchannelRequest> for requests::FundchannelRequest {
|
||||||
|
fn from(c: &pb::FundchannelRequest) -> Self {
|
||||||
|
Self {
|
||||||
|
id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey
|
||||||
|
amount: c.amount.as_ref().unwrap().into(), // Rule #1 for type msat_or_all
|
||||||
|
feerate: c.feerate.as_ref().map(|a| a.into()), // Rule #1 for type feerate?
|
||||||
|
announce: c.announce.clone(), // Rule #1 for type boolean?
|
||||||
|
minconf: c.minconf.clone(), // Rule #1 for type number?
|
||||||
|
push_msat: c.push_msat.as_ref().map(|a| a.into()), // Rule #1 for type msat?
|
||||||
|
close_to: c.close_to.clone(), // Rule #1 for type string?
|
||||||
|
request_amt: c.request_amt.as_ref().map(|a| a.into()), // Rule #1 for type msat?
|
||||||
|
compact_lease: c.compact_lease.clone(), // Rule #1 for type string?
|
||||||
|
utxos: Some(c.utxos.iter().map(|s| s.into()).collect()), // Rule #4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
impl From<&pb::GetrouteRequest> for requests::GetrouteRequest {
|
impl From<&pb::GetrouteRequest> for requests::GetrouteRequest {
|
||||||
fn from(c: &pb::GetrouteRequest) -> Self {
|
fn from(c: &pb::GetrouteRequest) -> Self {
|
||||||
|
|||||||
@@ -1274,6 +1274,38 @@ async fn feerates(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn fund_channel(
|
||||||
|
&self,
|
||||||
|
request: tonic::Request<pb::FundchannelRequest>,
|
||||||
|
) -> Result<tonic::Response<pb::FundchannelResponse>, tonic::Status> {
|
||||||
|
let req = request.into_inner();
|
||||||
|
let req: requests::FundchannelRequest = (&req).into();
|
||||||
|
debug!("Client asked for fund_channel");
|
||||||
|
trace!("fund_channel request: {:?}", req);
|
||||||
|
let mut rpc = ClnRpc::new(&self.rpc_path)
|
||||||
|
.await
|
||||||
|
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
|
||||||
|
let result = rpc.call(Request::FundChannel(req))
|
||||||
|
.await
|
||||||
|
.map_err(|e| Status::new(
|
||||||
|
Code::Unknown,
|
||||||
|
format!("Error calling method FundChannel: {:?}", e)))?;
|
||||||
|
match result {
|
||||||
|
Response::FundChannel(r) => {
|
||||||
|
trace!("fund_channel response: {:?}", r);
|
||||||
|
Ok(tonic::Response::new((&r).into()))
|
||||||
|
},
|
||||||
|
r => Err(Status::new(
|
||||||
|
Code::Internal,
|
||||||
|
format!(
|
||||||
|
"Unexpected result {:?} to method call FundChannel",
|
||||||
|
r
|
||||||
|
)
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_route(
|
async fn get_route(
|
||||||
&self,
|
&self,
|
||||||
request: tonic::Request<pb::GetrouteRequest>,
|
request: tonic::Request<pb::GetrouteRequest>,
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ pub enum Request {
|
|||||||
TxSend(requests::TxsendRequest),
|
TxSend(requests::TxsendRequest),
|
||||||
Disconnect(requests::DisconnectRequest),
|
Disconnect(requests::DisconnectRequest),
|
||||||
Feerates(requests::FeeratesRequest),
|
Feerates(requests::FeeratesRequest),
|
||||||
|
FundChannel(requests::FundchannelRequest),
|
||||||
GetRoute(requests::GetrouteRequest),
|
GetRoute(requests::GetrouteRequest),
|
||||||
ListForwards(requests::ListforwardsRequest),
|
ListForwards(requests::ListforwardsRequest),
|
||||||
ListPays(requests::ListpaysRequest),
|
ListPays(requests::ListpaysRequest),
|
||||||
@@ -105,6 +106,7 @@ pub enum Response {
|
|||||||
TxSend(responses::TxsendResponse),
|
TxSend(responses::TxsendResponse),
|
||||||
Disconnect(responses::DisconnectResponse),
|
Disconnect(responses::DisconnectResponse),
|
||||||
Feerates(responses::FeeratesResponse),
|
Feerates(responses::FeeratesResponse),
|
||||||
|
FundChannel(responses::FundchannelResponse),
|
||||||
GetRoute(responses::GetrouteResponse),
|
GetRoute(responses::GetrouteResponse),
|
||||||
ListForwards(responses::ListforwardsResponse),
|
ListForwards(responses::ListforwardsResponse),
|
||||||
ListPays(responses::ListpaysResponse),
|
ListPays(responses::ListpaysResponse),
|
||||||
@@ -698,6 +700,30 @@ pub mod requests {
|
|||||||
pub style: FeeratesStyle,
|
pub style: FeeratesStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
pub struct FundchannelRequest {
|
||||||
|
#[serde(alias = "id")]
|
||||||
|
pub id: Pubkey,
|
||||||
|
#[serde(alias = "amount")]
|
||||||
|
pub amount: AmountOrAll,
|
||||||
|
#[serde(alias = "feerate", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub feerate: Option<Feerate>,
|
||||||
|
#[serde(alias = "announce", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub announce: Option<bool>,
|
||||||
|
#[serde(alias = "minconf", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub minconf: Option<f64>,
|
||||||
|
#[serde(alias = "push_msat", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub push_msat: Option<Amount>,
|
||||||
|
#[serde(alias = "close_to", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub close_to: Option<String>,
|
||||||
|
#[serde(alias = "request_amt", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub request_amt: Option<Amount>,
|
||||||
|
#[serde(alias = "compact_lease", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub compact_lease: Option<String>,
|
||||||
|
#[serde(alias = "utxos", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub utxos: Option<Vec<Outpoint>>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct GetrouteRequest {
|
pub struct GetrouteRequest {
|
||||||
#[serde(alias = "id")]
|
#[serde(alias = "id")]
|
||||||
@@ -2522,6 +2548,20 @@ pub mod responses {
|
|||||||
pub warning_missing_feerates: Option<String>,
|
pub warning_missing_feerates: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
pub struct FundchannelResponse {
|
||||||
|
#[serde(alias = "tx")]
|
||||||
|
pub tx: String,
|
||||||
|
#[serde(alias = "txid")]
|
||||||
|
pub txid: String,
|
||||||
|
#[serde(alias = "outnum")]
|
||||||
|
pub outnum: u32,
|
||||||
|
#[serde(alias = "channel_id")]
|
||||||
|
pub channel_id: String,
|
||||||
|
#[serde(alias = "close_to", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub close_to: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
/// The features understood by the destination node
|
/// The features understood by the destination node
|
||||||
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
|
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
|
||||||
pub enum GetrouteRouteStyle {
|
pub enum GetrouteRouteStyle {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ def load_jsonrpc_service(schema_dir: str = None):
|
|||||||
# "fetchinvoice",
|
# "fetchinvoice",
|
||||||
# "fundchannel_cancel",
|
# "fundchannel_cancel",
|
||||||
# "fundchannel_complete",
|
# "fundchannel_complete",
|
||||||
# "fundchannel",
|
"FundChannel",
|
||||||
# "fundchannel_start",
|
# "fundchannel_start",
|
||||||
# "funderupdate",
|
# "funderupdate",
|
||||||
# "getlog",
|
# "getlog",
|
||||||
|
|||||||
@@ -769,6 +769,16 @@ def feerates2py(m):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def fundchannel2py(m):
|
||||||
|
return remove_default({
|
||||||
|
"tx": hexlify(m.tx), # PrimitiveField in generate_composite
|
||||||
|
"txid": hexlify(m.txid), # PrimitiveField in generate_composite
|
||||||
|
"outnum": m.outnum, # PrimitiveField in generate_composite
|
||||||
|
"channel_id": hexlify(m.channel_id), # PrimitiveField in generate_composite
|
||||||
|
"close_to": hexlify(m.close_to), # PrimitiveField in generate_composite
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def getroute_route2py(m):
|
def getroute_route2py(m):
|
||||||
return remove_default({
|
return remove_default({
|
||||||
"id": hexlify(m.id), # PrimitiveField in generate_composite
|
"id": hexlify(m.id), # PrimitiveField in generate_composite
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -209,6 +209,11 @@ class NodeStub(object):
|
|||||||
request_serializer=node__pb2.FeeratesRequest.SerializeToString,
|
request_serializer=node__pb2.FeeratesRequest.SerializeToString,
|
||||||
response_deserializer=node__pb2.FeeratesResponse.FromString,
|
response_deserializer=node__pb2.FeeratesResponse.FromString,
|
||||||
)
|
)
|
||||||
|
self.FundChannel = channel.unary_unary(
|
||||||
|
'/cln.Node/FundChannel',
|
||||||
|
request_serializer=node__pb2.FundchannelRequest.SerializeToString,
|
||||||
|
response_deserializer=node__pb2.FundchannelResponse.FromString,
|
||||||
|
)
|
||||||
self.GetRoute = channel.unary_unary(
|
self.GetRoute = channel.unary_unary(
|
||||||
'/cln.Node/GetRoute',
|
'/cln.Node/GetRoute',
|
||||||
request_serializer=node__pb2.GetrouteRequest.SerializeToString,
|
request_serializer=node__pb2.GetrouteRequest.SerializeToString,
|
||||||
@@ -473,6 +478,12 @@ class NodeServicer(object):
|
|||||||
context.set_details('Method not implemented!')
|
context.set_details('Method not implemented!')
|
||||||
raise NotImplementedError('Method not implemented!')
|
raise NotImplementedError('Method not implemented!')
|
||||||
|
|
||||||
|
def FundChannel(self, request, context):
|
||||||
|
"""Missing associated documentation comment in .proto file."""
|
||||||
|
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||||
|
context.set_details('Method not implemented!')
|
||||||
|
raise NotImplementedError('Method not implemented!')
|
||||||
|
|
||||||
def GetRoute(self, request, context):
|
def GetRoute(self, request, context):
|
||||||
"""Missing associated documentation comment in .proto file."""
|
"""Missing associated documentation comment in .proto file."""
|
||||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||||
@@ -701,6 +712,11 @@ def add_NodeServicer_to_server(servicer, server):
|
|||||||
request_deserializer=node__pb2.FeeratesRequest.FromString,
|
request_deserializer=node__pb2.FeeratesRequest.FromString,
|
||||||
response_serializer=node__pb2.FeeratesResponse.SerializeToString,
|
response_serializer=node__pb2.FeeratesResponse.SerializeToString,
|
||||||
),
|
),
|
||||||
|
'FundChannel': grpc.unary_unary_rpc_method_handler(
|
||||||
|
servicer.FundChannel,
|
||||||
|
request_deserializer=node__pb2.FundchannelRequest.FromString,
|
||||||
|
response_serializer=node__pb2.FundchannelResponse.SerializeToString,
|
||||||
|
),
|
||||||
'GetRoute': grpc.unary_unary_rpc_method_handler(
|
'GetRoute': grpc.unary_unary_rpc_method_handler(
|
||||||
servicer.GetRoute,
|
servicer.GetRoute,
|
||||||
request_deserializer=node__pb2.GetrouteRequest.FromString,
|
request_deserializer=node__pb2.GetrouteRequest.FromString,
|
||||||
@@ -1399,6 +1415,23 @@ class Node(object):
|
|||||||
options, channel_credentials,
|
options, channel_credentials,
|
||||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def FundChannel(request,
|
||||||
|
target,
|
||||||
|
options=(),
|
||||||
|
channel_credentials=None,
|
||||||
|
call_credentials=None,
|
||||||
|
insecure=False,
|
||||||
|
compression=None,
|
||||||
|
wait_for_ready=None,
|
||||||
|
timeout=None,
|
||||||
|
metadata=None):
|
||||||
|
return grpc.experimental.unary_unary(request, target, '/cln.Node/FundChannel',
|
||||||
|
node__pb2.FundchannelRequest.SerializeToString,
|
||||||
|
node__pb2.FundchannelResponse.FromString,
|
||||||
|
options, channel_credentials,
|
||||||
|
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def GetRoute(request,
|
def GetRoute(request,
|
||||||
target,
|
target,
|
||||||
|
|||||||
45
doc/schemas/fundchannel.request.json
Normal file
45
doc/schemas/fundchannel.request.json
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"amount"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "pubkey",
|
||||||
|
"description": "id is the peer id obtained from connect."
|
||||||
|
},
|
||||||
|
"amount": {
|
||||||
|
"type": "msat_or_all"
|
||||||
|
},
|
||||||
|
"feerate": {
|
||||||
|
"type": "feerate"
|
||||||
|
},
|
||||||
|
"announce": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"minconf": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"push_msat": {
|
||||||
|
"type": "msat"
|
||||||
|
},
|
||||||
|
"close_to": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"request_amt": {
|
||||||
|
"type": "msat"
|
||||||
|
},
|
||||||
|
"compact_lease": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"utxos": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "outpoint"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user