fix(wallet): locate self-sent notes by nullifier

This commit is contained in:
Artem Gureev 2026-07-07 18:06:46 +00:00 committed by agureev
parent ceaf7fd4f0
commit 5d2b4a672a
2 changed files with 23 additions and 1 deletions

View File

@ -494,9 +494,16 @@ impl WalletCore {
tx: &lee::privacy_preserving_transaction::PrivacyPreservingTransaction,
acc_decode_mask: &[AccDecodeData],
) -> Result<()> {
for (output_index, acc_decode_data) in acc_decode_mask.iter().enumerate() {
for acc_decode_data in acc_decode_mask {
match acc_decode_data {
AccDecodeData::Decode(secret, acc_account_id) => {
let Some(output_index) = self
.storage
.key_chain()
.locate_spend(*acc_account_id, &tx.message)
else {
continue;
};
let acc_ead = tx.message.encrypted_private_post_states[output_index].clone();
let (kind, res_acc) = lee_core::EncryptionScheme::decrypt(

View File

@ -445,6 +445,21 @@ impl UserKeyChain {
Some(new_nullifier)
}
#[must_use]
pub fn locate_spend(&self, account_id: AccountId, message: &Message) -> Option<usize> {
let init = Nullifier::for_account_initialization(&account_id);
let update = self.private_account(account_id).map(|acc| {
Nullifier::for_account_update(
&Commitment::new(&account_id, acc.account),
&acc.key_chain.private_key_holder.nullifier_secret_key,
)
});
message
.new_nullifiers
.iter()
.position(|(nullifier, _)| *nullifier == init || Some(nullifier) == update.as_ref())
}
pub fn add_imported_public_account(&mut self, private_key: lee::PrivateKey) {
let account_id = AccountId::from(&lee::PublicKey::new_from_private_key(&private_key));