Skip to content

feat(mintd): allow multiple lightning backends per currency unit#1949

Open
Micah-Shallom wants to merge 5 commits into
cashubtc:mainfrom
Micah-Shallom:feat/multiple-backends
Open

feat(mintd): allow multiple lightning backends per currency unit#1949
Micah-Shallom wants to merge 5 commits into
cashubtc:mainfrom
Micah-Shallom:feat/multiple-backends

Conversation

@Micah-Shallom
Copy link
Copy Markdown

@Micah-Shallom Micah-Shallom commented Apr 30, 2026

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 was cdk-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):

[[ln]]
ln_backend = "cln"
unit = "sat"

[[ln]]
ln_backend = "lnbits"
unit = "eur"

[cln]
rpc_path = "..."

[lnbits]
admin_api_key = "..."
# ...

Each entry has its own mint/melt limits. Two entries pointing to the same (unit, method) are rejected at startup with a clear error.

@github-project-automation github-project-automation Bot moved this to Backlog in CDK Apr 30, 2026
@Micah-Shallom Micah-Shallom force-pushed the feat/multiple-backends branch from 3f0df4a to 81bf6b6 Compare April 30, 2026 17:12
Copy link
Copy Markdown
Collaborator

@asmogo asmogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

I have a minor change request regarding the grpc processor configuration. Apart from that, this looks good to me.

Comment thread crates/cdk-mintd/src/lib.rs Outdated
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 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmogo , i pushed e4c2b2d in this PR since it's small. supported_units stays in the struct so legacy configs still parse, but it no longer drives registration.

@github-project-automation github-project-automation Bot moved this from Backlog to In progress in CDK May 11, 2026
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.
@Micah-Shallom Micah-Shallom force-pushed the feat/multiple-backends branch from 36085a0 to f87057a Compare May 11, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Feature: allow multiple payment backends

2 participants