I need to send Zcash signed with WIF from nodejs.
I have a sample code but don't understand how to use whis.
Is there a simpest code or way to send zcash signed with WIF?
Thanks.
This is my code:
const bitcoinJSForks = require('bitcoinforksjs-lib');
const bitcoinZcash = require('bitcoinjs-lib-zcash');
const bitcoinPos = require('bitcoinjs-lib-pos');
const bitcoin = require('bitcoinjs-lib');
const utils = require('./utils');
const coinselect = require('coinselect');
// single sig
const transaction = (sendTo, changeAddress, wif, network, utxo, changeValue, spendValue, opreturn) => {
let key = network.isZcash ? bitcoinZcash.ECPair.fromWIF(wif, network) : bitcoin.ECPair.fromWIF(wif, network);
let tx;
let btcFork = {};
if (network.isZcash) {
tx = new bitcoinZcash.TransactionBuilder(network);
} else if (network.isPoS) {
tx = new bitcoinPos.TransactionBuilder(network);
} else if (network.isBtcFork) {
tx = new bitcoinJSForks.TransactionBuilder(network);
const keyPair = bitcoinJSForks.ECPair.fromWIF(wif, network);
btcFork = {
keyPair,
pk: bitcoinJSForks.crypto.hash160(keyPair.getPublicKeyBuffer()),
spk: bitcoinJSForks.script.pubKeyHash.output.encode(bitcoinJSForks.crypto.hash160(keyPair.getPublicKeyBuffer())),
};
} else {
tx = new bitcoin.TransactionBuilder(network);
}
}