Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,6 @@ jobs:
- name: Pin packages to allow for MSRV
if: matrix.msrv
run: |
cargo update -p hashlink --precise "0.8.2" --verbose # hashlink 0.8.3 requires hashbrown 0.14, requiring 1.64.0
cargo update -p regex --precise "1.9.6" --verbose # regex 1.10.0 requires rustc 1.65.0
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9 requires rustc 1.70 or newer
cargo update -p tokio --precise "1.38.1" --verbose # tokio v1.39.0 requires rustc 1.70 or newer
Expand Down
52 changes: 15 additions & 37 deletions Cargo.lock

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

38 changes: 38 additions & 0 deletions ldk-server-protos/src/api.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,6 +337,44 @@ pub struct ListPaymentsResponse {
#[prost(message, repeated, tag = "1")]
pub payments: ::prost::alloc::vec::Vec<super::types::Payment>,
}
/// Retrieves list of all forwarded payments.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsRequest {
/// `page_token` is a pagination token.
///
/// To query for the first page, `page_token` must not be specified.
///
/// For subsequent pages, use the value that was returned as `next_page_token` in the previous
/// page's response.
#[prost(message, optional, tag = "1")]
pub page_token: ::core::option::Option<super::types::PageToken>,
}
/// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
/// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsResponse {
/// List of forwarded payments.
#[prost(message, repeated, tag = "1")]
pub forwarded_payments: ::prost::alloc::vec::Vec<super::types::ForwardedPayment>,
/// `next_page_token` is a pagination token, used to retrieve the next page of results.
/// Use this value to query for next-page of paginated operation, by specifying
/// this value as the `page_token` in the next request.
///
/// If `next_page_token` is `None`, then the "last page" of results has been processed and
/// there is no more data to be retrieved.
///
/// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
/// result set. The only way to know when you have reached the end of the result set is when
/// `next_page_token` is `None`.
///
/// **Caution**: Clients must not assume a specific number of records to be present in a page for
/// paginated response.
#[prost(message, optional, tag = "2")]
pub next_page_token: ::core::option::Option<super::types::PageToken>,
}
/// Retrieves an overview of all known balances.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances>
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
34 changes: 34 additions & 0 deletions ldk-server-protos/src/proto/api.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,40 @@ message ListPaymentsResponse {
repeated types.Payment payments = 1;
}

// Retrieves list of all forwarded payments.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ListForwardedPaymentsRequest {
// `page_token` is a pagination token.
//
// To query for the first page, `page_token` must not be specified.
//
// For subsequent pages, use the value that was returned as `next_page_token` in the previous
// page's response.
optional types.PageToken page_token = 1;
}

// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
message ListForwardedPaymentsResponse {
// List of forwarded payments.
repeated types.ForwardedPayment forwarded_payments = 1;

// `next_page_token` is a pagination token, used to retrieve the next page of results.
// Use this value to query for next-page of paginated operation, by specifying
// this value as the `page_token` in the next request.
//
// If `next_page_token` is `None`, then the "last page" of results has been processed and
// there is no more data to be retrieved.
//
// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
// result set. The only way to know when you have reached the end of the result set is when
// `next_page_token` is `None`.
//
// **Caution**: Clients must not assume a specific number of records to be present in a page for
// paginated response.
optional types.PageToken next_page_token = 2;
}

// Retrieves an overview of all known balances.
// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances
message GetBalancesRequest {}
Expand Down
51 changes: 51 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,6 +161,51 @@ enum PaymentStatus {
FAILED = 2;
}

// A forwarded payment through our node.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ForwardedPayment{
// The channel id of the incoming channel between the previous node and us.
string prev_channel_id = 1;

// The channel id of the outgoing channel between the next node and us.
string next_channel_id = 2;

// The `user_channel_id` of the incoming channel between the previous node and us.
string prev_user_channel_id = 3;

// The `user_channel_id` of the outgoing channel between the next node and us.
// This will be `None` if the payment was settled via an on-chain transaction.
// See the caveat described for the `total_fee_earned_msat` field.
optional string next_user_channel_id = 4;

// The total fee, in milli-satoshis, which was earned as a result of the payment.
//
// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
// higher than expected as we still claimed the full value in millisatoshis from the source.
// In this case, `claim_from_onchain_tx` will be set.
//
// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
optional uint64 total_fee_earned_msat = 5;

// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
// counterparty accepted to receive less than the invoice amount.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 skimmed_fee_msat = 6;

// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
bool claim_from_onchain_tx = 7;

// The final amount forwarded, in milli-satoshis, after the fee is deducted.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 outbound_amount_forwarded_msat = 8;

}

message Channel {
// The channel ID (prior to funding transaction generation, this is a random 32-byte
// identifier, afterwards this is the transaction ID of the funding transaction XOR the
Expand DownExpand Up@@ -579,3 +624,9 @@ message AwaitingThresholdConfirmations {
// The amount, in satoshis, of the output being swept.
uint64 amount_satoshis = 5;
}

// Token used to determine start of next page in paginated APIs.
message PageToken {
string token = 1;
int64 index = 2;
}
55 changes: 55 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,6 +165,52 @@ pub struct LspFeeLimits {
#[prost(uint64, optional, tag = "2")]
pub max_proportional_opening_fee_ppm_msat: ::core::option::Option<u64>,
}
/// A forwarded payment through our node.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardedPayment {
/// The channel id of the incoming channel between the previous node and us.
#[prost(string, tag = "1")]
pub prev_channel_id: ::prost::alloc::string::String,
/// The channel id of the outgoing channel between the next node and us.
#[prost(string, tag = "2")]
pub next_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the incoming channel between the previous node and us.
#[prost(string, tag = "3")]
pub prev_user_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the outgoing channel between the next node and us.
/// This will be `None` if the payment was settled via an on-chain transaction.
/// See the caveat described for the `total_fee_earned_msat` field.
#[prost(string, optional, tag = "4")]
pub next_user_channel_id: ::core::option::Option<::prost::alloc::string::String>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
/// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
/// higher than expected as we still claimed the full value in millisatoshis from the source.
/// In this case, `claim_from_onchain_tx` will be set.
///
/// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
/// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
#[prost(uint64, optional, tag = "5")]
pub total_fee_earned_msat: ::core::option::Option<u64>,
/// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
/// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
/// counterparty accepted to receive less than the invoice amount.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "6")]
pub skimmed_fee_msat: ::core::option::Option<u64>,
/// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
#[prost(bool, tag = "7")]
pub claim_from_onchain_tx: bool,
/// The final amount forwarded, in milli-satoshis, after the fee is deducted.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "8")]
pub outbound_amount_forwarded_msat: ::core::option::Option<u64>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Channel {
Expand DownExpand Up@@ -647,6 +693,15 @@ pub struct AwaitingThresholdConfirmations {
#[prost(uint64, tag = "5")]
pub amount_satoshis: u64,
}
/// Token used to determine start of next page in paginated APIs.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PageToken {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub index: i64,
}
/// Represents the direction of a payment.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
Expand Down
6 changes: 2 additions & 4 deletions ldk-server/Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { version = "0.4.0", default-features = false }
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "2095d878be10923845bcdd1dd039ab0e670e723d" }
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 All@@ -15,7 +15,5 @@ prost = { version = "0.11.6", default-features = false, features = ["std"] }
ldk-server-protos = { path = "../ldk-server-protos" }
bytes = "1.4.0"
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
rusqlite = { version = "0.28.0", features = ["bundled"] }

[dev-dependencies]
rusqlite = { version = "0.31.0", features = ["bundled"] }
rand = "0.8.5"
16 changes: 9 additions & 7 deletions ldk-server/src/api/bolt11_receive.rs
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
use ldk_node::Node;
use crate::service::Context;
use ldk_server_protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse};
use std::sync::Arc;

pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";

