lndclient: attach key locator when any component is non-zero (lnd-21-0)#274
Merged
lndclient: attach key locator when any component is non-zero (lnd-21-0)#274
Conversation
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.
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.
Backport of #269 to the
lnd-21-0release branch.Summary
KeyLocatorwhenever 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).Test plan
go test -run TestMarshallSignDescriptors ./...