herrBez / Nduja

Nduja is a software that de-anonymize crypto-currencies' addresses
BSD 3-Clause "New" or "Revised" License
4 stars 4 forks source link

Remove duplicate different case #56

Closed mzanella closed 6 years ago

mzanella commented 6 years ago

Ethereum can have addresses of type 0x<20 bytes> or <20 bytes>

herrBez commented 6 years ago

The query to get the duplicate addresses is the following:

SELECT DISTINCT lower(w1.Address)
FROM Wallet as w1, Wallet as w2
WHERE w1.Currency = 'ETH' AND w2.Currency = 'ETH' 
AND w1.Address != w2.Address AND 
(w1.Address = w2.Address COLLATE NOCASE)
herrBez commented 6 years ago

From the command line one can simply write this:

DROP TABLE IF EXISTS _Variables; 
CREATE TEMP TABLE _Variables(A text);

INSERT INTO _Variables ( A ) 
    SELECT DISTINCT lower(w1.Address)
    FROM Wallet as w1, Wallet as w2, AccountWallet as aw1, AccountWallet as aw2
    WHERE w1.Currency = 'ETH' AND w2.Currency = 'ETH' 
    AND w1.Address = aw1.Wallet AND w1.Address != w2.Address AND aw1.RawUrl = 
aw2.RawUrl AND w2.Address = aw2.Wallet AND (w1.Address = w2.Address COLLATE 
NOCASE);

DELETE FROM AccountWallet WHERE Wallet in (SELECT * FROM _Variables);

DELETE FROM Wallet WHERE Address in (SELECT * FROM _Variables);

DROP TABLE _Variables;
herrBez commented 6 years ago

To simplify the solution of this issue it is better to do before: #55 (Indeed there are some entries of this kind)

herrBez commented 6 years ago
mzanella commented 6 years ago
SELECT a1.Address
FROM Wallet AS a1
WHERE UPPER(a1.Address) IN  (
    SELECT UPPER(a2.Address) 
    FROM Wallet AS a2
    GROUP BY UPPER(a2.Address) 
    HAVING COUNT(*) > 1
)
 ORDER BY a1.Address