pub(crate) fn handle_bolt11_receive_request(
node: Arc<Node>, request: Bolt11ReceiveRequest,
context: Context, request: Bolt11ReceiveRequest,
) -> Result<Bolt11ReceiveResponse, ldk_node::NodeError> {
let invoice = match request.amount_msat {
Some(amount_msat) => {
node.bolt11_payment().receive(amount_msat, &request.description, request.expiry_secs)?
},
None => node
Some(amount_msat) => context.node.bolt11_payment().receive(
amount_msat,
&request.description,
request.expiry_secs,
)?,
None => context
.node
.bolt11_payment()
.receive_variable_amount(&request.description, request.expiry_secs)?,
};
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Add Api impl for ListForwardedPayments. by G8XSU · Pull Request #32 · lightningdevkit/ldk-server · GitHub
Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,6 @@ jobs:
- name: Pin packages to allow for MSRV
if: matrix.msrv
run: |
cargo update -p hashlink --precise "0.8.2" --verbose # hashlink 0.8.3 requires hashbrown 0.14, requiring 1.64.0
cargo update -p regex --precise "1.9.6" --verbose # regex 1.10.0 requires rustc 1.65.0
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9 requires rustc 1.70 or newer
cargo update -p tokio --precise "1.38.1" --verbose # tokio v1.39.0 requires rustc 1.70 or newer
Expand Down
52 changes: 15 additions & 37 deletions Cargo.lock

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

38 changes: 38 additions & 0 deletions ldk-server-protos/src/api.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,6 +337,44 @@ pub struct ListPaymentsResponse {
#[prost(message, repeated, tag = "1")]
pub payments: ::prost::alloc::vec::Vec<super::types::Payment>,
}
/// Retrieves list of all forwarded payments.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsRequest {
/// `page_token` is a pagination token.
///
/// To query for the first page, `page_token` must not be specified.
///
/// For subsequent pages, use the value that was returned as `next_page_token` in the previous
/// page's response.
#[prost(message, optional, tag = "1")]
pub page_token: ::core::option::Option<super::types::PageToken>,
}
/// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
/// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsResponse {
/// List of forwarded payments.
#[prost(message, repeated, tag = "1")]
pub forwarded_payments: ::prost::alloc::vec::Vec<super::types::ForwardedPayment>,
/// `next_page_token` is a pagination token, used to retrieve the next page of results.
/// Use this value to query for next-page of paginated operation, by specifying
/// this value as the `page_token` in the next request.
///
/// If `next_page_token` is `None`, then the "last page" of results has been processed and
/// there is no more data to be retrieved.
///
/// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
/// result set. The only way to know when you have reached the end of the result set is when
/// `next_page_token` is `None`.
///
/// **Caution**: Clients must not assume a specific number of records to be present in a page for
/// paginated response.
#[prost(message, optional, tag = "2")]
pub next_page_token: ::core::option::Option<super::types::PageToken>,
}
/// Retrieves an overview of all known balances.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances>
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
34 changes: 34 additions & 0 deletions ldk-server-protos/src/proto/api.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,40 @@ message ListPaymentsResponse {
repeated types.Payment payments = 1;
}

// Retrieves list of all forwarded payments.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ListForwardedPaymentsRequest {
// `page_token` is a pagination token.
//
// To query for the first page, `page_token` must not be specified.
//
// For subsequent pages, use the value that was returned as `next_page_token` in the previous
// page's response.
optional types.PageToken page_token = 1;
}

// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
message ListForwardedPaymentsResponse {
// List of forwarded payments.
repeated types.ForwardedPayment forwarded_payments = 1;

// `next_page_token` is a pagination token, used to retrieve the next page of results.
// Use this value to query for next-page of paginated operation, by specifying
// this value as the `page_token` in the next request.
//
// If `next_page_token` is `None`, then the "last page" of results has been processed and
// there is no more data to be retrieved.
//
// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
// result set. The only way to know when you have reached the end of the result set is when
// `next_page_token` is `None`.
//
// **Caution**: Clients must not assume a specific number of records to be present in a page for
// paginated response.
optional types.PageToken next_page_token = 2;
}

// Retrieves an overview of all known balances.
// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances
message GetBalancesRequest {}
Expand Down
51 changes: 51 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,6 +161,51 @@ enum PaymentStatus {
FAILED = 2;
}

// A forwarded payment through our node.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ForwardedPayment{
// The channel id of the incoming channel between the previous node and us.
string prev_channel_id = 1;

// The channel id of the outgoing channel between the next node and us.
string next_channel_id = 2;

// The `user_channel_id` of the incoming channel between the previous node and us.
string prev_user_channel_id = 3;

// The `user_channel_id` of the outgoing channel between the next node and us.
// This will be `None` if the payment was settled via an on-chain transaction.
// See the caveat described for the `total_fee_earned_msat` field.
optional string next_user_channel_id = 4;

// The total fee, in milli-satoshis, which was earned as a result of the payment.
//
// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
// higher than expected as we still claimed the full value in millisatoshis from the source.
// In this case, `claim_from_onchain_tx` will be set.
//
// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
optional uint64 total_fee_earned_msat = 5;

// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
// counterparty accepted to receive less than the invoice amount.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 skimmed_fee_msat = 6;

// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
bool claim_from_onchain_tx = 7;

// The final amount forwarded, in milli-satoshis, after the fee is deducted.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 outbound_amount_forwarded_msat = 8;

}

message Channel {
// The channel ID (prior to funding transaction generation, this is a random 32-byte
// identifier, afterwards this is the transaction ID of the funding transaction XOR the
Expand DownExpand Up@@ -579,3 +624,9 @@ message AwaitingThresholdConfirmations {
// The amount, in satoshis, of the output being swept.
uint64 amount_satoshis = 5;
}

// Token used to determine start of next page in paginated APIs.
message PageToken {
string token = 1;
int64 index = 2;
}
55 changes: 55 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,6 +165,52 @@ pub struct LspFeeLimits {
#[prost(uint64, optional, tag = "2")]
pub max_proportional_opening_fee_ppm_msat: ::core::option::Option<u64>,
}
/// A forwarded payment through our node.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardedPayment {
/// The channel id of the incoming channel between the previous node and us.
#[prost(string, tag = "1")]
pub prev_channel_id: ::prost::alloc::string::String,
/// The channel id of the outgoing channel between the next node and us.
#[prost(string, tag = "2")]
pub next_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the incoming channel between the previous node and us.
#[prost(string, tag = "3")]
pub prev_user_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the outgoing channel between the next node and us.
/// This will be `None` if the payment was settled via an on-chain transaction.
/// See the caveat described for the `total_fee_earned_msat` field.
#[prost(string, optional, tag = "4")]
pub next_user_channel_id: ::core::option::Option<::prost::alloc::string::String>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
/// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
/// higher than expected as we still claimed the full value in millisatoshis from the source.
/// In this case, `claim_from_onchain_tx` will be set.
///
/// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
/// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
#[prost(uint64, optional, tag = "5")]
pub total_fee_earned_msat: ::core::option::Option<u64>,
/// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
/// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
/// counterparty accepted to receive less than the invoice amount.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "6")]
pub skimmed_fee_msat: ::core::option::Option<u64>,
/// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
#[prost(bool, tag = "7")]
pub claim_from_onchain_tx: bool,
/// The final amount forwarded, in milli-satoshis, after the fee is deducted.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "8")]
pub outbound_amount_forwarded_msat: ::core::option::Option<u64>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Channel {
Expand DownExpand Up@@ -647,6 +693,15 @@ pub struct AwaitingThresholdConfirmations {
#[prost(uint64, tag = "5")]
pub amount_satoshis: u64,
}
/// Token used to determine start of next page in paginated APIs.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PageToken {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub index: i64,
}
/// Represents the direction of a payment.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
Expand Down
6 changes: 2 additions & 4 deletions ldk-server/Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { version = "0.4.0", default-features = false }
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "2095d878be10923845bcdd1dd039ab0e670e723d" }
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 All@@ -15,7 +15,5 @@ prost = { version = "0.11.6", default-features = false, features = ["std"] }
ldk-server-protos = { path = "../ldk-server-protos" }
bytes = "1.4.0"
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
rusqlite = { version = "0.28.0", features = ["bundled"] }

[dev-dependencies]
rusqlite = { version = "0.31.0", features = ["bundled"] }
rand = "0.8.5"
16 changes: 9 additions & 7 deletions ldk-server/src/api/bolt11_receive.rs
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
use ldk_node::Node;
use crate::service::Context;
use ldk_server_protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse};
use std::sync::Arc;

pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";

