Skip to content

Commit 3520b13

Browse files
committed
msggen: add currencyconvert, currencyrate and listcurrencyrates.
I used daywalker's hack to patch.py to make this work: ``` if f.added is None and 'added' not in m: m['added'] = 'v26.04' ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 549f721 commit 3520b13

10 files changed

Lines changed: 628 additions & 36 deletions

File tree

.msggen.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,19 @@
13151315
"CreateRune.unique_id": 2,
13161316
"CreateRune.warning_unrestricted_rune": 3
13171317
},
1318+
"CurrencyconvertRequest": {
1319+
"CurrencyConvert.amount": 1,
1320+
"CurrencyConvert.currency": 2
1321+
},
1322+
"CurrencyconvertResponse": {
1323+
"CurrencyConvert.msat": 1
1324+
},
1325+
"CurrencyrateRequest": {
1326+
"CurrencyRate.currency": 1
1327+
},
1328+
"CurrencyrateResponse": {
1329+
"CurrencyRate.rate": 1
1330+
},
13181331
"CustomMsgNotification": {
13191332
"custommsg.payload": 2,
13201333
"custommsg.peer_id": 1
@@ -2707,6 +2720,16 @@
27072720
"ListConfigs.wallet": 15,
27082721
"ListConfigs.watchtime-blocks": 31
27092722
},
2723+
"ListcurrencyratesCurrencyrates": {
2724+
"ListCurrencyRates.currencyrates[].amount": 2,
2725+
"ListCurrencyRates.currencyrates[].source": 1
2726+
},
2727+
"ListcurrencyratesRequest": {
2728+
"ListCurrencyRates.currency": 1
2729+
},
2730+
"ListcurrencyratesResponse": {
2731+
"ListCurrencyRates.currencyrates[]": 1
2732+
},
27102733
"ListdatastoreDatastore": {
27112734
"ListDatastore.datastore[].generation": 2,
27122735
"ListDatastore.datastore[].hex": 3,
@@ -6032,6 +6055,34 @@
60326055
"added": "v23.08",
60336056
"deprecated": null
60346057
},
6058+
"CurrencyConvert": {
6059+
"added": "v26.04",
6060+
"deprecated": null
6061+
},
6062+
"CurrencyConvert.amount": {
6063+
"added": "v26.04",
6064+
"deprecated": null
6065+
},
6066+
"CurrencyConvert.currency": {
6067+
"added": "v26.04",
6068+
"deprecated": null
6069+
},
6070+
"CurrencyConvert.msat": {
6071+
"added": "v26.04",
6072+
"deprecated": null
6073+
},
6074+
"CurrencyRate": {
6075+
"added": "v26.04",
6076+
"deprecated": null
6077+
},
6078+
"CurrencyRate.currency": {
6079+
"added": "v26.04",
6080+
"deprecated": null
6081+
},
6082+
"CurrencyRate.rate": {
6083+
"added": "v26.04",
6084+
"deprecated": null
6085+
},
60356086
"Datastore": {
60366087
"added": "pre-v0.10.1",
60376088
"deprecated": null
@@ -10152,6 +10203,26 @@
1015210203
"added": "pre-v0.10.1",
1015310204
"deprecated": "v23.08"
1015410205
},
10206+
"ListCurrencyRates": {
10207+
"added": "v26.04",
10208+
"deprecated": null
10209+
},
10210+
"ListCurrencyRates.currency": {
10211+
"added": "v26.04",
10212+
"deprecated": null
10213+
},
10214+
"ListCurrencyRates.currencyrates[]": {
10215+
"added": "v26.04",
10216+
"deprecated": null
10217+
},
10218+
"ListCurrencyRates.currencyrates[].amount": {
10219+
"added": "v26.04",
10220+
"deprecated": null
10221+
},
10222+
"ListCurrencyRates.currencyrates[].source": {
10223+
"added": "v26.04",
10224+
"deprecated": null
10225+
},
1015510226
"ListDatastore": {
1015610227
"added": "pre-v0.10.1",
1015710228
"deprecated": null

cln-grpc/proto/node.proto

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-grpc/src/convert.rs

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-grpc/src/server.rs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4626,6 +4626,102 @@ impl Node for Server
46264626

46274627
}
46284628

