Commit graph

405 commits

Author SHA1 Message Date
Ken Sedgwick
6fe275ad70
JitRebalancer: restore the in-flight guard lost in the #328 squash
The #328 squash commit (986f30d) was created by soft-resetting the
autoclose branch onto origin/master, but the branch's index still held
a tree from before the #327 merge, so the commit silently reverted
Boss/Mod/JitRebalancer.cpp and tests/boss/test_jitrebalancer.cpp to
their pre-guard state.  master and the v0.16.3-rc1 tag therefore lack
the fix for #323 that the CHANGELOG describes.  GitHub's up-to-date
check passed because it checks ancestry, not tree content, and CI
passed because the guard's tests were reverted along with the guard.

Restore both files from the post-#327 master tip (5839241); nothing
else has touched them since, and git diff 5839241 986f30d confirms
the reversion was limited to these two files.

Restores the fix for #323.
2026-08-14 12:33:57 -07:00
Ken Sedgwick
986f30d1b4
PeerComplaintsDesk: defer auto-close while the peer is offline
Some checks failed
Code Base Sanity Check / tests (push) Has been cancelled
Code Base Sanity Check / coverage (push) Has been cancelled
Code Base Sanity Check / build-clang (push) Has been cancelled
close was issued with unilateraltimeout=180 on a fixed timer,
without regard to the peer's connection state, while one complaint
source (ComplainerByLowConnectRate) selects peers specifically for
a low connect rate.  Closing while the peer is offline escalates
to a unilateral force-close after 3 minutes, against exactly the
peers least likely to negotiate a mutual close in time.

Check the peer's channels for a live connection (listpeerchannels
peer_connected) before issuing close, and defer while the peer is
offline.  Poll close candidates every 10 minutes rather than once
per solicitation cycle, so a flaky peer's brief online windows are
actually caught.  If the peer stays offline for close_patience
(3 days), close anyway and let the short unilateral timeout
escalate; the first-deferred time is persisted in a new
PeerComplaintsDesk_closepending table so restarts do not reset
the patience window.  The fees_low gate applies only to that
unilateral path: a mutual close even at high feerates is cheaper
than a unilateral at low feerates, so connected peers are closed
immediately regardless of feerate.

Add tests/boss/test_peercomplaintsdesk_main.cpp covering the close
paths: a connected peer closes immediately; an offline peer defers
and the deferral survives a restart; within patience it holds;
expired patience holds at high fees and closes at low fees;
dropping below the complaint threshold sweeps the deferral;
channel destruction clears it; disabled auto-close closes nothing.
The test drives the module over the bus with a mock CLN on a
socketpair.

Reported by an external security researcher via private disclosure.

Fixes #324
2026-08-13 13:18:04 -07:00
Ken Sedgwick
16ac283abb
JitRebalancer: skip rebalance if one is already in flight for the destination
Some checks failed
Code Base Sanity Check / tests (push) Has been cancelled
Code Base Sanity Check / coverage (push) Has been cancelled
Code Base Sanity Check / build-clang (push) Has been cancelled
The fee budget check reads out_expenditures, which is only
persisted once a rebalance completes (up to 120 s per run).  Each
incoming HTLC spawned an independent rebalance run with no guard,
so concurrent HTLCs to the same underfunded channel each passed
the check against the same stale value, multiplying the intended
25%-of-earnings aggregate cap by the number of concurrent triggers.

Skip HTLC-triggered rebalances for a node that already has one in
flight, mirroring the working guard in EarningsRebalancer.  Skipped
HTLCs are released immediately and proceed without JIT rebalancing;
a retry after the in-flight run completes sees both the refilled
channel and the updated budget.

Update the parallel-calls unit test to the new semantics: exactly
one of three concurrent calls is let in, only it requests a
rebalance, and the guard clears once the run completes.

Reported by an external security researcher via private disclosure.

Fixes #323
2026-08-13 12:05:06 -07:00
Ken Sedgwick
3c8dc3c16d
FundsMover: verify incoming amount before resolving self-payment HTLCs
The claim of a returning self-payment matched payment_hash and
payment_secret but not the HTLC amount.  Answering the hook with
resolve settles the HTLC at once, so lightningd's own
final_incorrect_htlc_amount check is skipped.  The last-hop peer
relays our onion (and thus the secret) intact but chooses the offered
amount, so it could settle a reduced HTLC, learn the preimage, and
claim the full amount upstream.

Record the intended amount at Claimer::generate() time and resolve
only an exact match; a mismatch is left to normal handling, which
fails the HTLC for lack of an invoice.