pub(crate) fn handle_bolt11_receive_request(
node: Arc<Node>, request: Bolt11ReceiveRequest,
context: Context, request: Bolt11ReceiveRequest,
) -> Result<Bolt11ReceiveResponse, ldk_node::NodeError> {
let invoice = match request.amount_msat {
Some(amount_msat) => {
node.bolt11_payment().receive(amount_msat, &request.description, request.expiry_secs)?
},
None => node
Some(amount_msat) => context.node.bolt11_payment().receive(
amount_msat,
&request.description,
request.expiry_secs,
)?,
None => context
.node
.bolt11_payment()
.receive_variable_amount(&request.description, request.expiry_secs)?,
};
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add Api impl for ListForwardedPayments. by G8XSU · Pull Request #32 · lightningdevkit/ldk-server · GitHub
Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,6 @@ jobs:
- name: Pin packages to allow for MSRV
if: matrix.msrv
run: |
cargo update -p hashlink --precise "0.8.2" --verbose # hashlink 0.8.3 requires hashbrown 0.14, requiring 1.64.0
cargo update -p regex --precise "1.9.6" --verbose # regex 1.10.0 requires rustc 1.65.0
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9 requires rustc 1.70 or newer
cargo update -p tokio --precise "1.38.1" --verbose # tokio v1.39.0 requires rustc 1.70 or newer
Expand Down
52 changes: 15 additions & 37 deletions Cargo.lock

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

38 changes: 38 additions & 0 deletions ldk-server-protos/src/api.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,6 +337,44 @@ pub struct ListPaymentsResponse {
#[prost(message, repeated, tag = "1")]
pub payments: ::prost::alloc::vec::Vec<super::types::Payment>,
}
/// Retrieves list of all forwarded payments.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsRequest {
/// `page_token` is a pagination token.
///
/// To query for the first page, `page_token` must not be specified.
///
/// For subsequent pages, use the value that was returned as `next_page_token` in the previous
/// page's response.
#[prost(message, optional, tag = "1")]
pub page_token: ::core::option::Option<super::types::PageToken>,
}
/// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
/// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsResponse {
/// List of forwarded payments.
#[prost(message, repeated, tag = "1")]
pub forwarded_payments: ::prost::alloc::vec::Vec<super::types::ForwardedPayment>,
/// `next_page_token` is a pagination token, used to retrieve the next page of results.
/// Use this value to query for next-page of paginated operation, by specifying
/// this value as the `page_token` in the next request.
///
/// If `next_page_token` is `None`, then the "last page" of results has been processed and
/// there is no more data to be retrieved.
///
/// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
/// result set. The only way to know when you have reached the end of the result set is when
/// `next_page_token` is `None`.
///
/// **Caution**: Clients must not assume a specific number of records to be present in a page for
/// paginated response.
#[prost(message, optional, tag = "2")]
pub next_page_token: ::core::option::Option<super::types::PageToken>,
}
/// Retrieves an overview of all known balances.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances>
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
34 changes: 34 additions & 0 deletions ldk-server-protos/src/proto/api.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,40 @@ message ListPaymentsResponse {
repeated types.Payment payments = 1;
}

// Retrieves list of all forwarded payments.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ListForwardedPaymentsRequest {
// `page_token` is a pagination token.
//
// To query for the first page, `page_token` must not be specified.
//
// For subsequent pages, use the value that was returned as `next_page_token` in the previous
// page's response.
optional types.PageToken page_token = 1;
}

// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
message ListForwardedPaymentsResponse {
// List of forwarded payments.
repeated types.ForwardedPayment forwarded_payments = 1;

// `next_page_token` is a pagination token, used to retrieve the next page of results.
// Use this value to query for next-page of paginated operation, by specifying
// this value as the `page_token` in the next request.
//
// If `next_page_token` is `None`, then the "last page" of results has been processed and
// there is no more data to be retrieved.
//
// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
// result set. The only way to know when you have reached the end of the result set is when
// `next_page_token` is `None`.
//
// **Caution**: Clients must not assume a specific number of records to be present in a page for
// paginated response.
optional types.PageToken next_page_token = 2;
}

// Retrieves an overview of all known balances.
// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances
message GetBalancesRequest {}
Expand Down
51 changes: 51 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,6 +161,51 @@ enum PaymentStatus {
FAILED = 2;
}

// A forwarded payment through our node.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ForwardedPayment{
// The channel id of the incoming channel between the previous node and us.
string prev_channel_id = 1;

// The channel id of the outgoing channel between the next node and us.
string next_channel_id = 2;

// The `user_channel_id` of the incoming channel between the previous node and us.
string prev_user_channel_id = 3;

// The `user_channel_id` of the outgoing channel between the next node and us.
// This will be `None` if the payment was settled via an on-chain transaction.
// See the caveat described for the `total_fee_earned_msat` field.
optional string next_user_channel_id = 4;

// The total fee, in milli-satoshis, which was earned as a result of the payment.
//
// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
// higher than expected as we still claimed the full value in millisatoshis from the source.
// In this case, `claim_from_onchain_tx` will be set.
//
// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
optional uint64 total_fee_earned_msat = 5;

// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
// counterparty accepted to receive less than the invoice amount.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 skimmed_fee_msat = 6;

// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
bool claim_from_onchain_tx = 7;

// The final amount forwarded, in milli-satoshis, after the fee is deducted.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 outbound_amount_forwarded_msat = 8;

}

message Channel {
// The channel ID (prior to funding transaction generation, this is a random 32-byte
// identifier, afterwards this is the transaction ID of the funding transaction XOR the
Expand DownExpand Up@@ -579,3 +624,9 @@ message AwaitingThresholdConfirmations {
// The amount, in satoshis, of the output being swept.
uint64 amount_satoshis = 5;
}

// Token used to determine start of next page in paginated APIs.
message PageToken {
string token = 1;
int64 index = 2;
}
55 changes: 55 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,6 +165,52 @@ pub struct LspFeeLimits {
#[prost(uint64, optional, tag = "2")]
pub max_proportional_opening_fee_ppm_msat: ::core::option::Option<u64>,
}
/// A forwarded payment through our node.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardedPayment {
/// The channel id of the incoming channel between the previous node and us.
#[prost(string, tag = "1")]
pub prev_channel_id: ::prost::alloc::string::String,
/// The channel id of the outgoing channel between the next node and us.
#[prost(string, tag = "2")]
pub next_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the incoming channel between the previous node and us.
#[prost(string, tag = "3")]
pub prev_user_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the outgoing channel between the next node and us.
/// This will be `None` if the payment was settled via an on-chain transaction.
/// See the caveat described for the `total_fee_earned_msat` field.
#[prost(string, optional, tag = "4")]
pub next_user_channel_id: ::core::option::Option<::prost::alloc::string::String>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
/// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
/// higher than expected as we still claimed the full value in millisatoshis from the source.
/// In this case, `claim_from_onchain_tx` will be set.
///
/// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
/// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
#[prost(uint64, optional, tag = "5")]
pub total_fee_earned_msat: ::core::option::Option<u64>,
/// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
/// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
/// counterparty accepted to receive less than the invoice amount.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "6")]
pub skimmed_fee_msat: ::core::option::Option<u64>,
/// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
#[prost(bool, tag = "7")]
pub claim_from_onchain_tx: bool,
/// The final amount forwarded, in milli-satoshis, after the fee is deducted.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "8")]
pub outbound_amount_forwarded_msat: ::core::option::Option<u64>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Channel {
Expand DownExpand Up@@ -647,6 +693,15 @@ pub struct AwaitingThresholdConfirmations {
#[prost(uint64, tag = "5")]
pub amount_satoshis: u64,
}
/// Token used to determine start of next page in paginated APIs.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PageToken {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub index: i64,
}
/// Represents the direction of a payment.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
Expand Down
6 changes: 2 additions & 4 deletions ldk-server/Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { version = "0.4.0", default-features = false }
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "2095d878be10923845bcdd1dd039ab0e670e723d" }
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 All@@ -15,7 +15,5 @@ prost = { version = "0.11.6", default-features = false, features = ["std"] }
ldk-server-protos = { path = "../ldk-server-protos" }
bytes = "1.4.0"
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
rusqlite = { version = "0.28.0", features = ["bundled"] }

[dev-dependencies]
rusqlite = { version = "0.31.0", features = ["bundled"] }
rand = "0.8.5"
16 changes: 9 additions & 7 deletions ldk-server/src/api/bolt11_receive.rs
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
use ldk_node::Node;
use crate::service::Context;
use ldk_server_protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse};
use std::sync::Arc;

pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";

