Skip to content

Wallet should be able to store multiple transactions with same txid #11240

@sdaftuar

Description

@sdaftuar

Pre-segwit, malleated transactions would have a different txid and therefore be accepted and stored by the wallet when seen on the network.

Post-segwit, it's possible for a malleated transaction that is seen on the network to be ignored by the wallet, because we index the wallet db by txid, and we are currently only able to store one entry for a given txid (and I have no idea whether this assumption is easy to change). This means that if a malleated transaction were mined on the network, we would only store the original version of the transaction. While this doesn't appear to have any direct impact on our wallet's behavior, this could frustrate wallet users who expect the stored transaction to be the same as the one mined.

Within the current paradigm (of storing a single transaction per txid), we could instead store the latest seen version of any transaction, so that if a malleated version of a transaction is mined, that will get stored in our wallet and we'd forget about any previous version. However, that isn't an ideal solution either: suppose the malleated version of the transaction violates local mempool policy, and the block containing the malleated transaction gets reorged out. If the wallet would replace the non-malleated transaction with the malleated one when it was received, we'd have no way to rebroadcast the transaction again after such a reorg. And since I think losing a signed transaction (which we may not be able to reproduce) is a terrible outcome, I think we should for now continue to keep whatever original signed version of a transaction that we see, and not replace.

Slightly relevant to this: #11225 adds the ability to replace a transaction that has no witness with one that has a witness, under the reasoning that this is only possible if we have upgraded a wallet that was pre-segwit, and are now receiving the full transaction post-upgrade. Since any transaction that is valid with a witness must be invalid under segwit's rules without the witness, doing this specific replacement should put the wallet in a strictly better position (where it might now be storing a valid transaction, which is possibly the same as the version of the transaction which was/will be mined).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions