zcash / librustzcash

Rust-language assets for Zcash
Other
324 stars 243 forks source link

zcash_client_backend: If a seed is reused, transparent UTXO spends from one wallet may not be detected in the other. #1353

Open nuttycom opened 2 months ago

nuttycom commented 2 months ago

At present, the transparent UTXO set of the wallet is populated by querying for unspent TXOs associated with a set of addresses, and adding those to the wallet's UTXO set, but if a UTXO disappears from that set (because it was spent by a different wallet) we do not have any way of detecting that spend because we do not inspect the transparent inputs on the chain in the same fashion that we do shielded inputs.

One possible "quick fix" for this issue would be to compare the existing UTXO set known to the wallet to the UTXO set returned from lightwalletd, and mark as spent (or otherwise unusable) the TXOs that no longer appear in the UTXO set from lightwalletd, but this is a pretty unsatisfactory approach because handling things in this fashion doesn't give us any way, at present, to recover information about how or where those funds were spent.

In some cases, we should expect this not to be a problem because when a UTXO is shielded, we should then detect the received shielded note from the chain and enhancement of the associated transaction should detect the spend and mark the UTXO as spent.

A complete solution, which will be required for #1349, is to allow the wallet to request transparent input and output information as part of its stream of block data.