Why Nostr? What is Njump?
2022-12-09 00:46:17
in reply to

dave on Nostr: Alright, here's my new version: function isLikelyCoinjoin(txdata) { // Check number ...

Alright, here's my new version:

function isLikelyCoinjoin(txdata) {
// Check number of inputs/outputs
const numInputs = txdata.vin.length;
const numOutputs = txdata.vout.length;
if (numInputs > 1 && numOutputs > 2) {
// Check outputs have close to the same value
let outputValues = txdata.vout.map(o => o.value);
outputValues.sort((a, b) => a - b);
let difference = outputValues[numOutputs - 1] - outputValues[0];
if (difference < 0.001) {
// Check if there are at least 2 clusters of 2 or more outputs with identical output values
let isClustered = outputValues.some(v =>
outputValues.filter(v2 => v2 === v).length >= 2);
if (isClustered) {
return true;
}
}
}
return false;
}
Author Public Key
npub1tsgw6pncspg4d5u778hk63s3pls70evs4czfsmx0fzap9xwt203qtkhtk4