cryptocoinjs / coininfo

JavaScript component for crypto currency specific information.
116 stars 114 forks source link

Can we use coininfo and coinkey to create zcash address/private key #40

Closed coincrypto closed 6 years ago

coincrypto commented 6 years ago

@fanatid sorry to bother you, but I have a question. Can we use coininfo and coinkey to create zcash address/private key? If so, could you give example please!. I tried but seem address created is invalid. I googled it but could not find. Thank you very much!

fanatid commented 6 years ago

Zcash is same as Bitcoin, but 2 bytes as version... you should check coininfo sources, you will find values.

    const sha = crypto.createHash('sha256').update(publicKey).digest()
    const pubKeyHash = crypto.createHash('rmd160').update(sha).digest()
    const payload = Buffer.allocUnsafe(22)
    payload.writeUInt16BE(coinInfo(name).versions.public)
    pubKeyHash.copy(payload, 2)
    return bs58check.encode(payload)
coincrypto commented 6 years ago

Thank you very much. It was helped me a lot.