librustzcash icon indicating copy to clipboard operation
librustzcash copied to clipboard

get_wallet_summary is inconsistent about including funds from mempool txns that can still be mined when min_confirmations == 0

Open daira opened this issue 1 year ago • 2 comments

@str4d wrote at https://github.com/zcash/librustzcash/pull/914/files#r1316507311 :

There is a slight issue here regarding notes that are just about to expire. Without the max(_, 1), with min_confirmations == 0 this would set summary_height to the "mempool height" (chain_height + 1), which is precisely what we want for any transaction in the mempool (that still has a chance of being mined, and thus mined before expiry). Down below in the note selection code, we exclude transactions that have expired as of summary_height (because expiry_height < summary_height) from the balance, which means if someone calls this API with min_confirmations == 0, then about-to-expire funds will disappear from the wallet balance, only to reappear again if the transaction does actually get mined in the last block it can.

I'm fine with this being an edge case we don't handle yet, and instead merging @daira's suggested comment change that we treat min_confirmations == 0 as min_confirmations == 1 for shielded notes.

daira avatar Sep 06 '23 01:09 daira