vanitygen-plusplus icon indicating copy to clipboard operation
vanitygen-plusplus copied to clipboard

Tronlink unrecognized PK format

Open CashCode opened this issue 1 year ago • 0 comments

Hello, Sirs

It's dublicate of issue #75 When we use older version it give a PK in format:

TRX Privkey: 1MmbZJRoHKX75mC2neUGimxvsZyZpf6KBxoNDVxogH3kevW424

It's not base58, from commit it was fixed:

  if (strncmp(ticker, "TRX", 3) == 0) {
    // For tron, output hex string for private key
    char *buf = BN_bn2hex(EC_KEY_get0_private_key(pkey));
    strcpy(privkey_buf, buf);
    if (buf) OPENSSL_free(buf);
  }

I'm asking for a hint how to convert previously generated format PK into hex one, which is acceptable for tronlink. I think many people, especially on windows struggling to convert.

I tried on fast hand in this way, but it's not correct:

const bs58 = require('bs58');
const { ec: EC } = require('elliptic');

const arrayToHex = (uint8Array) =>
  Array.from(uint8Array)
    .map((byte) => byte.toString(16).padStart(2, '0'))
    .join('');

function convertBase58ToHex(base58Key) {
  const privateKeyBytes = bs58.decode(base58Key);
  const privateKeyHex = privateKeyBytes.slice(1, -4);
  return arrayToHex(privateKeyHex);
}

const privateKeyBase58 = '1oqSVtJJBpWKpRwpqeuSKvb7v39RwJYCdZQj6Fuw2hkg9Xipek';
const privateKeyHex = convertBase58ToHex(privateKeyBase58);

console.log(privateKeyHex);

//result should be a PK of TXXXGFPPqUHy6X4kcD6gcyAqtjyozYsgqa address, but it's private key from another address

CashCode avatar Jun 12 '23 23:06 CashCode