The same issue was recently fixed in sling (daywalker90/sling@835f36e8).

Fixes #322.
2026-08-11 14:56:24 -07:00
Ken Sedgwick
1c3ac637ec
Boss/Mod/NewaddrHandler.cpp: Request p2tr addresses (CLN bech32 default removed).
CLN deprecated and then removed the implicit-bech32 default for the
newaddr command. Modern CLN (tested on v26.04.1) responds to
newaddr with only {"p2tr": "..."} and prints the warning

  jsonrpc: Note: disallowing deprecated newaddr.addresstype.defaultbech32

This hit our existing code at line 38, which extracted res["bech32"]
unconditionally. Jsmn::Object::operator[] returns an Object with
null pimpl when the key is missing, and the std::string conversion
operator then throws TypeError. The exception propagates up the
Ev::Io chain and is swallowed silently, so Msg::ResponseNewaddr is
never raised.

Downstream symptom: SwapManager hangs forever in state 0
(NeedsOnchainAddress) after restart. Its getting_address flag was
set true when it raised the request, and only clears when the
queue empties via the response chain that never completes. Every
subsequent Timer10Minutes tick short-circuits on the still-true
flag and does nothing.

Fix matches the draft on origin/boltzapi-v2-taproot-reverse-swaps
commit c3dd1de: explicitly request newaddr p2tr and read res["p2tr"].
This is a breaking change for CLN v23.05 and older, but those are
two-plus years out of support already.
2026-08-06 16:42:23 -07:00
Ken Sedgwick
157ec0e935
ChannelCreateDestroyMonitor: tolerate missing old_state (CLN v26.06)
CLN's channel_state_changed notification used to emit the sentinel
value "unknown" for old_state when there was no previous state.
That value was deprecated in v25.05 and is last-supported in v26.04;
as of v26.06 the old_state field is simply omitted instead (see
doc/developers-guide/deprecated-features.md, entry
"channel_state_changed.old_state.unknown").

The notification handler unconditionally extracted old_state, which
throws Jsmn::TypeError when the field is absent.  The throw was
caught by the surrounding handler, logged as Error
("Unexpected channel_state_changed payload: ..."), and then the
handler returned without taking action.  Functional behavior was
unchanged compared to the legacy "unknown" path (both result in
no destruction event), but the new release variant produced noisy
Error log lines for every state-changed notification on nodes
running v26.06+.

Add an explicit has() check and leave old_state as the default
empty string when absent.  The empty string will not match either
"CHANNELD_NORMAL" or "CHANNELD_AWAITING_LOCKIN", so the handler
falls through to the no-op return -- the same outcome the legacy
catch-and-log path produced, but silently.

