Skip to content

Detecting non-segwit proposal broadcast #1214

@arminsabouri

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.

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