How to use the bitcore-lib-cash.Script function in bitcore-lib-cash

To help you get started, we’ve selected a few bitcore-lib-cash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simpleledger / slpjs / lib / transactionhelpers.ts View on Github external
}

            // 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'))
        })
github blockparty-sh / craft.cash / src / main.js View on Github external
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