Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// p2pk encode scriptSig
else if(!(s as ScriptSigP2PKH).pubKeyBuf && (s as ScriptSigP2PKH).signatureBuf) {
bip62Encoded = this.slp.BITBOX.Script.encode([ (s as ScriptSigP2PKH).signatureBuf ]);
}
// throw if input data did not result in encoded scriptSig
if(!bip62Encoded)
throw Error("Was not able to set input script for index="+s.index);
// actually set the input's scriptSig property
let script = new Bitcore.Script(bip62Encoded);
txn.inputs[s.index].setScript(script);
// console.log("scriptSig for index", s.input_index, ":", bip62Encoded.toString('hex'))
})
app.add_op_return_data = (tx, data) => {
let script = new bch.Script();
script.add(bch.Opcode.OP_RETURN);
for (let m of data) {
if (m['type'] == 'hex') {
script.add(Buffer.from(m['v'], 'hex'));
} else if(m['type'] == 'str') {
script.add(Buffer.from(m['v']));
} else {
throw new Error('unknown data type');
}
}
tx.addOutput(new bch.Transaction.Output({
script: script,
satoshis: 0