Skip to content

Commit 5e62634

Browse files
Lagrang3rustyrussell
authored andcommitted
xpay: add sendamount command
Changelog-Added: sendamount command, to make a payment specifying the desired amount to send instead of the amount to be received. Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
1 parent 820303d commit 5e62634

16 files changed

Lines changed: 987 additions & 159 deletions

File tree

‎.msggen.json‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3876,6 +3876,23 @@
38763876
"sendpay_success.status": 12,
38773877
"sendpay_success.updated_index": 5
38783878
},
3879+
"SendamountRequest": {
3880+
"SendAmount.amount_msat": 2,
3881+
"SendAmount.invstring": 1,
3882+
"SendAmount.label": 8,
3883+
"SendAmount.layers[]": 4,
3884+
"SendAmount.maxdelay": 6,
3885+
"SendAmount.maxfee": 3,
3886+
"SendAmount.payer_note": 7,
3887+
"SendAmount.retry_for": 5
3888+
},
3889+
"SendamountResponse": {
3890+
"SendAmount.amount_msat": 4,
3891+
"SendAmount.amount_sent_msat": 5,
3892+
"SendAmount.failed_parts": 2,
3893+
"SendAmount.payment_preimage": 1,
3894+
"SendAmount.successful_parts": 3
3895+
},
38793896
"SendcustommsgRequest": {
38803897
"SendCustomMsg.msg": 2,
38813898
"SendCustomMsg.node_id": 1
@@ -13315,6 +13332,58 @@
1331513332
"added": "pre-v0.10.1",
1331613333
"deprecated": null
1331713334
},
13335+
"SendAmount": {
13336+
"added": "v26.06",
13337+
"deprecated": null
13338+
},
13339+
"SendAmount.amount_msat": {
13340+
"added": "v26.06",
13341+
"deprecated": null
13342+
},
13343+
"SendAmount.amount_sent_msat": {
13344+
"added": "v26.06",
13345+
"deprecated": null
13346+
},
13347+
"SendAmount.failed_parts": {
13348+
"added": "v26.06",
13349+
"deprecated": null
13350+
},
13351+
"SendAmount.invstring": {
13352+
"added": "v26.06",
13353+
"deprecated": null
13354+
},
13355+
"SendAmount.label": {
13356+
"added": "v26.06",
13357+
"deprecated": null
13358+
},
13359+
"SendAmount.layers[]": {
13360+
"added": "v26.06",
13361+
"deprecated": null
13362+
},
13363+
"SendAmount.maxdelay": {
13364+
"added": "v26.06",
13365+
"deprecated": null
13366+
},
13367+
"SendAmount.maxfee": {
13368+
"added": "v26.06",
13369+
"deprecated": null
13370+
},
13371+
"SendAmount.payer_note": {
13372+
"added": "v26.06",
13373+
"deprecated": null
13374+
},
13375+
"SendAmount.payment_preimage": {
13376+
"added": "v26.06",
13377+
"deprecated": null
13378+
},
13379+
"SendAmount.retry_for": {
13380+
"added": "v26.06",
13381+
"deprecated": null
13382+
},
13383+
"SendAmount.successful_parts": {
13384+
"added": "v26.06",
13385+
"deprecated": null
13386+
},
1331813387
"SendCustomMsg": {
1331913388
"added": "v0.10.1",
1332013389
"deprecated": null

‎cln-grpc/proto/node.proto‎

Lines changed: 20 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: 46 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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4850,6 +4850,38 @@ impl Node for Server
48504850

48514851
}
48524852

4853+
async fn send_amount(
4854+
&self,
4855+
request: tonic::Request<pb::SendamountRequest>,
4856+
) -> Result<tonic::Response<pb::SendamountResponse>, tonic::Status> {
4857+
let req = request.into_inner();
4858+
let req: requests::SendamountRequest = req.into();
4859+
debug!("Client asked for send_amount");
4860+
trace!("send_amount request: {:?}", req);
4861+
let mut rpc = ClnRpc::new(&self.rpc_path)
4862+
.await
4863+
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
4864+
let result = rpc.call(Request::SendAmount(req))
4865+
.await
4866+
.map_err(|e| Status::new(
4867+
Code::Unknown,
4868+
format!("Error calling method SendAmount: {:?}", e)))?;
4869+
match result {
4870+
Response::SendAmount(r) => {
4871+
trace!("send_amount response: {:?}", r);
4872+
Ok(tonic::Response::new(r.into()))
4873+
},
4874+
r => Err(Status::new(
4875+
Code::Internal,
4876+
format!(
4877+
"Unexpected result {:?} to method call SendAmount",
4878+
r
4879+
)
4880+
)),
4881+
}
4882+
4883+
}
4884+
48534885

48544886

48554887
type SubscribeBalanceSnapshotStream = NotificationStream<pb::BalanceSnapshotNotification>;

‎cln-rpc/src/model.rs‎

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

0 commit comments

Comments
 (0)