Skip to content

lndclient: attach key locator when any component is non-zero (lnd-21-0)#274

Merged
Roasbeef merged 2 commits intolnd-21-0from
signoutput-fix-lnd-21-0
May 5, 2026
Merged

lndclient: attach key locator when any component is non-zero (lnd-21-0)#274
Roasbeef merged 2 commits intolnd-21-0from
signoutput-fix-lnd-21-0

Conversation

@Roasbeef
Copy link
Copy Markdown
Member

@Roasbeef Roasbeef commented May 5, 2026

Backport of #269 to the lnd-21-0 release branch.

Summary

  • Attach the KeyLocator whenever either family or index is non-zero, instead of requiring both to be non-zero — fixes silent locator drop for LND's node identity key (family 6 / index 0) and any first-index key in a non-zero family (e.g. restored-from-seed wallets).
  • Pin the contract with table-driven tests covering the full marshaller (all-zero / family-only / index-only / fully populated, with and without a pubkey) and the legacy partial marshaller.

Test plan

  • go test -run TestMarshallSignDescriptors ./...
  • CI: build + lint

Roasbeef added 2 commits May 5, 2026 17:37
SignOutputRawKeyLocator was introduced to propagate the key locator
alongside the raw public key, but its marshaller required both the
family and the index to be non-zero before attaching the KeyLoc.
That silently dropped the locator for valid keys whose slot has a
zero component — most visibly LND's node identity key at family 6 /
index 0, but any first-index key in a non-zero family is affected.

Attach the locator whenever either component is non-zero, and keep
omitting it only for the all-zero KeyLocator, which is the struct's
zero value and therefore indistinguishable from "locator not set"
at call sites.

This lets callers that sign against the node identity key path, or
any first-index key in a restored-from-seed wallet, resolve through
the fully populated descriptor instead of falling back to pubkey
scanning.
Pin the contract that SignOutputRawKeyLocator's marshaller attaches
the key locator whenever either the family or the index is non-zero
and omits it only for the all-zero KeyLocator. The family-only case
(KeyFamilyNodeKey / index 0) is the specific regression guard for
the previously "both components non-zero" predicate that silently
dropped the locator for LND's node identity key slot.

Also cover the legacy partial descriptor path used by SignOutputRaw
to pin that it still populates either the public key or the locator
but never both, matching the behavior Loop and other downstream
callers adjusted themselves to.
@Roasbeef Roasbeef merged commit 5903493 into lnd-21-0 May 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant