Refactor `try_preserving_privacy` for correctness and flexibility
Original Title:
try_preserving_privacyshould take something more flexible thanHashMap
Some people might want to use a database or a different data structure. The type should be something like impl IntoIterator + Index<OutPoint>
Since mixed input types aren't allowed in BIP 78 It should alto filter candidate inputs by sender input type or else the sender will reject the proposal. Perhaps a better name would be find_candidate_input_contribution.
It may also be helpful for larger wallets to be able to find multiple candidate input contributions.
Edit for anyone taking this on: Address each comment in this issue separately. Yes try_preserving_privacy could probably use a big refactor but approaching it piecemeal will ease review and better guarantee success.
It seems like the Index is used for in-memory data structures, not databases, and at least for now, our try_preserving_privacy implementation only needed to iterate. So the solution was just to use impl IntoIterator<(Amount, OutPoint)>