Skip to content

Commit a4ade5c

Browse files
authored
Merge pull request #59 from G8XSU/25-3-20-fee-info
Add fee_paid_msat in Payment.
2 parents 1f22a54 + 936ec30 commit a4ade5c

File tree

6 files changed

+44
-17
lines changed

6 files changed

+44
-17
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "6de350040e0fc5eb9cfcd15fad3919f5a79b82b9" }
7+
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "f0338d19256615088fabab2b6927d478ae3ec1a1" }
88
serde = { version = "1.0.203", default-features = false, features = ["derive"] }
99
serde_json = { version = "1.0.118", default-features = false }
1010
hyper = { version = "1", default-features = false, features = ["server", "http1"] }

ldk-server/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn main() {
7070
ldk_node_config.network = config_file.network;
7171

7272
let mut builder = Builder::from_config(ldk_node_config);
73-
builder.set_log_facade_logger(Some(LogLevel::Trace));
73+
builder.set_log_facade_logger();
7474

7575
let bitcoind_rpc_addr = config_file.bitcoind_rpc_addr;
7676

ldk-server/src/util/proto_adapter.rs

Lines changed: 29 additions & 14 deletions
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)