mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-07-09 15:29:34 +00:00
fix(wallet): locate self-sent notes by nullifier
This commit is contained in:
parent
ceaf7fd4f0
commit
5d2b4a672a
@ -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(
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user