cmd/loop: fix route hint array parsing - #1213
Open
starius wants to merge 2 commits into
Open
Conversation
Treat --route_hints as a single JSON array instead of a repeatable string slice. This preserves commas in the JSON without disabling slice separators for unrelated UTXO and deposit flags. Decode the outer array into raw JSON elements, then use protojson for each RouteHint protobuf. This follows protobuf JSON field naming and quoted uint64 semantics, and rejects unknown fields instead of silently accepting misspelled hints. Reject empty RouteHint messages at the RPC boundary. An empty route would be encoded as an empty BOLT 11 r field, which zpay32 rejects when decoding the invoice. Add recorded CLI sessions covering valid single, multiple, and multi-hop hints, malformed input, RPC-boundary validation, and comma-separated UTXO and deposit selections.
The protobuf implementation intentionally varies the separator after its error prefix between an ASCII space and a non-breaking space across builds. This made recorded route hint sessions depend on the test binary and fail CI despite identical parsing behavior. Normalize the non-breaking space before returning the CLI error so the user-facing message and recorded sessions remain stable across builds.
starius
force-pushed
the
fix-cli-route-hints-array
branch
from
August 27, 2026 01:14
2862b4c to
328f302
Compare
starius
marked this pull request as ready for review
August 27, 2026 06:04
hieblmi
approved these changes
Aug 28, 2026
hieblmi
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, pending one finding.
| if rpcHint.ChanId == 0 { | ||
| return zpay32.HopHint{}, fmt.Errorf("channel ID is zero") | ||
| } | ||
| if rpcHint.CltvExpiryDelta == 0 { |
Collaborator
There was a problem hiding this comment.
Zero CLTV deltas are protocol-permitted. The new check in swapclient_server.go rejects every hint with cltv_expiry_delta == 0. BOLT 7 defines this as an unrestricted u16 and only requires it to equal the blocks subtracted; BOLT 11 carries that value into route hints without adding a nonzero constraint. This can reject a standards-permitted private-channel policy and breaks previously accepted gRPC requests. Keep the > MaxUint16 guard, but remove the zero check unless Loop intentionally documents a stricter API requirement. BOLT 7, BOLT 11.
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.
Another approach for #1209. We can have only a single
--route_hintswith complete JSON, so the type should becli.StringFlag. And then we don't needDisableSliceFlagSeparatorand touching other flags (--utxoand--deposit_outpoint).Treat
--route_hintsas a single JSON array instead of a repeatable string slice. This preserves commas in the JSON without disabling slice separators for unrelated UTXO and deposit flags.Decode the outer array into raw JSON elements, then use protojson for each
RouteHintprotobuf. This follows protobuf JSON field naming and quoted uint64 semantics, and rejects unknown fields instead of silently accepting misspelled hints.Reject empty RouteHint messages at the RPC boundary. An empty route would be encoded as an empty BOLT 11
rfield, which zpay32 rejects when decoding the invoice.Add recorded CLI sessions covering valid single, multiple, and multi-hop hints, malformed input, RPC-boundary validation, and comma-separated UTXO and deposit selections.
Pull Request Checklist
docs/release-notes/release-notes-next.md, or apply theno-changeloglabel (required by CI)