Repository navigation
Description
The purpose of this ticket is to collect improvements to receiver coin selection and output creation so that the resulting PayJoin transaction has a plausible trivial sub tx mapping and its more likely than other interpertations.
The current receiver strategy is:
- If output subsitution is allowed, add outputs / substitute output.
- Select a candidate input that avoids UIH2: the smallest input must exceed the smallest output
- Bump the payment output by exactly the receiver's input value (drain bump)
When no candidate passes the UIH2 check, the implementation falls back to selecting the first available candidate regardless. Technically this could be represented as a transient error and the implementation can decide wether to broadcast the fallback or produce a PJ with a UIH2 marker. UIH arguably is worse bc it definetly leaks idiosyncratic distribution.
An alternative raised during mob programming: split the receiver's outputs such that no single output is smaller than the receiver's input, simulating a batch payment and avoiding UIH2 without requiring a large input. How common is the peelchain-like structure in practice? Example Cake to BB tx. It seems like some data collection here is neccessary.
The cost is twofold. First, additional block space. Second and more importantly: the resulting outputs must never be spent together. Doing so reinstates CIH linkage and retroactively degrades the PayJoin.
What would the interface of this look like? Wallets today don't keep track of what UTXOs should NOT be spent together. Perhaps we have an oppurtunity to set the standard here.
Another observation: Input selection is not scored. The current loop returns the first UIH2-passing candidate. Among all passing candidates, those closest in magnitude to the sender's inputs are strictly preferable as they minimize value asymmetry, reduce the size signal UIH2 is a proxy for, and make the trivial mapping harder to distinguish from the two-party interpretation.
Perhaps another way of stating the problem and solution: input selection and output construction should be treated as a joint optimization. Given:
- Sender inputs
$I_S$ and outputs$O_S$ (fixed) - Receiver candidate UTXOs
$\mathcal{C}$ - Outputs the receiver must create
- Outputs the receiver is willing to create (e.g. via splitting)
Select
Concrete tickets are TBD. First wanted to put my thoughts on paper
Activity
bc1cindy commentedon Mar 17, 2026
hey @arminsabouri !
I'm very curious and excited about this area. Yesterday I was reading about fingerprints and found this repo (https://github.com/ishaanam/wallet-fingerprinting), so I started using to make some tests based on (https://github.com/payjoin/research-docs/blob/main/fingerprints/payjoin.md), and I saw your issue today, so I made a python script to collect data using a fork of the repo that I have locally, following the methodology bellow:
100 blocks sampled uniformly across the last ~2 years (blocks ~835,898–941,018, one every ~1,051 blocks), 200 random transactions per block, ~20,000 transactions total. Data via mempool.space public API. Coinbase transactions and OP_RETURN outputs excluded
Primary criterion requires all three simultaneously: 2+ inputs, 3+ outputs, and
min(inputs) > min(outputs)Relaxed criterion structural match only: 2+ inputs, 3+ outputs, no value check. The gap between the two figures isolates how many transactions have the right structure but fail specifically on UIH2.
for transactions passing the primary criterion, input asymmetry
(max(inputs) / min(inputs))was also recorded to address the scoring observation in the issue among UIH2-passing candidates. A ratio close to 1.0 means both inputs are similar in value, and high ratio (e.g. 10x) means that one input is much larger than the otherafter 5 hours running:
here are some of the txids saved:
i was also thinking that could be good to contribute to (https://github.com/0xB10C/mainnet-observer) to have the data we may need being monitored
digging more around the interface point, I see that when the receiver reaches the
PayjoinProposalstate, it already has all the info needed to create an isolation group: the set of output outpoints that must never be combined in a future spend. The wallet receives this group and persists it locally, encrypted alongside other UTXO metadata, never forwarded to the sender. This is the same pattern Samourai implemented withBlockedUTXOfor Whirlpool outputs.The coin selector can honor the group before constructing any future transaction, it checks whether any pair of selected UTXOs belongs to the same isolation group. If so, the combination is discarded.
if it's useful, I'm happy to run other scripts, in a different temporal spread, or criterions and help with what's needed!
bc1cindy commentedon Mar 17, 2026
i also found this repo, that may be helpful (https://github.com/Samourai-Wallet/boltzmann)
arminsabouri commentedon Mar 18, 2026
Wow that is odd. Almost 50% are one input one output txs? Do these txs have any other similarities? Are they cpfp'ing? These questions are not related to the ticket but just curious what the story here is.
Thanks for showing interest here. On-chain data def helps us make more informed choices (specifically whether or not to split outputs and understanding how bad of a problem this is). Im also curious if these consolidation txs are during fee rate dips. In the data set you collected what is the precentage of UIH2 flagged 2-input 2-output txs?
PS: this kind of data collection pipeline is exactly what https://github.com/payjoin/tx-indexer was designed for. Its a work in progress but just wantted to mention it
bc1cindy commentedon Mar 19, 2026
Do outputs get spent together?
62.7% of candidates contain P2PKH in some input or output, compared to 15.1% in the baseline, a difference of +47.6 pp. P2PKH is a legacy script type, practically absent in modern wallets. 44.1% have at least one output with a value divisible by 10,000 sat, compared to 6.3% in the baseline +37.8 pp. Round outputs are characteristic of exchange payments where the value is a clean number. 93.2% have locktime=0, without anti-fee-sniping, Bitcoin Core has enabled anti-fee-sniping by default since 2014. Only 10.2% have Taproot input, compared to 35.4% in the baseline -25.2 pp.
282 transactions in the dataset have the structure that output splitting would produce, 1.4% of the total. Of these, 25.2% also pass the UIH2-check.