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;
}
Published at
2022-12-09 00:46:17Event JSON
{
"id": "d50cdfe66a4bd5a6317bbe9a108a12f7ca822f0c011d0f744559a2105236be00",
"pubkey": "5c10ed0678805156d39ef1ef6d46110fe1e7e590ae04986ccf48ba1299cb53e2",
"created_at": 1670546777,
"kind": 1,
"tags": [
[
"e",
"f04c12f13467f1af68817979f65ea91a91b5cf2131644265f7c43155d5fc7ae9",
"",
"root"
],
[
"e",
"0c00835befce8f581c7c89160e21ec073c87e5b43206631531e7856b4dbb491c",
"",
"reply"
],
[
"p",
"2b36fb6ae1022d0d4eac2a9f13fc2638f3350acc9b07bdca1de43a7c63429644"
]
],
"content": "Alright, here's my new version:\n\nfunction isLikelyCoinjoin(txdata) {\n // Check number of inputs/outputs\n const numInputs = txdata.vin.length;\n const numOutputs = txdata.vout.length;\n if (numInputs \u003e 1 \u0026\u0026 numOutputs \u003e 2) { \n // Check outputs have close to the same value\n let outputValues = txdata.vout.map(o =\u003e o.value);\n outputValues.sort((a, b) =\u003e a - b);\n let difference = outputValues[numOutputs - 1] - outputValues[0];\n if (difference \u003c 0.001) {\n // Check if there are at least 2 clusters of 2 or more outputs with identical output values\n let isClustered = outputValues.some(v =\u003e \n outputValues.filter(v2 =\u003e v2 === v).length \u003e= 2);\n if (isClustered) {\n return true;\n }\n }\n }\n return false;\n}",
"sig": "07dbecbbe728525ff82363269c9a6e9a5635594ce7a9f0eaf29ab41b26ce7622243ea45e3c1813233cbffe0bbc7bdb5ff0d79427ea4fb2ef9a27621dad109ea2"
}