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

This commit is contained in:
Artem Gureev 2026-07-07 18:06:46 +00:00
parent 831a90d5c6
commit e44c368477
2 changed files with 23 additions and 1 deletions

View File

@ -556,9 +556,16 @@ impl WalletCore {
"Decode mask has {} entries but the transaction has {note_count} notes",
acc_decode_mask.len(),
);
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

@ -453,6 +453,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));