Skip to content

Instantly share code, notes, and snippets.

@smdmitry
Created October 29, 2018 14:06
Show Gist options
  • Save smdmitry/9c0caf75f694edb2b8e0d6a9c4c11005 to your computer and use it in GitHub Desktop.
Save smdmitry/9c0caf75f694edb2b8e0d6a9c4c11005 to your computer and use it in GitHub Desktop.
const bitGoUTXO = require('bitgo-utxo-lib');
const wif = '******';
const inputAmount = 1000000;
const minerFee = 1000;
const inputTxId = '83ec80bdecd69def653209f86d45621d54885c3def2590a62eb8bc7218477e27';
const inputOutputN = 0;
const toAddress = 't1YjypJzDtHkPZVQ8nLu5xFGxbBPjydK2SS';
const inputScriptHex = '76a9140ec26089e8b143fc7bea13a7340ee3b0e6c123f688ac';
const inputScript = Buffer.from(inputScriptHex, 'hex');
const hashType = bitGoUTXO.Transaction.SIGHASH_ALL;
const zecNetwork = bitGoUTXO.networks.zcash;
const builder = new bitGoUTXO.TransactionBuilder(zecNetwork);
builder.setVersion(bitGoUTXO.Transaction.ZCASH_SAPLING_VERSION);
builder.setVersionGroupId(parseInt('0x892F2085', 16));
const keyPair = bitGoUTXO.ECPair.fromWIF(wif, zecNetwork);
builder.addInput(inputTxId, inputOutputN);
builder.addOutput(toAddress, inputAmount - minerFee);
builder.sign(0, keyPair, inputScript, hashType, inputAmount);
const signedTransaction = builder.build();
console.log(signedTransaction.toHex());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment