0

I have this sample t-address: t1csbsjLRGYCsRMjM1NdUjeFQkysQG2YefY When I put this address through the following code, I get a return value of false.

var bitcore = require('zcash-bitcore-lib');
var Message = require("zcash-bitcore-message");
var Address=bitcore.Address;
var address = 't1csbsjLRGYCsRMjM1NdUjeFQkysQG2YefY';
Address.isValid(address);

In this other variant also, I get a return value of false:

var bitcore = require('zcash-bitcore-lib');
    var Message = require("zcash-bitcore-message");
    var Address=bitcore.Address;
    var publicKey = 't1csbsjLRGYCsRMjM1NdUjeFQkysQG2YefY';
var address = Address.fromPublicKey(publicKey);
    Address.isValid(address);

Can some explain to me how to get a valid zCash address and public key from t-address?

Thanks.

0

I haven't played with zcash a lot but some things I know for certain.

I have no clue if your t-address is a valid one, or if the bitcore lib is working for zcash but what I do know is the following.

You can only go from public key -> t-address, not the other way around. Given a t-address, you can NOT retrieve the public key by merely cryptography and/or compression. There are exception such as a few scenario where you can retrieve the public key from the blockchain, given that the address has already spent an output.

Just remember, you don't need the public key to validate the correctness of an address. Your second variant is really completely wrong, you're inserting the address as public key. The address is a hashed format of the public key and then base58 encoded.

Your first example is more in the right direction, I don't immediately see anything wrong with it. Maybe try the following.

var bitcore = require('zcash-bitcore-lib');
var Address = bitcore.Address;

//test 1
var address = new Address('t1csbsjLRGYCsRMjM1NdUjeFQkysQG2YefY', 'livenet');
console.log("test1: " + address.isValid() + "\n");

//test 2
console.log("test2: " + Address.isValid('t1csbsjLRGYCsRMjM1NdUjeFQkysQG2YefY') + "\n");

//test 3 (gives error message)
console.log("error validation: " +  Address.getValidationError('t1csbsjLRGYCsRMjM1NdUjeFQkysQG2YefY', 'livenet') + "\n");

The output of the above console logs would be helpful to solving your issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.