4629+
async fn list_currency_rates(
4630+
&self,
4631+
request: tonic::Request<pb::ListcurrencyratesRequest>,
4632+
) -> Result<tonic::Response<pb::ListcurrencyratesResponse>, tonic::Status> {
4633+
let req = request.into_inner();
4634+
let req: requests::ListcurrencyratesRequest = req.into();
4635+
debug!("Client asked for list_currency_rates");
4636+
trace!("list_currency_rates request: {:?}", req);
4637+
let mut rpc = ClnRpc::new(&self.rpc_path)
4638+
.await
4639+
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
4640+
let result = rpc.call(Request::ListCurrencyRates(req))
4641+
.await
4642+
.map_err(|e| Status::new(
4643+
Code::Unknown,
4644+
format!("Error calling method ListCurrencyRates: {:?}", e)))?;
4645+
match result {
4646+
Response::ListCurrencyRates(r) => {
4647+
trace!("list_currency_rates response: {:?}", r);
4648+
Ok(tonic::Response::new(r.into()))
4649+
},
4650+
r => Err(Status::new(
4651+
Code::Internal,
4652+
format!(
4653+
"Unexpected result {:?} to method call ListCurrencyRates",
4654+
r
4655+
)
4656+
)),
4657+
}
4658+
4659+
}
4660+
4661+
async fn currency_convert(
4662+
&self,
4663+
request: tonic::Request<pb::CurrencyconvertRequest>,
4664+
) -> Result<tonic::Response<pb::CurrencyconvertResponse>, tonic::Status> {
4665+
let req = request.into_inner();
4666+
let req: requests::CurrencyconvertRequest = req.into();
4667+
debug!("Client asked for currency_convert");
4668+
trace!("currency_convert request: {:?}", req);
4669+
let mut rpc = ClnRpc::new(&self.rpc_path)
4670+
.await
4671+
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
4672+
let result = rpc.call(Request::CurrencyConvert(req))
4673+
.await
4674+
.map_err(|e| Status::new(
4675+
Code::Unknown,
4676+
format!("Error calling method CurrencyConvert: {:?}", e)))?;
4677+
match result {
4678+
Response::CurrencyConvert(r) => {
4679+
trace!("currency_convert response: {:?}", r);
4680+
Ok(tonic::Response::new(r.into()))
4681+
},
4682+
r => Err(Status::new(
4683+
Code::Internal,
4684+
format!(
4685+
"Unexpected result {:?} to method call CurrencyConvert",
4686+
r
4687+
)
4688+
)),
4689+
}
4690+
4691+
}
4692+
4693+
async fn currency_rate(
4694+
&self,
4695+
request: tonic::Request<pb::CurrencyrateRequest>,
4696+
) -> Result<tonic::Response<pb::CurrencyrateResponse>, tonic::Status> {
4697+
let req = request.into_inner();
4698+
let req: requests::CurrencyrateRequest = req.into();
4699+
debug!("Client asked for currency_rate");
4700+
trace!("currency_rate request: {:?}", req);
4701+
let mut rpc = ClnRpc::new(&self.rpc_path)
4702+
.await
4703+
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
4704+
let result = rpc.call(Request::CurrencyRate(req))
4705+
.await
4706+
.map_err(|e| Status::new(
4707+
Code::Unknown,
4708+
format!("Error calling method CurrencyRate: {:?}", e)))?;
4709+
match result {
4710+
Response::CurrencyRate(r) => {
4711+
trace!("currency_rate response: {:?}", r);
4712+
Ok(tonic::Response::new(r.into()))
4713+
},
4714+
r => Err(Status::new(
4715+
Code::Internal,
4716+
format!(
4717+
"Unexpected result {:?} to method call CurrencyRate",
4718+
r
4719+
)
4720+
)),
4721+
}
4722+
4723+
}
4724+
46294725

46304726

46314727
type SubscribeBlockAddedStream = NotificationStream<pb::BlockAddedNotification>;

0 commit comments

Comments
 (0)