Use native rust-bitcoin methods for weight calculations
See https://github.com/payjoin/rust-payjoin/issues/353
This deletes the custom weight.rs traits and input_type.rs helpers in favor of out-of-the-box rust-bitcoin methods. It also removes the unused output_type.rs.
A question that may be relevant to this PR: do we want to commit to allowing mixed input types (despite it being a violation of the BIP78 spec) to better enable batching use cases? Maybe we could introduce a allow_mixed_input_types parameter that can be set by the sender and defaults to false if not set?
pretty massive delete! eager to follow
I'm partial to allow mixed input types, and that opinion appears to be consensus. In addition, allow by default is more permissive and should have fewer failed attempts, I'm not sure I'd even want to expose the option unless it were strictly necessary for a downstream usecase if the logic weren't already in the codebase for v1.
@DanGould Summary of changes since your last review:
- Fixed the
try_foldissue you brought up. - Removed the
input_typeandsequencefields from the ContextV1 and RequestContext structs, as they can be computed from the original psbt. - Added a unit test for input weight calculations. I used payjoin-cli with
RUST_LOG=traceto generate and obtain the original and payjoin PSBT values, and a new bitcoin-cli wallet for each address type.
- Try_fold fix looks good
- input_type and sequence removal also looking good
I haven't checked the PSBT values in the known-weight tests, so I'm on that tomorrow. I think that's the last substantive check to make.
Thanks - fixed the clippy warnings and test name.