test zcash

node v8.17.0
version: 2.0.0
endpointsharetweet
var bs58check = require('bs58check') ; // https://github.com/bitcoinjs/bs58check const assert = require('assert'); var safebuffer = require("safe-buffer"); /** * Converts a Bitcoin "Pay To Public Key Hash" (P2PKH) public * address to a ZCash t-address. (Such Bitcoin addresses always * start with a '1'. * * The same private key (aka "spending key") that generated * the Bitcoin address can be used to control funds associated * with the ZCash t-address. (This requires a ZCash wallet system * which allows that private key to be imported. For example, * zcashd with its `importprivkey` function.) */ function baddr_to_taddr() { var baddr_str = "15CZMQGP6KPm2HFdCqkKAiQ4sPDcDHBNgV"; var baddr = bs58check.decode(baddr_str).slice(1); // discard type byte console.log(baddr); var taddr = new Uint8Array(22); taddr.set(baddr, 2); console.log(taddr); taddr.set([0x1c,0xb8], 0); // set zcash type bytes console.log(taddr); console.log(Buffer.from(taddr)); return bs58check.encode(Buffer.from(taddr)); } console.log(baddr_to_taddr());
Loading…

no comments

    sign in to comment