Skip to content

Commit 25c0e70

Browse files
committed
Add proto definition for ListForwardedPayments API.
1 parent ae1deb1 commit 25c0e70

File tree

4 files changed

+178
-0
lines changed

4 files changed

+178
-0
lines changed

ldk-server-protos/src/api.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,44 @@ pub struct ListPaymentsResponse {
337337
#[prost(message, repeated, tag = "1")]
338338
pub payments: ::prost::alloc::vec::Vec<super::types::Payment>,
339339
}
340+
/// Retrieves list of all forwarded payments.
341+
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
342+
#[allow(clippy::derive_partial_eq_without_eq)]
343+
#[derive(Clone, PartialEq, ::prost::Message)]
344+
pub struct ListForwardedPaymentsRequest {
345+
/// `page_token` is a pagination token.
346+
///
347+
/// To query for the first page, `page_token` must not be specified.
348+
///
349+
/// For subsequent pages, use the value that was returned as `next_page_token` in the previous
350+
/// page's response.
351+
#[prost(message, optional, tag = "1")]
352+
pub page_token: ::core::option::Option<super::types::PageToken>,
353+
}
354+
/// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
355+
/// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
356+
#[allow(clippy::derive_partial_eq_without_eq)]
357+
#[derive(Clone, PartialEq, ::prost::Message)]
358+
pub struct ListForwardedPaymentsResponse {
359+
/// List of forwarded payments.
360+
#[prost(message, repeated, tag = "1")]
361+
pub forwarded_payments: ::prost::alloc::vec::Vec<super::types::ForwardedPayment>,
362+
/// `next_page_token` is a pagination token, used to retrieve the next page of results.
363+
/// Use this value to query for next-page of paginated operation, by specifying
364+
/// this value as the `page_token` in the next request.
365+
///
366+
/// If `next_page_token` is `None`, then the "last page" of results has been processed and
367+
/// there is no more data to be retrieved.
368+
///
369+
/// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
370+
/// result set. The only way to know when you have reached the end of the result set is when
371+
/// `next_page_token` is `None`.
372+
///
373+
/// **Caution**: Clients must not assume a specific number of records to be present in a page for
374+
/// paginated response.
375+
#[prost(message, optional, tag = "2")]
376+
pub next_page_token: ::core::option::Option<super::types::PageToken>,
377+
}
340378
/// Retrieves an overview of all known balances.
341379
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances>
342380
#[allow(clippy::derive_partial_eq_without_eq)]

ldk-server-protos/src/proto/api.proto

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,40 @@ message ListPaymentsResponse {
319319
repeated types.Payment payments = 1;
320320
}
321321

322+
// Retrieves list of all forwarded payments.
323+
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
324+
message ListForwardedPaymentsRequest {
325+
// `page_token` is a pagination token.
326+
//
327+
// To query for the first page, `page_token` must not be specified.
328+
//
329+
// For subsequent pages, use the value that was returned as `next_page_token` in the previous
330+
// page's response.
331+
optional types.PageToken page_token = 1;
332+
}
333+
334+
// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
335+
// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
336+
message ListForwardedPaymentsResponse {
337+
// List of forwarded payments.
338+
repeated types.ForwardedPayment forwarded_payments = 1;
339+
340+
// `next_page_token` is a pagination token, used to retrieve the next page of results.
341+
// Use this value to query for next-page of paginated operation, by specifying
342+
// this value as the `page_token` in the next request.
343+
//
344+
// If `next_page_token` is `None`, then the "last page" of results has been processed and
345+
// there is no more data to be retrieved.
346+
//
347+
// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
348+
// result set. The only way to know when you have reached the end of the result set is when
349+
// `next_page_token` is `None`.
350+
//
351+
// **Caution**: Clients must not assume a specific number of records to be present in a page for
352+
// paginated response.
353+
optional types.PageToken next_page_token = 2;
354+
}
355+
322356
// Retrieves an overview of all known balances.
323357
// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances
324358
message GetBalancesRequest {}

ldk-server-protos/src/proto/types.proto

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,51 @@ enum PaymentStatus {
161161
FAILED = 2;
162162
}
163163

