rust-payjoin icon indicating copy to clipboard operation
rust-payjoin copied to clipboard

Refactor `try_preserving_privacy` for correctness and flexibility

Open Kixunil opened this issue 2 years ago • 1 comments

Original Title: try_preserving_privacy should take something more flexible than HashMap

Some people might want to use a database or a different data structure. The type should be something like impl IntoIterator + Index<OutPoint>

Kixunil avatar May 10 '23 21:05 Kixunil

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.

DanGould avatar Oct 04 '23 16:10 DanGould

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)>

DanGould avatar Oct 07 '24 19:10 DanGould