SyncMetaData is intended to handle the case of malleated transactions by copying the metadata from a presumed original transaction to all of the malleations of that transaction. However, it did not do this correctly, leading to both a crash that can be reached during bumpfee, and failing to actually copy the metadata to some malleated transactions.
The crash was reachable by having both the original transaction and a malleation of it in the wallet, then calling bumpfee on the original, and then calling bumpfee on the malleation. Calling bumpfee on the malleation would result in an assertion failure in MarkReplaced, hitting Assert(!wtx.m_replaced_by_txid);. This is reached since adding the RBF to the wallet causes a metadata sync between the original and the malleation, which copies m_replaced_by_txid. MarkReplaced is called soon afterwards, resulting in the crash. This is fixed by syncing the metadata after MarkReplaced sets replaced_by_txid during the RBF of the original transaction so that bumpfee refuses to bump the malleation in the first place as it will check m_replaced_by_txid before bumping.
The other issue is that if a RBF transaction is malleated, SyncMetaData was not copying the metadata from the original RBF transaction to the malleation.
These are fixed by changing SyncMetaData to find all of the malleations of a transaction rather than all of the conflicts and simplifying how it is called. Additionally, CWalletTx::IsEquivalentTo is used by SyncMetaData to determine whether a transaction is a malleation, and this PR pulls in #32723 (comment) to make it explicitly clear which fields it is actually checking to determine the equivalence. Lastly, SyncMetaData is renamed to SyncMalleatedTxMetadata and IsEquivalntTo renamed to IsMalleation to clarify that these functions are for handling malleated txs.
The last 2 commits of this PR adds tests for these cases, and the first commit a test for basic SyncMalleatedTxMetadata functionality that should not change here.