mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-16 13:09:33 +00:00
fix private shared account preparation
This commit is contained in:
parent
67b6916b72
commit
bc65c877af
@ -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.
|
/// 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).
|
/// TODO: Requires auth-transfer init to work with shared accounts (authorization flow).
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore = "Requires auth-transfer init to work with shared accounts (authorization flow)"]
|
|
||||||
async fn fund_shared_account_from_public() -> Result<()> {
|
async fn fund_shared_account_from_public() -> Result<()> {
|
||||||
let mut ctx = TestContext::new().await?;
|
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;
|
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
|
// Fund from a public account
|
||||||
let from_public = ctx.existing_public_accounts()[0];
|
let from_public = ctx.existing_public_accounts()[0];
|
||||||
let command = Command::AuthTransfer(AuthTransferSubcommand::Send {
|
let command = Command::AuthTransfer(AuthTransferSubcommand::Send {
|
||||||
|
|||||||
@ -178,6 +178,7 @@ impl NSSAUserData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the key chain and account data for the given private account ID.
|
/// 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]
|
#[must_use]
|
||||||
pub fn get_private_account(
|
pub fn get_private_account(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@ -505,8 +505,17 @@ impl WalletCore {
|
|||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_private_account_commitment(&self, account_id: AccountId) -> Option<Commitment> {
|
pub fn get_private_account_commitment(&self, account_id: AccountId) -> Option<Commitment> {
|
||||||
let (_keys, account, _identifier) =
|
let account = self
|
||||||
self.storage.user_data.get_private_account(account_id)?;
|
.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))
|
Some(Commitment::new(&account_id, &account))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -381,24 +381,18 @@ async fn private_shared_acc_preparation(
|
|||||||
.map(|e| e.account.clone())
|
.map(|e| e.account.clone())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let exists = acc != nssa_core::account::Account::default();
|
let pre_state = AccountWithMetadata::new(acc, true, account_id);
|
||||||
let pre_state = AccountWithMetadata::new(acc, exists, account_id);
|
|
||||||
|
|
||||||
let proof = if exists {
|
let proof = wallet
|
||||||
wallet
|
.check_private_account_initialized(account_id)
|
||||||
.check_private_account_initialized(account_id)
|
.await
|
||||||
.await
|
.unwrap_or(None);
|
||||||
.unwrap_or(None)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let eph_holder = EphemeralKeyHolder::new(&npk);
|
let eph_holder = EphemeralKeyHolder::new(&npk);
|
||||||
let ssk = eph_holder.calculate_shared_secret_sender(&vpk);
|
let ssk = eph_holder.calculate_shared_secret_sender(&vpk);
|
||||||
let epk = eph_holder.generate_ephemeral_public_key();
|
let epk = eph_holder.generate_ephemeral_public_key();
|
||||||
|
|
||||||
Ok(AccountPreparedData {
|
Ok(AccountPreparedData {
|
||||||
nsk: exists.then_some(nsk),
|
nsk: Some(nsk),
|
||||||
npk,
|
npk,
|
||||||
identifier,
|
identifier,
|
||||||
vpk,
|
vpk,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user