feat(wallet): create a regular shared account under a supplied identifier

This commit is contained in:
Artem Gureev 2026-07-10 17:49:18 +00:00 committed by agureev
parent ce0d0c4886
commit 4d91d6f7cb
2 changed files with 17 additions and 5 deletions

View File

@ -111,8 +111,9 @@ pub enum NewSubcommand {
#[arg(long, requires = "pda")]
/// Program ID as hex string.
program_id: Option<String>,
#[arg(long, requires = "pda")]
/// Identifier that diversifies this PDA within the (`program_id`, seed, npk) family.
#[arg(long)]
/// Identifier selecting the shared account.
/// Co-owners must supply the same value to derive the same account.
/// Defaults to a random value if not specified.
identifier: Option<u128>,
},
@ -237,6 +238,10 @@ impl NewSubcommand {
identifier.unwrap_or_else(rand::random),
)
.await?
} else if let Some(id) = identifier {
wallet_core
.create_shared_regular_account_with_identifier(group.clone(), id)
.await?
} else {
wallet_core
.create_shared_regular_account(group.clone())

View File

@ -439,14 +439,21 @@ impl WalletCore {
})
}
/// Create a shared regular private account from a group's GMS. Returns the `AccountId` and
/// derived keys. The derivation seed is computed deterministically from a random identifier.
/// Create a shared regular private account from a group's GMS with a random identifier.
pub async fn create_shared_regular_account(
&mut self,
group_name: Label,
) -> Result<SharedAccountInfo> {
let identifier: lee_core::Identifier = rand::random();
self.create_shared_regular_account_with_identifier(group_name, rand::random())
.await
}
/// Create a shared regular private account from a group's GMS under the given `identifier`.
pub async fn create_shared_regular_account_with_identifier(
&mut self,
group_name: Label,
identifier: lee_core::Identifier,
) -> Result<SharedAccountInfo> {
let holder = self
.storage
.key_chain()