Skip to content

Add DeriveAndStoreKey RPC - #288

Open
GeorgeTsagk wants to merge 2 commits into
masterfrom
derive-and-store-key
Open

Add DeriveAndStoreKey RPC#288
GeorgeTsagk wants to merge 2 commits into
masterfrom
derive-and-store-key

Conversation

@GeorgeTsagk

@GeorgeTsagk GeorgeTsagk commented Aug 18, 2026

Copy link
Copy Markdown
Member

Description

Wraps lnd's new DeriveAndStoreKey RPC, which derives a key at an arbitrary index and also records it in the wallet. Recording a key is what lets the wallet map the key's public key back to its locator, which it needs in order to sign with the key, and it advances the key family's derivation index past the recorded index.

Depends on lightningnetwork/lnd#11095

@GeorgeTsagk GeorgeTsagk self-assigned this Aug 18, 2026
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Aug 18, 2026
Recording a key in LND implies recording every key that precedes it, so
restoring a key family's index is one DeriveAndStoreKey call per family
instead of one DeriveNextKey per index. LND keeps that operation monotonic
and bounds the number of keys it derives, so the local advance loop, the
rewind guard and the maxKeyIndexAdvance limit are no longer needed here.

Requires an LND with the DeriveAndStoreKey RPC
(lightningnetwork/lnd#11095) and the lndclient wrapper for it
(lightninglabs/lndclient#288).
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Aug 18, 2026
Recording a key in LND implies recording every key that precedes it, so
restoring a key family's index is one DeriveAndStoreKey call per family
instead of one DeriveNextKey per index. LND keeps that operation monotonic
and bounds the number of keys it derives, so the local advance loop, the
rewind guard and the maxKeyIndexAdvance limit are no longer needed here.

Requires an LND with the DeriveAndStoreKey RPC
(lightningnetwork/lnd#11095) and the lndclient wrapper for it
(lightninglabs/lndclient#288).
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Aug 18, 2026
Recording a key in LND implies recording every key that precedes it, so
restoring a key family's index is one DeriveAndStoreKey call per family
instead of one DeriveNextKey per index. LND keeps that operation monotonic
and bounds the number of keys it derives, so the local advance loop, the
rewind guard and the maxKeyIndexAdvance limit are no longer needed here.

Requires an LND with the DeriveAndStoreKey RPC
(lightningnetwork/lnd#11095) and the lndclient wrapper for it
(lightninglabs/lndclient#288).
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Aug 18, 2026
Recording a key in LND implies recording every key that precedes it, so
restoring a key family's index is one DeriveAndStoreKey call per family
instead of one DeriveNextKey per index. LND keeps that operation monotonic
and bounds the number of keys it derives, so the local advance loop, the
rewind guard and the maxKeyIndexAdvance limit are no longer needed here.

Requires an LND with the DeriveAndStoreKey RPC
(lightningnetwork/lnd#11095) and the lndclient wrapper for it
(lightninglabs/lndclient#288).
Wraps lnd's new DeriveAndStoreKey RPC, which derives a key at an
arbitrary index and also records it in the wallet. Recording a key is
what lets the wallet map the key's public key back to its locator, which
it needs in order to sign with the key, and it advances the key family's
derivation index past the recorded index.
The wrapper added in the previous commit calls an RPC that does not exist
in any released LND yet, so this points the LND dependency at the branch of
lightningnetwork/lnd#11095 to make the build work in the meantime.

This commit must be dropped in favor of a normal LND version bump before
this branch can be merged.
@GeorgeTsagk
GeorgeTsagk force-pushed the derive-and-store-key branch from 2c8ee79 to 7d3fdf0 Compare August 19, 2026 12:39
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