pub(crate) fn handle_bolt11_receive_request(
node: Arc<Node>, request: Bolt11ReceiveRequest,
context: Context, request: Bolt11ReceiveRequest,
) -> Result<Bolt11ReceiveResponse, ldk_node::NodeError> {
let invoice = match request.amount_msat {
Some(amount_msat) => {
node.bolt11_payment().receive(amount_msat, &request.description, request.expiry_secs)?
},
None => node
Some(amount_msat) => context.node.bolt11_payment().receive(
amount_msat,
&request.description,
request.expiry_secs,
)?,
None => context
.node
.bolt11_payment()
.receive_variable_amount(&request.description, request.expiry_secs)?,
};
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add Api impl for ListForwardedPayments. by G8XSU · Pull Request #32 · lightningdevkit/ldk-server · GitHub
Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,6 @@ jobs:
- name: Pin packages to allow for MSRV
if: matrix.msrv
run: |
cargo update -p hashlink --precise "0.8.2" --verbose # hashlink 0.8.3 requires hashbrown 0.14, requiring 1.64.0
cargo update -p regex --precise "1.9.6" --verbose # regex 1.10.0 requires rustc 1.65.0
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9 requires rustc 1.70 or newer
cargo update -p tokio --precise "1.38.1" --verbose # tokio v1.39.0 requires rustc 1.70 or newer
Expand Down
52 changes: 15 additions & 37 deletions Cargo.lock

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

38 changes: 38 additions & 0 deletions ldk-server-protos/src/api.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,6 +337,44 @@ pub struct ListPaymentsResponse {
#[prost(message, repeated, tag = "1")]
pub payments: ::prost::alloc::vec::Vec<super::types::Payment>,
}
/// Retrieves list of all forwarded payments.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsRequest {
/// `page_token` is a pagination token.
///
/// To query for the first page, `page_token` must not be specified.
///
/// For subsequent pages, use the value that was returned as `next_page_token` in the previous
/// page's response.
#[prost(message, optional, tag = "1")]
pub page_token: ::core::option::Option<super::types::PageToken>,
}
/// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
/// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsResponse {
/// List of forwarded payments.
#[prost(message, repeated, tag = "1")]
pub forwarded_payments: ::prost::alloc::vec::Vec<super::types::ForwardedPayment>,
/// `next_page_token` is a pagination token, used to retrieve the next page of results.
/// Use this value to query for next-page of paginated operation, by specifying
/// this value as the `page_token` in the next request.
///
/// If `next_page_token` is `None`, then the "last page" of results has been processed and
/// there is no more data to be retrieved.
///
/// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
/// result set. The only way to know when you have reached the end of the result set is when
/// `next_page_token` is `None`.
///
/// **Caution**: Clients must not assume a specific number of records to be present in a page for
/// paginated response.
#[prost(message, optional, tag = "2")]
pub next_page_token: ::core::option::Option<super::types::PageToken>,
}
/// Retrieves an overview of all known balances.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances>
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
34 changes: 34 additions & 0 deletions ldk-server-protos/src/proto/api.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,40 @@ message ListPaymentsResponse {
repeated types.Payment payments = 1;
}

// Retrieves list of all forwarded payments.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ListForwardedPaymentsRequest {
// `page_token` is a pagination token.
//
// To query for the first page, `page_token` must not be specified.
//
// For subsequent pages, use the value that was returned as `next_page_token` in the previous
// page's response.
optional types.PageToken page_token = 1;
}

// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
message ListForwardedPaymentsResponse {
// List of forwarded payments.
repeated types.ForwardedPayment forwarded_payments = 1;

// `next_page_token` is a pagination token, used to retrieve the next page of results.
// Use this value to query for next-page of paginated operation, by specifying
// this value as the `page_token` in the next request.
//
// If `next_page_token` is `None`, then the "last page" of results has been processed and
// there is no more data to be retrieved.
//
// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
// result set. The only way to know when you have reached the end of the result set is when
// `next_page_token` is `None`.
//
// **Caution**: Clients must not assume a specific number of records to be present in a page for
// paginated response.
optional types.PageToken next_page_token = 2;
}

// Retrieves an overview of all known balances.
// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances
message GetBalancesRequest {}
Expand Down
51 changes: 51 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,6 +161,51 @@ enum PaymentStatus {
FAILED = 2;
}

// A forwarded payment through our node.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ForwardedPayment{
// The channel id of the incoming channel between the previous node and us.
string prev_channel_id = 1;

// The channel id of the outgoing channel between the next node and us.
string next_channel_id = 2;

// The `user_channel_id` of the incoming channel between the previous node and us.
string prev_user_channel_id = 3;

// The `user_channel_id` of the outgoing channel between the next node and us.
// This will be `None` if the payment was settled via an on-chain transaction.
// See the caveat described for the `total_fee_earned_msat` field.
optional string next_user_channel_id = 4;

// The total fee, in milli-satoshis, which was earned as a result of the payment.
//
// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
// higher than expected as we still claimed the full value in millisatoshis from the source.
// In this case, `claim_from_onchain_tx` will be set.
//
// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
optional uint64 total_fee_earned_msat = 5;

// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
// counterparty accepted to receive less than the invoice amount.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 skimmed_fee_msat = 6;

// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
bool claim_from_onchain_tx = 7;

// The final amount forwarded, in milli-satoshis, after the fee is deducted.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 outbound_amount_forwarded_msat = 8;

}

message Channel {
// The channel ID (prior to funding transaction generation, this is a random 32-byte
// identifier, afterwards this is the transaction ID of the funding transaction XOR the
Expand DownExpand Up@@ -579,3 +624,9 @@ message AwaitingThresholdConfirmations {
// The amount, in satoshis, of the output being swept.
uint64 amount_satoshis = 5;
}

// Token used to determine start of next page in paginated APIs.
message PageToken {
string token = 1;
int64 index = 2;
}
55 changes: 55 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,6 +165,52 @@ pub struct LspFeeLimits {
#[prost(uint64, optional, tag = "2")]
pub max_proportional_opening_fee_ppm_msat: ::core::option::Option<u64>,
}
/// A forwarded payment through our node.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardedPayment {
/// The channel id of the incoming channel between the previous node and us.
#[prost(string, tag = "1")]
pub prev_channel_id: ::prost::alloc::string::String,
/// The channel id of the outgoing channel between the next node and us.
#[prost(string, tag = "2")]
pub next_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the incoming channel between the previous node and us.
#[prost(string, tag = "3")]
pub prev_user_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the outgoing channel between the next node and us.
/// This will be `None` if the payment was settled via an on-chain transaction.
/// See the caveat described for the `total_fee_earned_msat` field.
#[prost(string, optional, tag = "4")]
pub next_user_channel_id: ::core::option::Option<::prost::alloc::string::String>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
/// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
/// higher than expected as we still claimed the full value in millisatoshis from the source.
/// In this case, `claim_from_onchain_tx` will be set.
///
/// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
/// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
#[prost(uint64, optional, tag = "5")]
pub total_fee_earned_msat: ::core::option::Option<u64>,
/// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
/// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
/// counterparty accepted to receive less than the invoice amount.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "6")]
pub skimmed_fee_msat: ::core::option::Option<u64>,
/// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
#[prost(bool, tag = "7")]
pub claim_from_onchain_tx: bool,
/// The final amount forwarded, in milli-satoshis, after the fee is deducted.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "8")]
pub outbound_amount_forwarded_msat: ::core::option::Option<u64>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Channel {
Expand DownExpand Up@@ -647,6 +693,15 @@ pub struct AwaitingThresholdConfirmations {
#[prost(uint64, tag = "5")]
pub amount_satoshis: u64,
}
/// Token used to determine start of next page in paginated APIs.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PageToken {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub index: i64,
}
/// Represents the direction of a payment.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
Expand Down
6 changes: 2 additions & 4 deletions ldk-server/Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { version = "0.4.0", default-features = false }
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "2095d878be10923845bcdd1dd039ab0e670e723d" }
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 All@@ -15,7 +15,5 @@ prost = { version = "0.11.6", default-features = false, features = ["std"] }
ldk-server-protos = { path = "../ldk-server-protos" }
bytes = "1.4.0"
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
rusqlite = { version = "0.28.0", features = ["bundled"] }

[dev-dependencies]
rusqlite = { version = "0.31.0", features = ["bundled"] }
rand = "0.8.5"
16 changes: 9 additions & 7 deletions ldk-server/src/api/bolt11_receive.rs
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
use ldk_node::Node;
use crate::service::Context;
use ldk_server_protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse};
use std::sync::Arc;

pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";

pub(crate) fn handle_bolt11_receive_request(
node: Arc<Node>, request: Bolt11ReceiveRequest,
context: Context, request: Bolt11ReceiveRequest,
) -> Result<Bolt11ReceiveResponse, ldk_node::NodeError> {
let invoice = match request.amount_msat {
Some(amount_msat) => {
node.bolt11_payment().receive(amount_msat, &request.description, request.expiry_secs)?
},
None => node
Some(amount_msat) => context.node.bolt11_payment().receive(
amount_msat,
&request.description,
request.expiry_secs,
)?,
None => context
.node
.bolt11_payment()
.receive_variable_amount(&request.description, request.expiry_secs)?,
};
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Add Api impl for ListForwardedPayments. by G8XSU · Pull Request #32 · lightningdevkit/ldk-server · GitHub
Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,6 @@ jobs:
- name: Pin packages to allow for MSRV
if: matrix.msrv
run: |
cargo update -p hashlink --precise "0.8.2" --verbose # hashlink 0.8.3 requires hashbrown 0.14, requiring 1.64.0
cargo update -p regex --precise "1.9.6" --verbose # regex 1.10.0 requires rustc 1.65.0
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9 requires rustc 1.70 or newer
cargo update -p tokio --precise "1.38.1" --verbose # tokio v1.39.0 requires rustc 1.70 or newer
Expand Down
52 changes: 15 additions & 37 deletions Cargo.lock

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

38 changes: 38 additions & 0 deletions ldk-server-protos/src/api.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,6 +337,44 @@ pub struct ListPaymentsResponse {
#[prost(message, repeated, tag = "1")]
pub payments: ::prost::alloc::vec::Vec<super::types::Payment>,
}
/// Retrieves list of all forwarded payments.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsRequest {
/// `page_token` is a pagination token.
///
/// To query for the first page, `page_token` must not be specified.
///
/// For subsequent pages, use the value that was returned as `next_page_token` in the previous
/// page's response.
#[prost(message, optional, tag = "1")]
pub page_token: ::core::option::Option<super::types::PageToken>,
}
/// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
/// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsResponse {
/// List of forwarded payments.
#[prost(message, repeated, tag = "1")]
pub forwarded_payments: ::prost::alloc::vec::Vec<super::types::ForwardedPayment>,
/// `next_page_token` is a pagination token, used to retrieve the next page of results.
/// Use this value to query for next-page of paginated operation, by specifying
/// this value as the `page_token` in the next request.
///
/// If `next_page_token` is `None`, then the "last page" of results has been processed and
/// there is no more data to be retrieved.
///
/// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
/// result set. The only way to know when you have reached the end of the result set is when
/// `next_page_token` is `None`.
///
/// **Caution**: Clients must not assume a specific number of records to be present in a page for
/// paginated response.
#[prost(message, optional, tag = "2")]
pub next_page_token: ::core::option::Option<super::types::PageToken>,
}
/// Retrieves an overview of all known balances.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances>
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
34 changes: 34 additions & 0 deletions ldk-server-protos/src/proto/api.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,40 @@ message ListPaymentsResponse {
repeated types.Payment payments = 1;
}

// Retrieves list of all forwarded payments.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ListForwardedPaymentsRequest {
// `page_token` is a pagination token.
//
// To query for the first page, `page_token` must not be specified.
//
// For subsequent pages, use the value that was returned as `next_page_token` in the previous
// page's response.
optional types.PageToken page_token = 1;
}

// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
message ListForwardedPaymentsResponse {
// List of forwarded payments.
repeated types.ForwardedPayment forwarded_payments = 1;

// `next_page_token` is a pagination token, used to retrieve the next page of results.
// Use this value to query for next-page of paginated operation, by specifying
// this value as the `page_token` in the next request.
//
// If `next_page_token` is `None`, then the "last page" of results has been processed and
// there is no more data to be retrieved.
//
// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
// result set. The only way to know when you have reached the end of the result set is when
// `next_page_token` is `None`.
//
// **Caution**: Clients must not assume a specific number of records to be present in a page for
// paginated response.
optional types.PageToken next_page_token = 2;
}

// Retrieves an overview of all known balances.
// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances
message GetBalancesRequest {}
Expand Down
51 changes: 51 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,6 +161,51 @@ enum PaymentStatus {
FAILED = 2;
}

// A forwarded payment through our node.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ForwardedPayment{
// The channel id of the incoming channel between the previous node and us.
string prev_channel_id = 1;

// The channel id of the outgoing channel between the next node and us.
string next_channel_id = 2;

// The `user_channel_id` of the incoming channel between the previous node and us.
string prev_user_channel_id = 3;

// The `user_channel_id` of the outgoing channel between the next node and us.
// This will be `None` if the payment was settled via an on-chain transaction.
// See the caveat described for the `total_fee_earned_msat` field.
optional string next_user_channel_id = 4;

// The total fee, in milli-satoshis, which was earned as a result of the payment.
//
// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
// higher than expected as we still claimed the full value in millisatoshis from the source.
// In this case, `claim_from_onchain_tx` will be set.
//
// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
optional uint64 total_fee_earned_msat = 5;

// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
// counterparty accepted to receive less than the invoice amount.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 skimmed_fee_msat = 6;

// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
bool claim_from_onchain_tx = 7;

// The final amount forwarded, in milli-satoshis, after the fee is deducted.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 outbound_amount_forwarded_msat = 8;

}

message Channel {
// The channel ID (prior to funding transaction generation, this is a random 32-byte
// identifier, afterwards this is the transaction ID of the funding transaction XOR the
Expand DownExpand Up@@ -579,3 +624,9 @@ message AwaitingThresholdConfirmations {
// The amount, in satoshis, of the output being swept.
uint64 amount_satoshis = 5;
}

// Token used to determine start of next page in paginated APIs.
message PageToken {
string token = 1;
int64 index = 2;
}
55 changes: 55 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,6 +165,52 @@ pub struct LspFeeLimits {
#[prost(uint64, optional, tag = "2")]
pub max_proportional_opening_fee_ppm_msat: ::core::option::Option<u64>,
}
/// A forwarded payment through our node.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardedPayment {
/// The channel id of the incoming channel between the previous node and us.
#[prost(string, tag = "1")]
pub prev_channel_id: ::prost::alloc::string::String,
/// The channel id of the outgoing channel between the next node and us.
#[prost(string, tag = "2")]
pub next_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the incoming channel between the previous node and us.
#[prost(string, tag = "3")]
pub prev_user_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the outgoing channel between the next node and us.
/// This will be `None` if the payment was settled via an on-chain transaction.
/// See the caveat described for the `total_fee_earned_msat` field.
#[prost(string, optional, tag = "4")]
pub next_user_channel_id: ::core::option::Option<::prost::alloc::string::String>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
/// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
/// higher than expected as we still claimed the full value in millisatoshis from the source.
/// In this case, `claim_from_onchain_tx` will be set.
///
/// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
/// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
#[prost(uint64, optional, tag = "5")]
pub total_fee_earned_msat: ::core::option::Option<u64>,
/// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
/// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
/// counterparty accepted to receive less than the invoice amount.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "6")]
pub skimmed_fee_msat: ::core::option::Option<u64>,
/// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
#[prost(bool, tag = "7")]
pub claim_from_onchain_tx: bool,
/// The final amount forwarded, in milli-satoshis, after the fee is deducted.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "8")]
pub outbound_amount_forwarded_msat: ::core::option::Option<u64>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Channel {
Expand DownExpand Up@@ -647,6 +693,15 @@ pub struct AwaitingThresholdConfirmations {
#[prost(uint64, tag = "5")]
pub amount_satoshis: u64,
}
/// Token used to determine start of next page in paginated APIs.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PageToken {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub index: i64,
}
/// Represents the direction of a payment.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
Expand Down
6 changes: 2 additions & 4 deletions ldk-server/Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { version = "0.4.0", default-features = false }
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "2095d878be10923845bcdd1dd039ab0e670e723d" }
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 All@@ -15,7 +15,5 @@ prost = { version = "0.11.6", default-features = false, features = ["std"] }
ldk-server-protos = { path = "../ldk-server-protos" }
bytes = "1.4.0"
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
rusqlite = { version = "0.28.0", features = ["bundled"] }

[dev-dependencies]
rusqlite = { version = "0.31.0", features = ["bundled"] }
rand = "0.8.5"
16 changes: 9 additions & 7 deletions ldk-server/src/api/bolt11_receive.rs
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
use ldk_node::Node;
use crate::service::Context;
use ldk_server_protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse};
use std::sync::Arc;

pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";

