From d54ea96bba2d801f81e3de09f9c21de1623c1589 Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Fri, 3 Oct 2025 00:44:46 -0300 Subject: [PATCH] remove resetting program owner in wallet privacy commands --- wallet/src/chain_storage/mod.rs | 9 +++++++-- wallet/src/lib.rs | 25 +++++++++++++++++------- wallet/src/token_transfers/deshielded.rs | 2 -- wallet/src/token_transfers/private.rs | 5 ----- wallet/src/token_transfers/shielded.rs | 2 -- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/wallet/src/chain_storage/mod.rs b/wallet/src/chain_storage/mod.rs index fdc9abd..825d51c 100644 --- a/wallet/src/chain_storage/mod.rs +++ b/wallet/src/chain_storage/mod.rs @@ -2,6 +2,7 @@ use std::collections::HashMap; use anyhow::Result; use key_protocol::key_protocol_core::NSSAUserData; +use nssa::program::Program; use crate::config::{InitialAccountData, PersistentAccountData, WalletConfig}; @@ -21,8 +22,12 @@ impl WalletChainStore { public_init_acc_map.insert(data.address.parse()?, data.pub_sign_key); } InitialAccountData::Private(data) => { - private_init_acc_map - .insert(data.address.parse()?, (data.key_chain, data.account)); + let mut account = data.account; + // TODO: Program owner is only known after code is compiled and can't be set in + // the config. Therefore we overwrite it here on startup. Fix this when program + // id can be fetched from the node and queried from the wallet. + account.program_owner = Program::authenticated_transfer_program().id(); + private_init_acc_map.insert(data.address.parse()?, (data.key_chain, account)); } } } diff --git a/wallet/src/lib.rs b/wallet/src/lib.rs index f63515d..116c19e 100644 --- a/wallet/src/lib.rs +++ b/wallet/src/lib.rs @@ -431,9 +431,13 @@ pub async fn execute_subcommand(command: Command) -> Result Result Result= balance_to_move { let program = nssa::program::Program::authenticated_transfer_program(); - from_acc.program_owner = program.id(); - to_acc.program_owner = program.id(); - let sender_commitment = nssa_core::Commitment::new(&from_npk, &from_acc); let receiver_commitment = nssa_core::Commitment::new(&to_npk, &to_acc); diff --git a/wallet/src/token_transfers/shielded.rs b/wallet/src/token_transfers/shielded.rs index 0c9a9e7..5f8dd75 100644 --- a/wallet/src/token_transfers/shielded.rs +++ b/wallet/src/token_transfers/shielded.rs @@ -28,8 +28,6 @@ impl WalletCore { if from_acc.balance >= balance_to_move { let program = nssa::program::Program::authenticated_transfer_program(); - to_acc.program_owner = program.id(); - let receiver_commitment = nssa_core::Commitment::new(&to_keys.nullifer_public_key, &to_acc);