This is the third and final commit of the v26.06 compatibility
PR (preceded by the Dowser and Matchmaker/ActiveProber commits).
2026-08-06 16:41:57 -07:00
Tamas Jantvik
df0ed1147b
Addition of Boltz backend on signet (clearnet address needs proxy) 2026-06-08 13:28:45 -07:00
Ken Sedgwick
5a6b5eabe1
Remove defunct DNS seed entries (#309)
Both Lightning DNS seeds are no longer operational: lseed.bitcoinstats.com
returns SERVFAIL and lseed.darosior.ninja is confirmed dead by its
maintainer. The empty seed list is handled gracefully with a warning
log. Retained the original IRC discussion as historical context for future seed
selection.
2026-03-23 14:27:21 -07:00
clboss-contributor
4057154967 feat: add clang C++20 build job to CI
Add clang build configuration to catch C++20 compatibility issues early.

Changes:
- Add build-clang job to .github/workflows/build.yml
- Add missing #include<cstdint> for std::uint* types (clang strict mode)
- Add -lexecinfo for FreeBSD in configure.ac (backtrace_symbols)
- Fix pessimizing-move warning in test_earningsrebalancer.cpp
- Fix CHANGELOG.md formatting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-04 11:24:31 -08:00
Ken Sedgwick
c4be10d63b
feemon: add clboss-feemon-peers to determine peer set for time window 2026-02-27 14:28:59 -08:00
Ken Sedgwick
c58037715c
feemon: add price theory center price 2026-02-27 14:28:55 -08:00
Ken Sedgwick
88c6fd57c4
coroutine: mitigate GCC PR 107288 coroutine issue 2026-02-27 14:28:53 -08:00
Ken Sedgwick
ed16c670bc
feemon: add fee monitor to save per-channel stats
- add clboss-feemon-history command
- add unit tests
2026-02-27 14:28:53 -08:00
tank-welder
8821897a4b
fix missing quote 2026-02-19 14:47:31 -08:00
tank-welder
c86ca5e407
fix: accomodate raw _or_ nested listconfigs rpc output in initiator module
This has been broken since CLN 24.11, fixes https://github.com/ksedgwic/clboss/issues/298
2026-02-19 14:47:30 -08:00
Ken Sedgwick
d23778fc6a
fix: make the argument to decode "string" instead of "bolt11" 2026-02-17 15:49:04 -08:00
Ken Sedgwick
b7251de364
fix: use CLN decode RPC in InvoicePayer, add unit test 2026-02-13 11:40:15 -08:00
Ken Sedgwick
d57277d80a
remove dead code, if by_node is set, node_id must be empty 2026-01-22 11:09:08 -08:00
Ken Sedgwick
cd2fadf80a
add "all" (by_node) mode to clboss-earnings-history API 2026-01-22 11:09:08 -08:00
Ken Sedgwick
a738eebe09
Make the reserve parameter an uin32_t instead of a double
This matches the API docs here: https://docs.corelightning.org/reference/fundpsbt
2026-01-22 10:41:37 -08:00
Ken Sedgwick
47a47adf7d
Don't try bool reserve arg to fundpsbt; resolve deprecation
Fixes #275
2026-01-22 10:41:36 -08:00
Ken Sedgwick
ccd784b057
coroutines: convert OnchainFundsAnnouncer to C++20 coroutines 2026-01-22 10:41:13 -08:00
ZmnSCPxj jxPCSnmZ
f012cacc44
Boss/Mod/FeeModderByPriceTheory.cpp: Simple example of moving to coroutines. 2026-01-21 11:40:36 -08:00
ZmnSCPxj jxPCSnmZ
ef17546c1a
configure.ac: Enable C++20.
This introduces a number of changes:

* We can no longer implicitly capture `this` in `[=]() { ... }`,
  we have to explicitly capture it: `[=, this]() { ... }`.
* We added a newer version of the `AX_CXX_COMPILE_STDCXX` macro as
  the stable Debian does not have the latest version yet, and it is
  the latest version that has support for C++20.
2026-01-21 11:40:01 -08:00
Ken Sedgwick
6aad979092 Decrease the testnet default for min_nodes_to_process 2025-09-11 13:49:22 -07:00
Ken Sedgwick
14299a23e9 Expose min_nodes_to_process as a configurable option 2025-09-11 13:49:22 -07:00
Ken Sedgwick
ec4d695796 Reduce the default max-rebalance-fee-ppm 2025-08-25 09:30:52 -07:00
Ken Sedgwick
30c7be4019 Add configurable max rebalance fee (ppm)
Introduce `--clboss-max-rebalance-fee-ppm` to cap the fee allowed for a
single rebalance. Both JitRebalancer and EarningsRebalancer register and
use this option, defaulting to 5000 ppm (0.5%). Documentation updated to
explain the new setting.
2025-08-25 09:30:52 -07:00
Ken Sedgwick
52e739ebd9 tabify for consistency (unfortunately) 2025-08-25 09:30:52 -07:00
Ken Sedgwick
97510805be Ignore our own node in ChannelFinderByPopularity
Fixes ([#266])
2025-07-14 11:15:30 -07:00
Ken Sedgwick
1a0008458f Add clboss-feerates RPC
- Register and implement the new clboss-feerates command in OnchainFeeMonitor
    - Document the command in README and note it in the changelog
    - Update RPC manifest tests to include the new command
2025-07-07 11:21:09 -07:00
Se7enZ
5fea90e3a7 swaps: Init SQL query to remove blank addresses from cache. 2025-01-24 14:38:15 -06:00
Se7enZ
a8a6fb371e swaps: Don't insert into or select empty addresses from cache. 2025-01-24 14:38:15 -06:00
Ken Sedgwick
9aeb29c541 Add associated primary volume (forwarded and rebalanced) to EarningsTracker
Addresses ([#229])

This allows effective feerates (PPM) to be computed for earnings and
expenses.

This PR updates the schema automatically.  Downgrading to previous
will require manual DB migration (but is possible).  Downgrade
commands are in a comment in EarningsTracker.c
2024-09-25 13:23:04 -05:00
Ken Sedgwick
1bd144a0f8 add clboss-recent-earnings and clboss-earnings-history 2024-09-25 13:23:04 -05:00
Ken Sedgwick
7000f970cb Upgrade EarningsTracker to time bucket schema, use old semantics
This commit modifies the schema of EarningsTracker to allow storing
and accessing earning and expenditure data in specific time ranges.

All existing strategies and reports still use all data from all time
so this PR should not change any balancing behavior.

After we've run w/ this for a while we'll have time-based data
collected and can evaluate how to improve the strategies.
2024-09-25 13:23:04 -05:00
Ken Sedgwick
65ce91578e add EarningsTracker::bucket_time quantizer and unit tests 2024-09-25 13:23:04 -05:00
Ken Sedgwick
781c4afb80 add get_now() and mock_get_now() to EarningsTracker and test_earningstracker
A time source is needed for upcoming time buckets change.
2024-09-25 13:23:04 -05:00
Ken Sedgwick
4a2ea4a039 Insert exception what() value in logging messages 2024-08-19 15:04:30 -07:00
Ken Sedgwick
39a09c2908 Use BacktraceException for appropriate (most) exceptions 2024-08-19 15:04:30 -07:00
Ken Sedgwick
2c0dae5cd6 Add totals to clboss-status offchain_earnings_tracker 2024-08-08 13:42:52 -07:00
Ken Sedgwick
a36d119ba4 Restore ForwardFeeMonitor's ability to see forwarding fees
Fixes ([#222])

Prior to ElementsProject/lightning@780f32d (`v23.05`) both `fee` and
`fee_msat` were sent for compatibility.  The ForwardFeeMonitor was
checking for the presence of the `fee` field before processing the
record.  This needed to be updated to `fee_msat`.
2024-08-08 13:42:52 -07:00
Ken Sedgwick
44476241d1 Improve the logged version string and add clboss-status "info"
The logged version now looks like:
plugin-clboss: clboss v0.13.2 (v0.13.2-rc1-3-g44832e2)

A new "info" chunk is added to clboss-status:
   "info": {
      "version": "v0.13.2",
      "git_commit_hash": "44832e2258069641a6149bdc90b7e5fc12219f77",
      "git_describe": "v0.13.2-rc1-3-g44832e2"
   },
2024-07-24 11:21:41 -07:00
Vincenzo Palazzo
0b5b225572 seeds: update the seeds list
The list of seeds that we currently have is really old
and also are really random.

What I did is to peak some of the most popular nodes (including some CLN
nodes) and update our list of seeds.

However, I am open to an objection is some of you want to keep ar add others
seeds nodes.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-07-18 14:47:57 -07:00
Ken Sedgwick
c8cf41d423 log h2l, mid, l2h, and last_value 2024-07-16 16:02:32 -07:00
Ken Sedgwick
eab672dc16 Improve Initialization of OnchainFeeMonitor with Conservative Synthetic History
Previously, CLBOSS initialized the OnchainFeeMonitor with 2 weeks of
synthetic data collected at an arbitrary time on an unknown
system. This historical data often failed to accurately determine
low/high fee conditions until 2 weeks had passed.

This update changes the initialization to use a smaller amount of
deliberately conservative history. This approach discourages CLBOSS
from prematurely declaring a low-fee environment, while still allowing
it to recognize low fees after a few days.

The new size is designed to have 50% influence on the lower 20th
percentile after 24 hours (24 * 6 * 20% * 0.5 = 14.4). This influence
decreases over time: to 25% after two days, 10% after five days, and
continues to decay until it has no effect after two weeks.

It's important to note that CLBOSS will still function in high fee
environments to manage initial liquidity, so this change does not
impact its ability to operate effectively.
2024-07-16 16:02:32 -07:00
Ken Sedgwick
56f405f063 Improve the ConstructedListpeers handling diagnostics
Hopefully this pattern will prove useful in future debugging
improvements.
2024-07-16 16:01:56 -07:00
Ken Sedgwick
df51d5486b testnet: reduce the min_nodes_to_process because testnet is shrinking
Changelog-Changed: testnet: The minimum number of nodes (with channels) before the ChannelFinderByPopularity starts is reduced from 300 to 200.
2024-06-02 17:24:33 -07:00
Ken Sedgwick
0bd255ce1b Convert ListpeerResult to use ConstructedListpeers
Construct a "compatibility struct" to convert `listpeerchannels`
output into legacy `listpeers` format.

Tests written using the legacy listpeers format can use the
`convert_legacy_listpeers` utility to construct a compatibility
struct.

The test_peerjudge_datagatherer malformed test needed to be malformed
differently to achieve the desired effect.
2024-06-02 16:19:56 -07:00
Ken Sedgwick
dec8114cdf Convert some listpeers uses to listpeerchannels.
A couple `listpeers` uses can remain because they don't need channel
information.  Others use ListpeersAnnouncer and are covered by the
next commit.
2024-06-02 16:19:56 -07:00