Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fee_paid_msat in Payment. #59

Merged
merged 2 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ message Payment {
// The amount transferred.
optional uint64 amount_msat = 3;

// The fees that were paid for this payment.
//
// For Lightning payments, this will only be updated for outbound payments once they
// succeeded.
optional uint64 fee_paid_msat = 7;

// The direction of the payment.
PaymentDirection direction = 4;

Expand Down
6 changes: 6 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ pub struct Payment {
/// The amount transferred.
#[prost(uint64, optional, tag = "3")]
pub amount_msat: ::core::option::Option<u64>,
/// The fees that were paid for this payment.
///
/// For Lightning payments, this will only be updated for outbound payments once they
/// succeeded.
#[prost(uint64, optional, tag = "7")]
pub fee_paid_msat: ::core::option::Option<u64>,
/// The direction of the payment.
#[prost(enumeration = "PaymentDirection", tag = "4")]
pub direction: i32,
Expand Down
2 changes: 1 addition & 1 deletion ldk-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "6de350040e0fc5eb9cfcd15fad3919f5a79b82b9" }
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "f0338d19256615088fabab2b6927d478ae3ec1a1" }
serde = { version = "1.0.203", default-features = false, features = ["derive"] }
serde_json = { version = "1.0.118", default-features = false }
hyper = { version = "1", default-features = false, features = ["server", "http1"] }
Expand Down
2 changes: 1 addition & 1 deletion ldk-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn main() {
ldk_node_config.network = config_file.network;

let mut builder = Builder::from_config(ldk_node_config);
builder.set_log_facade_logger(Some(LogLevel::Trace));
builder.set_log_facade_logger();

let bitcoind_rpc_addr = config_file.bitcoind_rpc_addr;

Expand Down
43 changes: 29 additions & 14 deletions ldk-server/src/util/proto_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,37 @@ pub(crate) fn channel_config_to_proto(
}

pub(crate) fn payment_to_proto(payment: PaymentDetails) -> Payment {
Payment {
id: payment.id.0.to_lower_hex_string(),
kind: Some(payment_kind_to_proto(payment.kind)),
amount_msat: payment.amount_msat,
direction: match payment.direction {
PaymentDirection::Inbound => ldk_server_protos::types::PaymentDirection::Inbound.into(),
PaymentDirection::Outbound => {
ldk_server_protos::types::PaymentDirection::Outbound.into()
match payment {
PaymentDetails {
id,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using a match statement, so that new fields added to payment_details cause a build failure and we can decide whether to ignore them or not.

kind,
amount_msat,
fee_paid_msat,
direction,
status,
latest_update_timestamp,
} => Payment {
id: id.to_string(),
kind: Some(payment_kind_to_proto(kind)),
amount_msat,
fee_paid_msat,
direction: match direction {
PaymentDirection::Inbound => {
ldk_server_protos::types::PaymentDirection::Inbound.into()
},
PaymentDirection::Outbound => {
ldk_server_protos::types::PaymentDirection::Outbound.into()
},
},
status: match status {
PaymentStatus::Pending => ldk_server_protos::types::PaymentStatus::Pending.into(),
PaymentStatus::Succeeded => {
ldk_server_protos::types::PaymentStatus::Succeeded.into()
},
PaymentStatus::Failed => ldk_server_protos::types::PaymentStatus::Failed.into(),
},
latest_update_timestamp,
},
status: match payment.status {
PaymentStatus::Pending => ldk_server_protos::types::PaymentStatus::Pending.into(),
PaymentStatus::Succeeded => ldk_server_protos::types::PaymentStatus::Succeeded.into(),
PaymentStatus::Failed => ldk_server_protos::types::PaymentStatus::Failed.into(),
},
latest_update_timestamp: payment.latest_update_timestamp,
}
}

Expand Down