|
// HACK: The script pubkey in the original test vector is a nested p2sh witness |
|
// script, which is not correctly supported in our current weight calculations. |
|
// To get around this limitation, this test uses a native segwit script instead. |
too costly in engineering to correctly calculate p2sh witness script? Not supported by rust-bitcoin?
The test is excellent, but I wonder if improper fee estimation is going to bite us elsewhere.
Originally posted by @DanGould in #332 (comment)
Full disclosure: I haven't put too much thought into this yet because my priority was to get a working test and it seemed like a long detour.
My initial hunch was that this issue might fix itself once we implement #353, but now I'm thinking it won't. The problem is that it's impossible to know that a p2sh script pubkey is nested segwit (or generally to know anything about the weight of the corresponding input), without knowing the actual script from final_script_sig for that input. By design, final_script_sig gets cleared beforehand in https://github.com/payjoin/rust-payjoin/blob/master/payjoin/src/receive/mod.rs#L587 for sender inputs, and the receiver has yet to sign their inputs at this point. So final_script_sig is never present when we estimate and apply receiver fees.
I don't know if there's a best practice for this. Maybe we can assume that any p2sh input is nested segwit and make fee estimates based on that? If the script turns out to be something else and min_feerate is not met the sender should reject the payjoin psbt anyway.
It looks like an issue that we need to address but is probably scope creep for this particular PR.
Originally posted by @spacebear21 in #332 (comment)
rust-payjoin/payjoin/src/receive/mod.rs
Lines 976 to 978 in 59c3d27
Originally posted by @DanGould in #332 (comment)
Originally posted by @spacebear21 in #332 (comment)