Skip to content

Commit 936ec30

Browse files
committed
Add fee_paid_msat in Payment.
1 parent 4ba7fdd commit 936ec30

File tree

3 files changed

+41
-14
lines changed

3 files changed

+41
-14
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ message Payment {
1313
// The amount transferred.
1414
optional uint64 amount_msat = 3;
1515

16+
// The fees that were paid for this payment.
17+
//
18+
// For Lightning payments, this will only be updated for outbound payments once they
19+
// succeeded.
20+
optional uint64 fee_paid_msat = 7;
21+
1622
// The direction of the payment.
1723
PaymentDirection direction = 4;
1824

ldk-server-protos/src/types.rs

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ pub struct Payment {
1212
/// The amount transferred.
1313
#[prost(uint64, optional, tag = "3")]
1414
pub amount_msat: ::core::option::Option<u64>,
15+
/// The fees that were paid for this payment.
16+
///
17+
/// For Lightning payments, this will only be updated for outbound payments once they
18+
/// succeeded.
19+
#[prost(uint64, optional, tag = "7")]
20+
pub fee_paid_msat: ::core::option::Option<u64>,
1521
/// The direction of the payment.
1622
#[prost(enumeration = "PaymentDirection", tag = "4")]
1723
pub direction: i32,

ldk-server/src/util/proto_adapter.rs

+29-14
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,37 @@ pub(crate) fn channel_config_to_proto(
9696
}
9797

9898
pub(crate) fn payment_to_proto(payment: PaymentDetails) -> Payment {
99-
Payment {
100-
id: payment.id.0.to_lower_hex_string(),
101-
kind: Some(payment_kind_to_proto(payment.kind)),
102-
amount_msat: payment.amount_msat,
103-
direction: match payment.direction {
104-
PaymentDirection::Inbound => ldk_server_protos::types::PaymentDirection::Inbound.into(),
105-
PaymentDirection::Outbound => {
106-
ldk_server_protos::types::PaymentDirection::Outbound.into()
99+
match payment {
100+
PaymentDetails {
101+
id,
102+
kind,
103+
amount_msat,
104+
fee_paid_msat,
105+
direction,
106+
status,
107+
latest_update_timestamp,
108+
} => Payment {
109+
id: id.to_string(),
110+
kind: Some(payment_kind_to_proto(kind)),
111+
amount_msat,
112+
fee_paid_msat,
113+
direction: match direction {
114+
PaymentDirection::Inbound => {
115+
ldk_server_protos::types::PaymentDirection::Inbound.into()
116+
},
117+
PaymentDirection::Outbound => {
118+
ldk_server_protos::types::PaymentDirection::Outbound.into()
119+
},
107120
},
121+
status: match status {
122+
PaymentStatus::Pending => ldk_server_protos::types::PaymentStatus::Pending.into(),
123+
PaymentStatus::Succeeded => {
124+
ldk_server_protos::types::PaymentStatus::Succeeded.into()
125+
},
126+
PaymentStatus::Failed => ldk_server_protos::types::PaymentStatus::Failed.into(),
127+
},
128+
latest_update_timestamp,
108129
},
109-
status: match payment.status {
110-
PaymentStatus::Pending => ldk_server_protos::types::PaymentStatus::Pending.into(),
111-
PaymentStatus::Succeeded => ldk_server_protos::types::PaymentStatus::Succeeded.into(),
112-
PaymentStatus::Failed => ldk_server_protos::types::PaymentStatus::Failed.into(),
113-
},
114-
latest_update_timestamp: payment.latest_update_timestamp,
115130
}
116131
}
117132

0 commit comments

Comments
 (0)