feat: P2PK key storage and auto-sign on receive #1053
No reviewers
Labels
No labels
DB & Storage
Deployment
Error Handling & Logging
Maintenance
Payment Backend
backport
backport v0.13.x
backport v0.14.x
backport v0.15.x
bindings
blocked
bug
cdk-sql
ci
cli
deps
documentation
duplicate
enhancement
good first issue
help wanted
invalid
keep-open
ldk-node-ui
migrations
mint
mutation-testing
needs rebase
needs review
new nut
nut change
question
ready
rust-version
rustfmt
stacked hold
stale
testing
wallet
weekly-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cashubtc/cdk!1053
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/p2pk-key-store-autosign"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements #1029
Followed development guide: formatted, typos, clippy; validated pure tests.
Should the wallet use the seed to make deterministic secrets instead of randomly generated secret keys (e.g., using BIP32)?
Great question — and I think we’re talking about two different classes of secrets:
In this PR, the “secret keys” in question are of the first type, so I kept them random by design.
I don't think these should be no ops especially ones that do not return errors we should force db backends to support this.
We store the pubkey and secret key, why don't we return both?
It seems to me the effect of this is for each receive even ones where no proof needs a signature we get all secret keys from the db and create a list of them, this seem unnecessary. Why don't we iter over the proofs get all pubkeys for those and then get the secret keys for only those pubkeys.
Updated the trait so these methods are mandatory (no default no-ops) and wired them through every wallet backend. The SQL store keeps its existing table, Redb has a v5 migration to create p2pk_signing_keys, and the FFI bridge now exposes the concrete impls, so all backends persist and surface P2PK keys consistently.
Switched list_p2pk_signing_keys (and the underlying db APIs) to return (pubkey, secret) pairs. Callers now get the stored public key alongside the secret so they can correlate entries without re-deriving.
Reworked the merge logic: we seed the map with any keys provided in ReceiveOptions, then, as we inspect each proof, we only call get_p2pk_key for the pubkeys actually referenced (track misses to avoid repeat queries). No more list_p2pk_keys() scan on every receive.
Fixed error conversion and rebased.
Should there be a wallet function to create a p2pk payment request that generates and saves the key as a convenience method so users don't have to remember to save it themselves?
Yes that's why I haven't merged. I don't think user should have to generate a secret key like they do now; should call a fn as you suggest.
superseded by https://github.com/cashubtc/cdk/pull/1466
Pull request closed