Skip to content

P2pk receive wallet#1466

Merged
thesimplekid merged 9 commits into
cashubtc:mainfrom
lescuer97:p2pk_receive_wallet
Mar 27, 2026
Merged

P2pk receive wallet#1466
thesimplekid merged 9 commits into
cashubtc:mainfrom
lescuer97:p2pk_receive_wallet

Conversation

@lescuer97
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

This replaces this right? #1053

Comment thread crates/cdk-common/src/database/wallet/mod.rs Outdated
@lescuer97
Copy link
Copy Markdown
Contributor Author

This replaces this right? #1053

yes

@lescuer97
Copy link
Copy Markdown
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 thread crates/cdk-cli/src/sub_commands/get_public_keys.rs Outdated
Comment thread crates/cdk-cli/Cargo.toml Outdated
Comment thread crates/cdk-common/src/wallet/mod.rs Outdated
Comment thread crates/cdk-ffi/src/database.rs Outdated
Comment thread crates/cdk-ffi/src/database.rs Outdated
Comment thread crates/cdk/src/wallet/mod.rs Outdated
Comment thread crates/cdk/src/wallet/multi_mint_wallet.rs Outdated
Comment thread crates/cdk/src/wallet/multi_mint_wallet.rs Outdated
Comment thread crates/cdk/src/wallet/multi_mint_wallet.rs Outdated
@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
Comment thread crates/cdk-redb/src/wallet/mod.rs Outdated
Comment thread crates/cdk/src/wallet/receive.rs Outdated
Copy link
Copy Markdown
Collaborator

@thesimplekid thesimplekid left a comment

Choose a reason for hiding this comment

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

Thanks just a few comments.

Comment thread crates/cdk-redb/src/wallet/mod.rs Outdated
Comment thread crates/cdk-sql-common/src/wallet/mod.rs
Comment thread crates/cdk-cli/src/sub_commands/get_public_keys.rs Outdated
Comment thread crates/cdk-cli/src/sub_commands/get_public_keys.rs Outdated
Comment thread crates/cdk-cli/src/sub_commands/get_public_keys.rs
Comment thread crates/cashu/src/nuts/nut00/mod.rs Outdated
Comment thread crates/cdk/src/wallet/multi_mint_wallet.rs Outdated
Comment thread crates/cdk/src/wallet/multi_mint_wallet.rs Outdated
Comment thread crates/cdk/src/wallet/multi_mint_wallet.rs Outdated
@lescuer97
Copy link
Copy Markdown
Contributor Author

@thesimplekid rebased

@thesimplekid thesimplekid self-requested a review January 14, 2026 15:36
@lescuer97 lescuer97 force-pushed the p2pk_receive_wallet branch from b64cc5d to 4093b6c Compare January 15, 2026 09:53
@thesimplekid thesimplekid added this to the 0.15.0 milestone Jan 15, 2026
@thesimplekid thesimplekid moved this from In progress to Ready to merge in CDK Jan 15, 2026
@thesimplekid
Copy link
Copy Markdown
Collaborator

ACK 4093b6c

Comment thread crates/cdk/src/wallet/p2pk.rs Outdated
@github-project-automation github-project-automation Bot moved this from Ready to merge to In progress in CDK Jan 15, 2026
@lescuer97 lescuer97 force-pushed the p2pk_receive_wallet branch 2 times, most recently from 3fccf57 to 251b0f1 Compare January 17, 2026 18:21
@thesimplekid thesimplekid modified the milestones: 0.15.0, 0.16.0 Feb 11, 2026
@lescuer97 lescuer97 force-pushed the p2pk_receive_wallet branch from e23f32f to 2f3829b Compare March 13, 2026 11:55
@lescuer97 lescuer97 force-pushed the p2pk_receive_wallet branch 2 times, most recently from 52c77b3 to 30beade Compare March 20, 2026 20:15
Comment thread crates/cdk-sql-common/src/wallet/mod.rs Outdated
Comment thread crates/cdk-ffi/src/types/wallet.rs Outdated
Comment on lines +759 to +760

pub use cdk_common::wallet::{WalletSaga, WalletSagaState};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure why these are here?