pub(crate) fn handle_bolt11_receive_request(
node: Arc<Node>, request: Bolt11ReceiveRequest,
context: Context, request: Bolt11ReceiveRequest,
) -> Result<Bolt11ReceiveResponse, ldk_node::NodeError> {
let invoice = match request.amount_msat {
Some(amount_msat) => {
node.bolt11_payment().receive(amount_msat, &request.description, request.expiry_secs)?
},
None => node
Some(amount_msat) => context.node.bolt11_payment().receive(
amount_msat,
&request.description,
request.expiry_secs,
)?,
None => context
.node
.bolt11_payment()
.receive_variable_amount(&request.description, request.expiry_secs)?,
};
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add Api impl for ListForwardedPayments. by G8XSU · Pull Request #32 · lightningdevkit/ldk-server · GitHub
Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,6 @@ jobs:
- name: Pin packages to allow for MSRV
if: matrix.msrv
run: |
cargo update -p hashlink --precise "0.8.2" --verbose # hashlink 0.8.3 requires hashbrown 0.14, requiring 1.64.0
cargo update -p regex --precise "1.9.6" --verbose # regex 1.10.0 requires rustc 1.65.0
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9 requires rustc 1.70 or newer
cargo update -p tokio --precise "1.38.1" --verbose # tokio v1.39.0 requires rustc 1.70 or newer
Expand Down
52 changes: 15 additions & 37 deletions Cargo.lock

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

38 changes: 38 additions & 0 deletions ldk-server-protos/src/api.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,6 +337,44 @@ pub struct ListPaymentsResponse {
#[prost(message, repeated, tag = "1")]
pub payments: ::prost::alloc::vec::Vec<super::types::Payment>,
}
/// Retrieves list of all forwarded payments.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsRequest {
/// `page_token` is a pagination token.
///
/// To query for the first page, `page_token` must not be specified.
///
/// For subsequent pages, use the value that was returned as `next_page_token` in the previous
/// page's response.
#[prost(message, optional, tag = "1")]
pub page_token: ::core::option::Option<super::types::PageToken>,
}
/// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
/// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsResponse {
/// List of forwarded payments.
#[prost(message, repeated, tag = "1")]
pub forwarded_payments: ::prost::alloc::vec::Vec<super::types::ForwardedPayment>,
/// `next_page_token` is a pagination token, used to retrieve the next page of results.
/// Use this value to query for next-page of paginated operation, by specifying
/// this value as the `page_token` in the next request.
///
/// If `next_page_token` is `None`, then the "last page" of results has been processed and
/// there is no more data to be retrieved.
///
/// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
/// result set. The only way to know when you have reached the end of the result set is when
/// `next_page_token` is `None`.
///
/// **Caution**: Clients must not assume a specific number of records to be present in a page for
/// paginated response.
#[prost(message, optional, tag = "2")]
pub next_page_token: ::core::option::Option<super::types::PageToken>,
}
/// Retrieves an overview of all known balances.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances>
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
34 changes: 34 additions & 0 deletions ldk-server-protos/src/proto/api.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,40 @@ message ListPaymentsResponse {
repeated types.Payment payments = 1;
}

// Retrieves list of all forwarded payments.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ListForwardedPaymentsRequest {
// `page_token` is a pagination token.
//
// To query for the first page, `page_token` must not be specified.
//
// For subsequent pages, use the value that was returned as `next_page_token` in the previous
// page's response.
optional types.PageToken page_token = 1;
}

// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
message ListForwardedPaymentsResponse {
// List of forwarded payments.
repeated types.ForwardedPayment forwarded_payments = 1;

// `next_page_token` is a pagination token, used to retrieve the next page of results.
// Use this value to query for next-page of paginated operation, by specifying
// this value as the `page_token` in the next request.
//
// If `next_page_token` is `None`, then the "last page" of results has been processed and
// there is no more data to be retrieved.
//
// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
// result set. The only way to know when you have reached the end of the result set is when
// `next_page_token` is `None`.
//
// **Caution**: Clients must not assume a specific number of records to be present in a page for
// paginated response.
optional types.PageToken next_page_token = 2;
}

// Retrieves an overview of all known balances.
// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances
message GetBalancesRequest {}
Expand Down
51 changes: 51 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,6 +161,51 @@ enum PaymentStatus {
FAILED = 2;
}

// A forwarded payment through our node.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ForwardedPayment{
// The channel id of the incoming channel between the previous node and us.
string prev_channel_id = 1;

// The channel id of the outgoing channel between the next node and us.
string next_channel_id = 2;

// The `user_channel_id` of the incoming channel between the previous node and us.
string prev_user_channel_id = 3;

// The `user_channel_id` of the outgoing channel between the next node and us.
// This will be `None` if the payment was settled via an on-chain transaction.
// See the caveat described for the `total_fee_earned_msat` field.
optional string next_user_channel_id = 4;

// The total fee, in milli-satoshis, which was earned as a result of the payment.
//
// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
// higher than expected as we still claimed the full value in millisatoshis from the source.
// In this case, `claim_from_onchain_tx` will be set.
//
// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
optional uint64 total_fee_earned_msat = 5;

// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
// counterparty accepted to receive less than the invoice amount.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 skimmed_fee_msat = 6;

// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
bool claim_from_onchain_tx = 7;

// The final amount forwarded, in milli-satoshis, after the fee is deducted.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 outbound_amount_forwarded_msat = 8;

}

message Channel {
// The channel ID (prior to funding transaction generation, this is a random 32-byte
// identifier, afterwards this is the transaction ID of the funding transaction XOR the
Expand DownExpand Up@@ -579,3 +624,9 @@ message AwaitingThresholdConfirmations {
// The amount, in satoshis, of the output being swept.
uint64 amount_satoshis = 5;
}

// Token used to determine start of next page in paginated APIs.
message PageToken {
string token = 1;
int64 index = 2;
}
55 changes: 55 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,6 +165,52 @@ pub struct LspFeeLimits {
#[prost(uint64, optional, tag = "2")]
pub max_proportional_opening_fee_ppm_msat: ::core::option::Option<u64>,
}
/// A forwarded payment through our node.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardedPayment {
/// The channel id of the incoming channel between the previous node and us.
#[prost(string, tag = "1")]
pub prev_channel_id: ::prost::alloc::string::String,
/// The channel id of the outgoing channel between the next node and us.
#[prost(string, tag = "2")]
pub next_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the incoming channel between the previous node and us.
#[prost(string, tag = "3")]
pub prev_user_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the outgoing channel between the next node and us.
/// This will be `None` if the payment was settled via an on-chain transaction.
/// See the caveat described for the `total_fee_earned_msat` field.
#[prost(string, optional, tag = "4")]
pub next_user_channel_id: ::core::option::Option<::prost::alloc::string::String>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
/// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
/// higher than expected as we still claimed the full value in millisatoshis from the source.
/// In this case, `claim_from_onchain_tx` will be set.
///
/// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
/// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
#[prost(uint64, optional, tag = "5")]
pub total_fee_earned_msat: ::core::option::Option<u64>,
/// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
/// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
/// counterparty accepted to receive less than the invoice amount.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "6")]
pub skimmed_fee_msat: ::core::option::Option<u64>,
/// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
#[prost(bool, tag = "7")]
pub claim_from_onchain_tx: bool,
/// The final amount forwarded, in milli-satoshis, after the fee is deducted.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "8")]
pub outbound_amount_forwarded_msat: ::core::option::Option<u64>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Channel {
Expand DownExpand Up@@ -647,6 +693,15 @@ pub struct AwaitingThresholdConfirmations {
#[prost(uint64, tag = "5")]
pub amount_satoshis: u64,
}
/// Token used to determine start of next page in paginated APIs.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PageToken {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub index: i64,
}
/// Represents the direction of a payment.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
Expand Down
6 changes: 2 additions & 4 deletions ldk-server/Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { version = "0.4.0", default-features = false }
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "2095d878be10923845bcdd1dd039ab0e670e723d" }
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 All@@ -15,7 +15,5 @@ prost = { version = "0.11.6", default-features = false, features = ["std"] }
ldk-server-protos = { path = "../ldk-server-protos" }
bytes = "1.4.0"
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
rusqlite = { version = "0.28.0", features = ["bundled"] }

[dev-dependencies]
rusqlite = { version = "0.31.0", features = ["bundled"] }
rand = "0.8.5"
16 changes: 9 additions & 7 deletions ldk-server/src/api/bolt11_receive.rs
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
use ldk_node::Node;
use crate::service::Context;
use ldk_server_protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse};
use std::sync::Arc;

pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";

pub(crate) fn handle_bolt11_receive_request(
node: Arc<Node>, request: Bolt11ReceiveRequest,
context: Context, request: Bolt11ReceiveRequest,
) -> Result<Bolt11ReceiveResponse, ldk_node::NodeError> {
let invoice = match request.amount_msat {
Some(amount_msat) => {
node.bolt11_payment().receive(amount_msat, &request.description, request.expiry_secs)?
},
None => node
Some(amount_msat) => context.node.bolt11_payment().receive(
amount_msat,
&request.description,
request.expiry_secs,
)?,
None => context
.node
.bolt11_payment()
.receive_variable_amount(&request.description, request.expiry_secs)?,
};
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add Api impl for ListForwardedPayments. by G8XSU · Pull Request #32 · lightningdevkit/ldk-server · GitHub
Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,6 @@ jobs:
- name: Pin packages to allow for MSRV
if: matrix.msrv
run: |
cargo update -p hashlink --precise "0.8.2" --verbose # hashlink 0.8.3 requires hashbrown 0.14, requiring 1.64.0
cargo update -p regex --precise "1.9.6" --verbose # regex 1.10.0 requires rustc 1.65.0
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9 requires rustc 1.70 or newer
cargo update -p tokio --precise "1.38.1" --verbose # tokio v1.39.0 requires rustc 1.70 or newer
Expand Down
52 changes: 15 additions & 37 deletions Cargo.lock

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

38 changes: 38 additions & 0 deletions ldk-server-protos/src/api.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,6 +337,44 @@ pub struct ListPaymentsResponse {
#[prost(message, repeated, tag = "1")]
pub payments: ::prost::alloc::vec::Vec<super::types::Payment>,
}
/// Retrieves list of all forwarded payments.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsRequest {
/// `page_token` is a pagination token.
///
/// To query for the first page, `page_token` must not be specified.
///
/// For subsequent pages, use the value that was returned as `next_page_token` in the previous
/// page's response.
#[prost(message, optional, tag = "1")]
pub page_token: ::core::option::Option<super::types::PageToken>,
}
/// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
/// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsResponse {
/// List of forwarded payments.
#[prost(message, repeated, tag = "1")]
pub forwarded_payments: ::prost::alloc::vec::Vec<super::types::ForwardedPayment>,
/// `next_page_token` is a pagination token, used to retrieve the next page of results.
/// Use this value to query for next-page of paginated operation, by specifying
/// this value as the `page_token` in the next request.
///
/// If `next_page_token` is `None`, then the "last page" of results has been processed and
/// there is no more data to be retrieved.
///
/// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
/// result set. The only way to know when you have reached the end of the result set is when
/// `next_page_token` is `None`.
///
/// **Caution**: Clients must not assume a specific number of records to be present in a page for
/// paginated response.
#[prost(message, optional, tag = "2")]
pub next_page_token: ::core::option::Option<super::types::PageToken>,
}
/// Retrieves an overview of all known balances.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances>
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
34 changes: 34 additions & 0 deletions ldk-server-protos/src/proto/api.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,40 @@ message ListPaymentsResponse {
repeated types.Payment payments = 1;
}

// Retrieves list of all forwarded payments.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ListForwardedPaymentsRequest {
// `page_token` is a pagination token.
//
// To query for the first page, `page_token` must not be specified.
//
// For subsequent pages, use the value that was returned as `next_page_token` in the previous
// page's response.
optional types.PageToken page_token = 1;
}

// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
message ListForwardedPaymentsResponse {
// List of forwarded payments.
repeated types.ForwardedPayment forwarded_payments = 1;

// `next_page_token` is a pagination token, used to retrieve the next page of results.
// Use this value to query for next-page of paginated operation, by specifying
// this value as the `page_token` in the next request.
//
// If `next_page_token` is `None`, then the "last page" of results has been processed and
// there is no more data to be retrieved.
//
// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
// result set. The only way to know when you have reached the end of the result set is when
// `next_page_token` is `None`.
//
// **Caution**: Clients must not assume a specific number of records to be present in a page for
// paginated response.
optional types.PageToken next_page_token = 2;
}

// Retrieves an overview of all known balances.
// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances
message GetBalancesRequest {}
Expand Down
51 changes: 51 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,6 +161,51 @@ enum PaymentStatus {
FAILED = 2;
}

// A forwarded payment through our node.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ForwardedPayment{
// The channel id of the incoming channel between the previous node and us.
string prev_channel_id = 1;

// The channel id of the outgoing channel between the next node and us.
string next_channel_id = 2;

// The `user_channel_id` of the incoming channel between the previous node and us.
string prev_user_channel_id = 3;

// The `user_channel_id` of the outgoing channel between the next node and us.
// This will be `None` if the payment was settled via an on-chain transaction.
// See the caveat described for the `total_fee_earned_msat` field.
optional string next_user_channel_id = 4;

// The total fee, in milli-satoshis, which was earned as a result of the payment.
//
// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
// higher than expected as we still claimed the full value in millisatoshis from the source.
// In this case, `claim_from_onchain_tx` will be set.
//
// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
optional uint64 total_fee_earned_msat = 5;

// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
// counterparty accepted to receive less than the invoice amount.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 skimmed_fee_msat = 6;

// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
bool claim_from_onchain_tx = 7;

// The final amount forwarded, in milli-satoshis, after the fee is deducted.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 outbound_amount_forwarded_msat = 8;

}

message Channel {
// The channel ID (prior to funding transaction generation, this is a random 32-byte
// identifier, afterwards this is the transaction ID of the funding transaction XOR the
Expand DownExpand Up@@ -579,3 +624,9 @@ message AwaitingThresholdConfirmations {
// The amount, in satoshis, of the output being swept.
uint64 amount_satoshis = 5;
}

// Token used to determine start of next page in paginated APIs.
message PageToken {
string token = 1;
int64 index = 2;
}
55 changes: 55 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,6 +165,52 @@ pub struct LspFeeLimits {
#[prost(uint64, optional, tag = "2")]
pub max_proportional_opening_fee_ppm_msat: ::core::option::Option<u64>,
}
/// A forwarded payment through our node.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardedPayment {
/// The channel id of the incoming channel between the previous node and us.
#[prost(string, tag = "1")]
pub prev_channel_id: ::prost::alloc::string::String,
/// The channel id of the outgoing channel between the next node and us.
#[prost(string, tag = "2")]
pub next_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the incoming channel between the previous node and us.
#[prost(string, tag = "3")]
pub prev_user_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the outgoing channel between the next node and us.
/// This will be `None` if the payment was settled via an on-chain transaction.
/// See the caveat described for the `total_fee_earned_msat` field.
#[prost(string, optional, tag = "4")]
pub next_user_channel_id: ::core::option::Option<::prost::alloc::string::String>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
/// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
/// higher than expected as we still claimed the full value in millisatoshis from the source.
/// In this case, `claim_from_onchain_tx` will be set.
///
/// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
/// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
#[prost(uint64, optional, tag = "5")]
pub total_fee_earned_msat: ::core::option::Option<u64>,
/// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
/// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
/// counterparty accepted to receive less than the invoice amount.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "6")]
pub skimmed_fee_msat: ::core::option::Option<u64>,
/// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
#[prost(bool, tag = "7")]
pub claim_from_onchain_tx: bool,
/// The final amount forwarded, in milli-satoshis, after the fee is deducted.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "8")]
pub outbound_amount_forwarded_msat: ::core::option::Option<u64>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Channel {
Expand DownExpand Up@@ -647,6 +693,15 @@ pub struct AwaitingThresholdConfirmations {
#[prost(uint64, tag = "5")]
pub amount_satoshis: u64,
}
/// Token used to determine start of next page in paginated APIs.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PageToken {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub index: i64,
}
/// Represents the direction of a payment.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
Expand Down
6 changes: 2 additions & 4 deletions ldk-server/Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { version = "0.4.0", default-features = false }
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "2095d878be10923845bcdd1dd039ab0e670e723d" }
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 All@@ -15,7 +15,5 @@ prost = { version = "0.11.6", default-features = false, features = ["std"] }
ldk-server-protos = { path = "../ldk-server-protos" }
bytes = "1.4.0"
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
rusqlite = { version = "0.28.0", features = ["bundled"] }

[dev-dependencies]
rusqlite = { version = "0.31.0", features = ["bundled"] }
rand = "0.8.5"
16 changes: 9 additions & 7 deletions ldk-server/src/api/bolt11_receive.rs
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
use ldk_node::Node;
use crate::service::Context;
use ldk_server_protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse};
use std::sync::Arc;

pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";

pub(crate) fn handle_bolt11_receive_request(
node: Arc<Node>, request: Bolt11ReceiveRequest,
context: Context, request: Bolt11ReceiveRequest,
) -> Result<Bolt11ReceiveResponse, ldk_node::NodeError> {
let invoice = match request.amount_msat {
Some(amount_msat) => {
node.bolt11_payment().receive(amount_msat, &request.description, request.expiry_secs)?
},
None => node
Some(amount_msat) => context.node.bolt11_payment().receive(
amount_msat,
&request.description,
request.expiry_secs,
)?,
None => context
.node
.bolt11_payment()
.receive_variable_amount(&request.description, request.expiry_secs)?,
};
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Add Api impl for ListForwardedPayments. by G8XSU · Pull Request #32 · lightningdevkit/ldk-server · GitHub
Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,6 @@ jobs:
- name: Pin packages to allow for MSRV
if: matrix.msrv
run: |
cargo update -p hashlink --precise "0.8.2" --verbose # hashlink 0.8.3 requires hashbrown 0.14, requiring 1.64.0
cargo update -p regex --precise "1.9.6" --verbose # regex 1.10.0 requires rustc 1.65.0
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9 requires rustc 1.70 or newer
cargo update -p tokio --precise "1.38.1" --verbose # tokio v1.39.0 requires rustc 1.70 or newer
Expand Down
52 changes: 15 additions & 37 deletions Cargo.lock

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

38 changes: 38 additions & 0 deletions ldk-server-protos/src/api.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,6 +337,44 @@ pub struct ListPaymentsResponse {
#[prost(message, repeated, tag = "1")]
pub payments: ::prost::alloc::vec::Vec<super::types::Payment>,
}
/// Retrieves list of all forwarded payments.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsRequest {
/// `page_token` is a pagination token.
///
/// To query for the first page, `page_token` must not be specified.
///
/// For subsequent pages, use the value that was returned as `next_page_token` in the previous
/// page's response.
#[prost(message, optional, tag = "1")]
pub page_token: ::core::option::Option<super::types::PageToken>,
}
/// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
/// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListForwardedPaymentsResponse {
/// List of forwarded payments.
#[prost(message, repeated, tag = "1")]
pub forwarded_payments: ::prost::alloc::vec::Vec<super::types::ForwardedPayment>,
/// `next_page_token` is a pagination token, used to retrieve the next page of results.
/// Use this value to query for next-page of paginated operation, by specifying
/// this value as the `page_token` in the next request.
///
/// If `next_page_token` is `None`, then the "last page" of results has been processed and
/// there is no more data to be retrieved.
///
/// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
/// result set. The only way to know when you have reached the end of the result set is when
/// `next_page_token` is `None`.
///
/// **Caution**: Clients must not assume a specific number of records to be present in a page for
/// paginated response.
#[prost(message, optional, tag = "2")]
pub next_page_token: ::core::option::Option<super::types::PageToken>,
}
/// Retrieves an overview of all known balances.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances>
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
34 changes: 34 additions & 0 deletions ldk-server-protos/src/proto/api.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,6 +319,40 @@ message ListPaymentsResponse {
repeated types.Payment payments = 1;
}

