fix private shared account preparation

This commit is contained in:
Sergio Chouhy 2026-05-12 17:17:58 -03:00
parent 67b6916b72
commit bc65c877af
4 changed files with 22 additions and 15 deletions

View File

@ -155,7 +155,6 @@ async fn group_invite_join_key_agreement() -> Result<()> {
/// Fund a shared account from a public account via auth-transfer, then sync.
/// TODO: Requires auth-transfer init to work with shared accounts (authorization flow).
#[test]
#[ignore = "Requires auth-transfer init to work with shared accounts (authorization flow)"]
async fn fund_shared_account_from_public() -> Result<()> {
let mut ctx = TestContext::new().await?;
@ -190,6 +189,10 @@ async fn fund_shared_account_from_public() -> Result<()> {
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
// Sync private accounts
let command = Command::Account(AccountSubcommand::SyncPrivate);
wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
// Fund from a public account
let from_public = ctx.existing_public_accounts()[0];
let command = Command::AuthTransfer(AuthTransferSubcommand::Send {

View File

@ -178,6 +178,7 @@ impl NSSAUserData {
}
/// Returns the key chain and account data for the given private account ID.
/// Does not cover shared private accounts — use `shared_private_account` for those.
#[must_use]
pub fn get_private_account(
&self,

View File

@ -505,8 +505,17 @@ impl WalletCore {
#[must_use]
pub fn get_private_account_commitment(&self, account_id: AccountId) -> Option<Commitment> {
let (_keys, account, _identifier) =
self.storage.user_data.get_private_account(account_id)?;
let account = self
.storage
.user_data
.get_private_account(account_id)
.map(|(_keys, account, _identifier)| account)
.or_else(|| {
self.storage
.user_data
.shared_private_account(&account_id)
.map(|entry| entry.account.clone())
})?;
Some(Commitment::new(&account_id, &account))
}

View File

@ -381,24 +381,18 @@ async fn private_shared_acc_preparation(
.map(|e| e.account.clone())
.unwrap_or_default();
let exists = acc != nssa_core::account::Account::default();
let pre_state = AccountWithMetadata::new(acc, exists, account_id);
let pre_state = AccountWithMetadata::new(acc, true, account_id);
let proof = if exists {
wallet
.check_private_account_initialized(account_id)
.await
.unwrap_or(None)
} else {
None
};
let proof = wallet
.check_private_account_initialized(account_id)
.await
.unwrap_or(None);
let eph_holder = EphemeralKeyHolder::new(&npk);
let ssk = eph_holder.calculate_shared_secret_sender(&vpk);
let epk = eph_holder.generate_ephemeral_public_key();
Ok(AccountPreparedData {
nsk: exists.then_some(nsk),
nsk: Some(nsk),
npk,
identifier,
vpk,