Copy link
Copy Markdown
Contributor Author

@lescuer97 lescuer97 Mar 26, 2026

Choose a reason for hiding this comment

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

don't know either. I remove them

Comment thread crates/cdk/src/wallet/mod.rs
Comment thread crates/cdk/src/wallet/p2pk.rs Outdated

use crate::error::Error;

const CASHU_PURPOSE: u32 = 129373;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is not the cashu purpose

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Im going to change the name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed the name to make it clearer

Comment thread crates/cdk/src/wallet/p2pk.rs Outdated
Comment on lines +12 to +13
const CASHU_PURPOSE: u32 = 129373;
const P2PK_PURPOSE: u32 = 10;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe should link to coco/spec of why we use these.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added some comments on why we use this. plus the PR link

Comment thread crates/cdk/src/wallet/p2pk.rs Outdated
Comment thread crates/cdk/src/wallet/mod.rs Outdated
Copy link
Copy Markdown
Collaborator

@thesimplekid thesimplekid left a comment

Choose a reason for hiding this comment

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

Didn't mean to approve. Sorry :(

@github-project-automation github-project-automation Bot moved this from Ready to merge to In progress in CDK Mar 26, 2026
@lescuer97 lescuer97 requested a review from thesimplekid March 26, 2026 18:10
Comment thread crates/cdk-ffi/src/types/wallet.rs Outdated
Comment thread crates/cdk-cli/src/sub_commands/get_public_keys.rs Outdated
Comment on lines +955 to +972
// P2PK proofs
/// generates and stores public key in database
async fn generate_public_key(&self) -> Result<PublicKey, Self::Error>;

/// gets public key by it's hex value
async fn get_public_key(
&self,
pubkey: &PublicKey,
) -> Result<Option<P2PKSigningKey>, Self::Error>;

/// gets list of stored public keys in database
async fn get_public_keys(&self) -> Result<Vec<P2PKSigningKey>, Self::Error>;

/// Gets the latest generated P2PK signing key (most recently created)
async fn get_latest_public_key(&self) -> Result<Option<P2PKSigningKey>, Self::Error>;

/// try to get secret key from p2pk signing key in localstore
async fn get_signing_key(&self, pubkey: &PublicKey) -> Result<Option<SecretKey>, Self::Error>;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

On second thought. And thinking about how we want to reduce our public api surface, maybe only generate and get latest should be in the public api and the other fns should be on the wallet as pub(crate) this way they can be removed from the trait and ffi?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the 2 that we could remove from the public are get_signing_key and get_public_keys. the others do need to there

Comment thread crates/cdk-redb/src/wallet/mod.rs Outdated
Comment thread crates/cdk-sql-common/src/wallet/mod.rs
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 24.92308% with 244 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@ba5853d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
crates/cdk-common/src/database/wallet/test/mod.rs 0.00% 84 Missing ⚠️
crates/cdk/src/wallet/mod.rs 0.00% 45 Missing ⚠️
crates/cdk-ffi/src/database.rs 0.00% 39 Missing ⚠️
crates/cdk-ffi/src/types/wallet.rs 0.00% 19 Missing ⚠️
crates/cdk-sql-common/src/wallet/mod.rs 0.00% 16 Missing ⚠️
crates/cdk-ffi/src/wallet_trait.rs 0.00% 10 Missing ⚠️
crates/cdk-redb/src/wallet/migrations.rs 0.00% 10 Missing ⚠️
crates/cdk-redb/src/wallet/mod.rs 9.09% 10 Missing ⚠️
crates/cdk/src/wallet/wallet_trait.rs 0.00% 10 Missing ⚠️
crates/cdk/src/wallet/receive/saga/mod.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1466   +/-   ##
=======================================
  Coverage        ?   61.91%           
=======================================
  Files           ?      331           
  Lines           ?    56176           
  Branches        ?        0           
=======================================
  Hits            ?    34784           
  Misses          ?    21392           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thesimplekid thesimplekid merged commit 7966d59 into cashubtc:main Mar 27, 2026
90 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in CDK Mar 27, 2026
crodas pushed a commit to crodas/cdk that referenced this pull request May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants