Skip to content

Commit 6d20fe3

Browse files
authored
Merge pull request #283 from benthecarman/migrate-forwarded-payments-ldk-node
Use ldk-node for forwarded payment history
2 parents c31191a + 42e05f6 commit 6d20fe3

43 files changed

Lines changed: 1778 additions & 941 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Cargo.lock‎

Lines changed: 18 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎contrib/ldk-server-config.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ alias = "ldk_server" # Lightning node alias
1010
#async_payments_role = "client" # Optional async payments role: "client" or "server"
1111
#enable_zero_fee_commitments = false # Enable zero-fee commitment channels (default: false)
1212

13+
# Forwarding history: "detailed" retains individual records for the current and previous hour,
14+
# then aggregates them into hourly channel-pair statistics and removes the individual records.
15+
# "stats" updates per-channel totals directly without storing individual forwards.
16+
#forwarded_payment_tracking_mode = "stats" # Default: "stats"
17+
1318
# Background probing service (optional)
1419
# CAUTION: Probes send real HTLCs and can lock outbound liquidity until they time out.
1520
# See docs/configuration.md for complete field descriptions.

‎docs/api-guide.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ a channel just-in-time when the invoice is paid.
161161
|-------------------------|------------------------------------------------|
162162
| `GetPaymentDetails` | Get details for a specific payment by ID |
163163
| `ListPayments` | List all payments (paginated) |
164-
| `ListForwardedPayments` | List all forwarded/routed payments (paginated) |
164+
| `GetForwardedPaymentDetails` | Get a stored forwarded payment by its ID |
165+
| `GetForwardedPaymentTrackingMode` | Get the configured forwarding history tracking mode |
166+
| `GetChannelForwardingStats` | Get forwarding statistics for a channel |
167+
| `ListChannelForwardingStats` | List channel forwarding statistics (paginated) |
168+
| `ListChannelPairForwardingStats` | List channel-pair forwarding statistics (paginated) |
169+
| `ListForwardedPayments` | List forwarded payments (paginated) |
165170

166171
See [Pagination](#pagination) below for how to page through results.
167172

@@ -286,7 +291,8 @@ errors before accepting further payments.
286291

287292
## Pagination
288293

289-
`ListPayments` and `ListForwardedPayments` support cursor-based pagination:
294+
`ListPayments`, `ListForwardedPayments`, `ListChannelForwardingStats`, and
295+
`ListChannelPairForwardingStats` support cursor-based pagination:
290296

291297
1. Make the first request without a `page_token`. The server controls the page size.
292298
2. If the response includes a `next_page_token`, pass it as `page_token` in the next request.

‎docs/configuration.md‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ falling back to other channel types supported by the peer. Enabling this setting
6464
source that supports Bitcoin Core's `submitpackage` RPC, and relays TRUC, P2A, and ephemeral
6565
dust. The default is `false`.
6666

67+
Set `forwarded_payment_tracking_mode = "detailed"` to store individual
68+
forwards. LDK Node retains these records for the current and previous one-hour buckets, then
69+
aggregates them into hourly channel-pair statistics and removes the individual records.
70+
Set it to `"stats"` (the default, matching LDK Node) to update per-channel totals directly without
71+
storing individual forwards. Values are case-insensitive.
72+
The same setting is available as `--node-forwarded-payment-tracking-mode` or
73+
`LDK_SERVER_NODE_FORWARDED_PAYMENT_TRACKING_MODE`.
74+
6775
### `[probing]`
6876

6977
Enables LDK Node's background probing service to train the payment scorer with current
@@ -220,8 +228,7 @@ Two resolution methods are supported via the `mode` field:
220228
<network>/ # e.g., bitcoin/, regtest/, signet/
221229
api_key # API key
222230
ldk-server.log # Log file
223-
ldk_node_data.sqlite # LDK Node state (channels, wallet, payments)
224-
ldk_server_data.sqlite # Forwarded-payment history
231+
ldk_node_data.sqlite # LDK Node state, payments, and forwarding history
225232
```
226233

227234
The mnemonic is the node's master secret, required to recover on-chain funds. On first start,

‎docs/operations.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ the following config to `/etc/logrotate.d/ldk-server` (adjust the log path to ma
5353
| File | Priority | Description |
5454
| -------------------------------------- | ------------ | -------------------------------------------------------------------------- |
5555
| `<storage_dir>/keys_mnemonic` | **Critical** | BIP39 mnemonic. Required to recover on-chain funds. Default for new installs. |
56-
| `<network_dir>/ldk_node_data.sqlite` | **Critical** | Channel state, on-chain wallet data, and payment history. Required to recover channel funds. |
57-
| `<network_dir>/ldk_server_data.sqlite` | Nice-to-have | Forwarded-payment history |
56+
| `<network_dir>/ldk_node_data.sqlite` | **Critical** | Channel state, on-chain wallet data, payment and forwarding history. Required to recover channel funds. |
5857

5958
### What is Reconstructable
6059

0 commit comments

Comments
 (0)