// Retrieves list of all forwarded payments.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ListForwardedPaymentsRequest {
// `page_token` is a pagination token.
//
// To query for the first page, `page_token` must not be specified.
//
// For subsequent pages, use the value that was returned as `next_page_token` in the previous
// page's response.
optional types.PageToken page_token = 1;
}

// The response `content` for the `ListForwardedPayments` API, when HttpStatusCode is OK (200).
// When HttpStatusCode is not OK (non-200), the response `content` contains a serialized `ErrorResponse`.
message ListForwardedPaymentsResponse {
// List of forwarded payments.
repeated types.ForwardedPayment forwarded_payments = 1;

// `next_page_token` is a pagination token, used to retrieve the next page of results.
// Use this value to query for next-page of paginated operation, by specifying
// this value as the `page_token` in the next request.
//
// If `next_page_token` is `None`, then the "last page" of results has been processed and
// there is no more data to be retrieved.
//
// If `next_page_token` is not `None`, it does not necessarily mean that there is more data in the
// result set. The only way to know when you have reached the end of the result set is when
// `next_page_token` is `None`.
//
// **Caution**: Clients must not assume a specific number of records to be present in a page for
// paginated response.
optional types.PageToken next_page_token = 2;
}

// Retrieves an overview of all known balances.
// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_balances
message GetBalancesRequest {}
Expand Down
51 changes: 51 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,6 +161,51 @@ enum PaymentStatus {
FAILED = 2;
}

// A forwarded payment through our node.
// See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded
message ForwardedPayment{
// The channel id of the incoming channel between the previous node and us.
string prev_channel_id = 1;

// The channel id of the outgoing channel between the next node and us.
string next_channel_id = 2;

// The `user_channel_id` of the incoming channel between the previous node and us.
string prev_user_channel_id = 3;

// The `user_channel_id` of the outgoing channel between the next node and us.
// This will be `None` if the payment was settled via an on-chain transaction.
// See the caveat described for the `total_fee_earned_msat` field.
optional string next_user_channel_id = 4;

// The total fee, in milli-satoshis, which was earned as a result of the payment.
//
// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
// higher than expected as we still claimed the full value in millisatoshis from the source.
// In this case, `claim_from_onchain_tx` will be set.
//
// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
optional uint64 total_fee_earned_msat = 5;

// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
// counterparty accepted to receive less than the invoice amount.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 skimmed_fee_msat = 6;

// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
bool claim_from_onchain_tx = 7;

// The final amount forwarded, in milli-satoshis, after the fee is deducted.
//
// The caveat described above the `total_fee_earned_msat` field applies here as well.
optional uint64 outbound_amount_forwarded_msat = 8;

}

message Channel {
// The channel ID (prior to funding transaction generation, this is a random 32-byte
// identifier, afterwards this is the transaction ID of the funding transaction XOR the
Expand DownExpand Up@@ -579,3 +624,9 @@ message AwaitingThresholdConfirmations {
// The amount, in satoshis, of the output being swept.
uint64 amount_satoshis = 5;
}

// Token used to determine start of next page in paginated APIs.
message PageToken {
string token = 1;
int64 index = 2;
}
55 changes: 55 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,6 +165,52 @@ pub struct LspFeeLimits {
#[prost(uint64, optional, tag = "2")]
pub max_proportional_opening_fee_ppm_msat: ::core::option::Option<u64>,
}
/// A forwarded payment through our node.
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded>
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardedPayment {
/// The channel id of the incoming channel between the previous node and us.
#[prost(string, tag = "1")]
pub prev_channel_id: ::prost::alloc::string::String,
/// The channel id of the outgoing channel between the next node and us.
#[prost(string, tag = "2")]
pub next_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the incoming channel between the previous node and us.
#[prost(string, tag = "3")]
pub prev_user_channel_id: ::prost::alloc::string::String,
/// The `user_channel_id` of the outgoing channel between the next node and us.
/// This will be `None` if the payment was settled via an on-chain transaction.
/// See the caveat described for the `total_fee_earned_msat` field.
#[prost(string, optional, tag = "4")]
pub next_user_channel_id: ::core::option::Option<::prost::alloc::string::String>,
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
///
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC was pending, the amount the
/// next hop claimed will have been rounded down to the nearest whole satoshi. Thus, the fee calculated here may be
/// higher than expected as we still claimed the full value in millisatoshis from the source.
/// In this case, `claim_from_onchain_tx` will be set.
///
/// If the channel which sent us the payment has been force-closed, we will claim the funds via an on-chain transaction.
/// In that case we do not yet know the on-chain transaction fees which we will spend and will instead set this to `None`.
#[prost(uint64, optional, tag = "5")]
pub total_fee_earned_msat: ::core::option::Option<u64>,
/// The share of the total fee, in milli-satoshis, which was withheld in addition to the forwarding fee.
/// This will only be set if we forwarded an intercepted HTLC with less than the expected amount. This means our
/// counterparty accepted to receive less than the invoice amount.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "6")]
pub skimmed_fee_msat: ::core::option::Option<u64>,
/// If this is true, the forwarded HTLC was claimed by our counterparty via an on-chain transaction.
#[prost(bool, tag = "7")]
pub claim_from_onchain_tx: bool,
/// The final amount forwarded, in milli-satoshis, after the fee is deducted.
///
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
#[prost(uint64, optional, tag = "8")]
pub outbound_amount_forwarded_msat: ::core::option::Option<u64>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Channel {
Expand DownExpand Up@@ -647,6 +693,15 @@ pub struct AwaitingThresholdConfirmations {
#[prost(uint64, tag = "5")]
pub amount_satoshis: u64,
}
/// Token used to determine start of next page in paginated APIs.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PageToken {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub index: i64,
}
/// Represents the direction of a payment.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
Expand Down
6 changes: 2 additions & 4 deletions ldk-server/Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { version = "0.4.0", default-features = false }
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "2095d878be10923845bcdd1dd039ab0e670e723d" }
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 All@@ -15,7 +15,5 @@ prost = { version = "0.11.6", default-features = false, features = ["std"] }
ldk-server-protos = { path = "../ldk-server-protos" }
bytes = "1.4.0"
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
rusqlite = { version = "0.28.0", features = ["bundled"] }

[dev-dependencies]
rusqlite = { version = "0.31.0", features = ["bundled"] }
rand = "0.8.5"
16 changes: 9 additions & 7 deletions ldk-server/src/api/bolt11_receive.rs
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
use ldk_node::Node;
use crate::service::Context;
use ldk_server_protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse};
use std::sync::Arc;

pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";

pub(crate) fn handle_bolt11_receive_request(
node: Arc<Node>, request: Bolt11ReceiveRequest,
context: Context, request: Bolt11ReceiveRequest,
) -> Result<Bolt11ReceiveResponse, ldk_node::NodeError> {
let invoice = match request.amount_msat {
Some(amount_msat) => {
node.bolt11_payment().receive(amount_msat, &request.description, request.expiry_secs)?
},
None => node
Some(amount_msat) => context.node.bolt11_payment().receive(
amount_msat,
&request.description,
request.expiry_secs,
)?,
None => context
.node
.bolt11_payment()
.receive_variable_amount(&request.description, request.expiry_secs)?,
};
Expand Down
Loading