Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In zcashlc_propose_shielding, when transparent_receiver is null select the first taddr that has sufficient funds to shield #171

Open
daira opened this issue Nov 26, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@daira
Copy link
Contributor

daira commented Nov 26, 2024

@str4d:

consider altering the Rust FFI backend to filter by threshold and then select the first taddr after that (so it doesn't get stuck always trying to select a taddr with insufficient funds to shield).

let from_addrs = if let Some((addr, _)) = transparent_receiver.map_or_else(||
if account_receivers.len() > 1 {
Err(anyhow!(
"Account has more than one transparent receiver with funds to shield; this is not yet supported by the SDK. Provide a specific transparent receiver to shield funds from."
))
} else {
Ok(account_receivers.iter().next().map(|(a, v)| (*a, *v)))
},
|addr| Ok(account_receivers.get(&addr).map(|value| (addr, *value)))
)?.filter(|(_, value)| *value >= shielding_threshold) {
[addr]
} else {
// There are no transparent funds to shield; don't create a proposal.
return Ok(FfiBoxedSlice::none());
};

Note that essentially the same code is implicated here and in Electric-Coin-Company/zcash-android-wallet-sdk#1643 . It may be preferable to move the logic for selecting which taddr to shield from by default into librustzcash, so that it can be shared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant