Skip to content

Detecting non-segwit proposal broadcast #1214

Closed

Description

@arminsabouri

As of 956c8b6 we detect the broadcast of a pj proposal with non-segwit inputs by looping through all the inputs of the proposal and checking if they were all spent. This is flawed.

if outpoints_spend == payjoin_proposal.unsigned_tx.input.len() {
            // All the payjoin proposal outpoints were spent. This means our payjoin proposal has non-segwit inputs and is broadcasted.
            return MaybeFatalOrSuccessTransition::success(SessionEvent::Closed(
                // TODO: there seems to be not great way to get the tx of the tx that spent these outpoints.
                SessionOutcome::Success(vec![]),
            ));
        }

If some of them were spent but not all we consider this a double spend.

else if outpoints_spend > 0 {
            // Some outpoints were spent but not in the payjoin proposal. This is a double spend.
            return MaybeFatalOrSuccessTransition::success(SessionEvent::Closed(
                SessionOutcome::Failure,
            ));
        } 

And if none of them were spent then the receiver is still monitoring for activity.
However all of the proposal outpoints could just be spent in seperate txs unrelated to the payjoin. The API would still consider this a successful Payjoin.
I don't have a great proposed solution for detecting a payjoin with non-segwit inputs at the time of writing this. If the proposal includes non-segwit inputs the reciever could just skip the monitoring typestate all together.

Activity

  1. mehmetefeumit commented on Dec 5, 2025

    @mehmetefeumit
    Contributor

    Expanding on the issue, the current implementation results in the following: whenever the sender spends the original proposal UTXO in another transaction, Receiver is going to treat it as a double-spend attack. So if the sender does RBF (as talked about in the integration test PR), or simply decides to use the UTXO in another payment while the v2 Payjoin is still on-going, then the Receiver treats that action as a double-spend attempt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions