feat(mintd): allow multiple lightning backends per currency unit#1949
Open
Micah-Shallom wants to merge 5 commits into
Open
feat(mintd): allow multiple lightning backends per currency unit#1949Micah-Shallom wants to merge 5 commits into
Micah-Shallom wants to merge 5 commits into
Conversation
3f0df4a to
81bf6b6
Compare
asmogo
requested changes
May 11, 2026
Collaborator
asmogo
left a comment
There was a problem hiding this comment.
Thanks for your contribution.
I have a minor change request regarding the grpc processor configuration. Apart from that, this looks good to me.
| tracing::debug!("Adding unit: {:?}", unit); | ||
| let processor = grpc_processor | ||
| .setup(settings, unit.clone(), None, work_dir, None) | ||
| for unit in grpc_processor.clone().supported_units { |
Collaborator
There was a problem hiding this comment.
I believe we should deprecate the supported_units variable and instead use ln_entry units in this context. With this setup, we may need to define the unit twice in the configuration, once for the supported_units variable and once for the ln_entry variable.
[grpc_processor]
addr = "http://127.0.0.1"
port = 50051
supported_units = ["sat"]
[[ln]]
ln_backend = "grpcprocessor"
unit = "sat"
I’m not sure if we should do this in the same pull request.
Author
A single mintd instance can now run several Lightning backends, each serving a different currency unit (for example CLN for sat, LNbits for eur). The legacy single [ln] config block is still accepted unchanged; multi-backend setups repeat [[ln]] with a unit field on each entry. Closes cashubtc#1465
Adds two round-trip parsing tests: - test_multi_backend_config_parses verifies a TOML with two [[ln]] blocks (sat and eur) deserializes into a 2-element Vec<Ln> with correct units and per-entry limits. - test_legacy_ln_block_parses verifies the old single [ln] form produces a 1-element Vec with unit defaulted to Sat, locking in backwards compatibility.
Updates example.config.toml to show the new [[ln]] array form alongside the existing single [ln] block, and adds a "Multiple Lightning Backends" section to the cdk-mintd README explaining per-unit configuration, duplicate (unit, method) rejection, and backwards compatibility.
Replaces the internal supported_units iteration with a single registration driven by [[ln]].unit, matching the pattern used by the other Lightning backends. Operators no longer need to declare the same unit twice (once in [fake_wallet]/[grpc_processor] and again in [[ln]]). The supported_units field stays in the config structs so legacy configs still parse, but it no longer affects registration. Operators using multiple supported_units should switch to one [[ln]] block per unit.
Verifies that when an operator configures [[ln]] backend = "fakewallet" with a non-default unit, the resulting mint registers that unit and not whatever [fake_wallet].supported_units says. This guards against the supported_units iteration creeping back into the dispatcher.
36085a0 to
f87057a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for running multiple Lightning backends in a single
cdk-mintd, with each backend serving a different currency unit. So one mint can hand out sat-denominated ecash via CLN and eur-denominated ecash via LNbits, all through the same mint URL.The mint engine itself already supported this (its payment-processor map is keyed by
(unit, method)); the only thing blocking it wascdk-mintd's config and startup, which assumed a single backend. This PR removes that assumption.Closes #1465
What operators see
Existing configs keep working. The old single
[ln]block is still accepted and behaves identically to today.For a multi-backend setup, repeat
[[ln]]instead, one entry per(unit, method):Each entry has its own mint/melt limits. Two entries pointing to the same
(unit, method)are rejected at startup with a clear error.