Recover ICP sent to the wrong account id?

Alright, I feel dumb making this kind of post but the thing that i swore would never happen to me just happened.

I was working on a project using the Go agent and i created a new identity.

Unfortunately the Go agent does not seem to have a built in method to retrieve the Account ID from the Principal address so i searched the forum but most likely fucked up a part and ended up with a wrong account id to which i sent some ICP.

Wrong account: b4e92e7f3ba6f52bcb2caef4364816fb4069248f0690e2e4c97dd3746e7dd72a
Correct account: 49c6f48b07a23481933217ccb43819dd22b9b205809d66529be22d5ab0067000

Now, the fateful question, is there something i can do or i call it a day and just forget about those ~16 ICP i lost?

Thanks and sorry once again.

1 Like

Edit: if you take a look you can see that i also sent some ICPs to the correct address, but switched them up somehow when i sent the “big” ~16 ICP bag

Where did the wrong address came from? Just thinking that maybe there could be a way you can send back!

I used some algorithm, which is most likely wrong, to get it from the Principal address:

func asciiStringToByteArray(s string) []byte {
	return []byte(s)
}

func bigEndianCrc32(data []byte) []byte {
	crc := crc32.ChecksumIEEE(data)
	crcBytes := make([]byte, 4)
	crcBytes[0] = byte(crc >> 24)
	crcBytes[1] = byte(crc >> 16)
	crcBytes[2] = byte(crc >> 8)
	crcBytes[3] = byte(crc)
	return crcBytes
}

func GetAccountIDFromPrincipal(principalID principal.Principal, subAccount []byte) string {
	padding := asciiStringToByteArray("\x0Aaccount-id")

	if subAccount == nil {
		subAccount = make([]byte, 32)
	}

	data := append(padding, principalID.Raw...)
	data = append(data, subAccount...)

	sha := sha3.New224()
	sha.Write(data)
	hash := sha.Sum(nil)

	checksum := bigEndianCrc32(hash)

	finalBytes := append(checksum, hash...)

	return hex.EncodeToString(finalBytes)
}

I see, I’m not sure at this point, I don’t think it’s possible to retrieve :frowning:

1 Like

I also don’t see a way to recover those ICP. Account IDs are by design non-reversible, so there is no way to figure out who owns those ICP (unless you wait until sha3 is broken, which could take decades), and even if you know the owner, you need the corresponding private key, which again is designed to be non-reversible

1 Like