I've tested some mutations related to test coverage for PSBT unknown field merging and discovered an inconsistency.
<details>
If line 71 of psbt.cpp "unknown.insert(psbt.unknown.begin(), psbt.unknown.end());" (inside bool PartiallySignedTransaction::Merge(const PartiallySignedTransaction& psbt) function) is removed then, the expected test fails: "Test that combining PSBTs preserves unknown fields with the same and with distinct values per map."
If line 434 of psbt.cpp "unknown.insert(input.unknown.begin(), input.unknown.end());" (inside bool PSBTInput::Merge(const PSBTInput& input) function), is removed, a different unexpected test fails: "Test that unknown values are just passed through".
If line 537 of psbt.cpp "unknown.insert(output.unknown.begin(), output.unknown.end());" (inside bool PSBTOutput::Merge(const PSBTOutput& output) function), is removed, the expected test fails: "Test that combining PSBTs preserves unknown fields with the same and with distinct values per map.".
</details>
This PR solves this inconsistency. The old code did 3 different things:
- Test the pass-through of unknown values for
walletprocesspsbt. - Combine two v0 PSBTs with different unknown input keys and check that both keys survive.
- Combine implicit v0 PSBT with explicit v0 and check that both keys survive.
Case 2 is already fully covered by the existing test_combinepsbt_preseves_unknown_fields so keeping it is redundant and misleading.
Commit 40eba5eb20ba0041a6328ba3482fcc26ddbe0185 moves the old code into a new method called test_unknown_fields_passthrough and commit ef4310097bd651497a98a9d1bb59560a7055ae01 removes the redundant code of Case 2 and moves Case 3 inside test_combinepsbt_preserves_unknown_fields.