164+
// A forwarded payment through our node.
165+
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
166+
message ForwardedPayment{
167+
// The channel id of the incoming channel between the previous node and us.
168+
string prev_channel_id = 1;
169+
170+
// The channel id of the outgoing channel between the next node and us.
171+
string next_channel_id = 2;
172+
173+
// The `user_channel_id` of the incoming channel between the previous node and us.
174+
string prev_user_channel_id = 3;
175+
176+
// The `user_channel_id` of the outgoing channel between the next node and us.
177+
// This will be `None` if the payment was settled via an on-chain transaction.
178+
// See the caveat described for the `total_fee_earned_msat` field.
179+
optional string next_user_channel_id = 4;
180+
181+
// The total fee, in milli-satoshis, which was earned as a result of the payment.
182+
//
183+
// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
184+
// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
185+
// higher than expected as we still claimed the full value in millisatoshis from the source.
186+
// In this case, `claim_from_onchain_tx` will be set.
187+
//
188+
// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
189+
// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
190+
optional uint64 total_fee_earned_msat = 5;
191+
192+
// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
193+
// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
194+
// counterparty accepted to receive less than the invoice amount.
195+
//
196+
// The caveat described above the `total_fee_earned_msat` field applies here as well.
197+
optional uint64 skimmed_fee_msat = 6;
198+
199+
// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
200+
bool claim_from_onchain_tx = 7;
201+
202+
// The final amount forwarded, in milli-satoshis, after the fee is deducted.
203+
//
204+
// The caveat described above the `total_fee_earned_msat` field applies here as well.
205+
optional uint64 outbound_amount_forwarded_msat = 8;
206+
207+
}
208+
164209
message Channel {
165210
// The channel ID (prior to funding transaction generation, this is a random 32-byte
166211
// identifier, afterwards this is the transaction ID of the funding transaction XOR the
@@ -579,3 +624,9 @@ message AwaitingThresholdConfirmations {
579624
// The amount, in satoshis, of the output being swept.
580625
uint64 amount_satoshis = 5;
581626
}
627+
628+
// Token used to determine start of next page in paginated APIs.
629+
message PageToken {
630+
string token = 1;
631+
int64 index = 2;
632+
}

ldk-server-protos/src/types.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,52 @@ pub struct LspFeeLimits {
165165
#[prost(uint64, optional, tag = "2")]
166166
pub max_proportional_opening_fee_ppm_msat: ::core::option::Option<u64>,
167167
}
168+
/// A forwarded payment through our node.
169+
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
170+
#[allow(clippy::derive_partial_eq_without_eq)]
171+
#[derive(Clone, PartialEq, ::prost::Message)]
172+
pub struct ForwardedPayment {
173+
/// The channel id of the incoming channel between the previous node and us.
174+
#[prost(string, tag = "1")]
175+
pub prev_channel_id: ::prost::alloc::string::String,
176+
/// The channel id of the outgoing channel between the next node and us.
177+
#[prost(string, tag = "2")]
178+
pub next_channel_id: ::prost::alloc::string::String,
179+
/// The `user_channel_id` of the incoming channel between the previous node and us.
180+
#[prost(string, tag = "3")]
181+
pub prev_user_channel_id: ::prost::alloc::string::String,
182+
/// The `user_channel_id` of the outgoing channel between the next node and us.
183+
/// This will be `None` if the payment was settled via an on-chain transaction.
184+
/// See the caveat described for the `total_fee_earned_msat` field.
185+
#[prost(string, optional, tag = "4")]
186+
pub next_user_channel_id: ::core::option::Option<::prost::alloc::string::String>,
187+
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
188+
///
189+
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
190+
/// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
191+
/// higher than expected as we still claimed the full value in millisatoshis from the source.
192+
/// In this case, `claim_from_onchain_tx` will be set.
193+
///
194+
/// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
195+
/// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
196+
#[prost(uint64, optional, tag = "5")]
197+
pub total_fee_earned_msat: ::core::option::Option<u64>,
198+
/// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
199+
/// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
200+
/// counterparty accepted to receive less than the invoice amount.
201+
///
202+
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
203+
#[prost(uint64, optional, tag = "6")]
204+
pub skimmed_fee_msat: ::core::option::Option<u64>,
205+
/// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
206+
#[prost(bool, tag = "7")]
207+
pub claim_from_onchain_tx: bool,
208+
/// The final amount forwarded, in milli-satoshis, after the fee is deducted.
209+
///
210+
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
211+
#[prost(uint64, optional, tag = "8")]
212+
pub outbound_amount_forwarded_msat: ::core::option::Option<u64>,
213+
}
168214
#[allow(clippy::derive_partial_eq_without_eq)]
169215
#[derive(Clone, PartialEq, ::prost::Message)]
170216
pub struct Channel {
@@ -647,6 +693,15 @@ pub struct AwaitingThresholdConfirmations {
647693
#[prost(uint64, tag = "5")]
648694
pub amount_satoshis: u64,
649695
}
696+
/// Token used to determine start of next page in paginated APIs.
697+
#[allow(clippy::derive_partial_eq_without_eq)]
698+
#[derive(Clone, PartialEq, ::prost::Message)]
699+
pub struct PageToken {
700+
#[prost(string, tag = "1")]
701+
pub token: ::prost::alloc::string::String,
702+
#[prost(int64, tag = "2")]
703+
pub index: i64,
704+
}
650705
/// Represents the direction of a payment.
651706
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
652707
#[repr(i32)]

0 commit comments

Comments
 (0)