Skip to content

Conversation

@lescuer97
Copy link
Contributor

Description

Add public key generation with counter for wallet.


Notes to the reviewers


Suggested CHANGELOG Updates

CHANGED

ADDED

REMOVED

FIXED


Checklist

@thesimplekid
Copy link
Collaborator

This replaces this right? #1053

Comment on lines 196 to 201
// stores p2pk signing keys for the wallet
async fn add_p2pk_key(&self, pubkey: &PublicKey, derivation_path: String, derivation_index: u32) -> Result<(), Self::Err>;
/// Get a stored P2PK signing key by pubkey.
async fn get_p2pk_key(&self, pubkey: &PublicKey) -> Result<Option<wallet::P2PKSigningKey>, Self::Err>;
/// List all stored P2PK signing keys.
async fn list_p2pk_keys(&self) -> Result<Vec<wallet::P2PKSigningKey>, Self::Err>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to have a discussion and have some guidelines on when we should add new fns to the db traits and when we should take advantage of the KVStore. I think there is a balance between over using the store and making our db traits too complicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to have a discussion and have some guidelines on when we should add new fns to the db traits and when we should take advantage of the KVStore. I think there is a balance between over using the store and making our db traits too complicated.

could you explain the difference between KVStore and the traits? what do you think it should be the parameters on choosing one or the other?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kvstore is general so we can just store arbitrary data in it without having to add fns on the trait. With the drawback of a different migration pattern and less structured data. So I'm not necessarily saying we should do it here but there is a discussion worth having about when to use the Kv and when to add new fns and db tables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I understand. I would use the KVstore when you have data that is clearly independent. EX: Information about a specific npub that you sent money to comes up in my mind

@lescuer97
Copy link
Contributor Author

This replaces this right? #1053

yes

@lescuer97
Copy link
Contributor Author

@thesimplekid @crodas I think this is know in a decent state. I know I'm lacking tests. I want to get your opinion on the implementation before I do that.

@lescuer97 lescuer97 marked this pull request as ready for review December 30, 2025 22:21
Comment on lines 2015 to 2020
pub async fn p2pk_public_key(
&self,
pubkey: &PublicKey,
) -> Result<Option<P2PKSigningKey>, database::Error> {
return self.localstore.get_p2pk_key(pubkey).await;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we should rename this get private key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not give a private key, so no

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't expose right now a way to get the secret key. this is a private method.

I'll take suggestions on naming

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not give a private key, so no

get_public_key i meant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the named functions plus added missing ones to ffi


wallet.melt_human_readable_quote(address, amount_msat).await
}
pub async fn generate_public_key(&self) -> Result<PublicKey, Error> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should have a fn to get the most recent pubkey especially with p2bk the user might want to just reuse the pubkey.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a bad idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a function for getting the latest public key

@thesimplekid thesimplekid added this to CDK Jan 1, 2026
@github-project-automation github-project-automation bot moved this to In progress in CDK Jan 1, 2026

proof.sign_p2pk(secret_key.to_owned().clone())?;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't error if we do not have the required keys to sign. If we cannot get enough sigs for a proof we should not send it to the mint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an enough_signatures function to the Proof struct that will check. Needed to add a new error to the Nut 10 file.

I'm getting a typo error from a meeting agenda. I assume this is a mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants