Returns the script that is fed to the referenced output (scriptPubKey) script in order to satisfy it: usually
contains signatures and maybe keys, but can contain arbitrary data if the output script accepts it.
518008
public Script getScriptSig() throws ScriptException {
        // Transactions that generate new coins don't actually have a script. Instead this
        // parameter is overloaded to be something totally different.
        Script script = scriptSig == null ? null : scriptSig.get();
        if (script == null) {
            script = new Script(scriptBytes);
            scriptSig = new WeakReference<>(script);
        }
        return script;
    }
1327923
def script_to_address(script, vbyte=0):
    '''
    
    '''
    if re.match('^[0-9a-fA-F]*$', script):
        script = binascii.unhexlify(script)
    if script[:3] == b'\x76\xa9\x14' and script[-2:] == b'\x88\xac' and len(script) == 25:
        return bin_to_b58check(script[3:-2], vbyte)  # pubkey hash addresses
    else:
        if vbyte in [111, 196]:
            # Testnet
            scripthash_byte = 196
        else:
            scripthash_byte = vbyte
        # BIP0016 scripthash addresses
        return bin_to_b58check(script[2:-1], scripthash_byte)
189257
def verify_input_sig_for_legacy(input_index, script_pubkey, flags)
      script_sig = inputs[input_index].script_sig
      checker = Bitcoin::TxChecker.new(tx: self, input_index: input_index)
      interpreter = Bitcoin::ScriptInterpreter.new(checker: checker, flags: flags)

      interpreter.verify_script(script_sig, script_pubkey)
    end
1372942
def payable(self, s):
        
        s = parseable_str(s)
        return self.address(s) or self.script(s)
861908
def verify_multisig(address, hash_hex, scriptSig):
    
    script_parts = virtualchain.btc_script_deserialize(scriptSig)
    if len(script_parts) < 2:
        log.warn("Verfiying multisig failed, couldn't grab script parts")
        return False

    redeem_script = script_parts[-1]
    script_sigs = script_parts[1:-1]

    if virtualchain.address_reencode(virtualchain.btc_make_p2sh_address(redeem_script)) != virtualchain.address_reencode(address):
        log.warn(("Address {} does not match redeem script {}".format(address, redeem_script)))
        return False

    m, pubk_hexes = virtualchain.parse_multisig_redeemscript(redeem_script)
    if len(script_sigs) != m:
        log.warn("Failed to validate multi-sig, not correct number of signatures: have {}, require {}".format(
            len(script_sigs), m))
        return False

    cur_pubk = 0
    for cur_sig in script_sigs:
        sig64 = base64.b64encode(binascii.unhexlify(cur_sig))
        sig_passed = False
        while not sig_passed:
            if cur_pubk >= len(pubk_hexes):
                log.warn("Failed to validate multi-signature, ran out of public keys to check")
                return False
            sig_passed = virtualchain.ecdsalib.verify_digest(hash_hex, pubk_hexes[cur_pubk], sig64)
            cur_pubk += 1

    return True
462672
def get_opcodes(self, script, verify_minimal_data=False, pc=0):
        
        while pc < len(script):
            opcode, data, new_pc, is_ok = self.scriptStreamer.get_opcode(
                script, pc, verify_minimal_data=verify_minimal_data)
            yield opcode, data, pc, new_pc
            pc = new_pc
922419
def get_smtlib_script_satisfiability(self, extra_constraints=(), extra_variables=()):
        
        try:
            e_csts = self._solver_backend.convert_list(extra_constraints + tuple(self.constraints))
            e_variables = self._solver_backend.convert_list(extra_variables)

            variables, csts = self._solver_backend._get_all_vars_and_constraints(e_c=e_csts, e_v=e_variables)
            return self._solver_backend._get_satisfiability_smt_script(csts, variables)
        except BackendError as e:
            raise ClaripyFrontendError("Backend error during smtlib script generation") from e
687822
public static Script createInputScript(@Nullable TransactionSignature signature) {
        byte[] sigBytes = signature != null ? signature.encodeToBitcoin() : new byte[]{};
        return new ScriptBuilder().data(sigBytes).build();
    }
99053
def script_exists(self, digest, *digests):
        """"""
        return self.execute(b'SCRIPT', b'EXISTS', digest, *digests)
298668
def CreateSignatureContract(publicKey):
        
        script = Contract.CreateSignatureRedeemScript(publicKey)
        params = b'\x00'
        encoded = publicKey.encode_point(True)
        pubkey_hash = Crypto.ToScriptHash(encoded, unhex=True)

        return Contract(script, params, pubkey_hash)
581090
def get_fingerprint_from_public_key(pubkey):
    

    # TODO: why is there a tmpdir?
    with tempdir() as workdir:
        key = os.path.join(workdir, 'key.pub')
        with open(key, 'w') as fd:
            fd.write(pubkey)

        cmd = [
            'ssh-keygen',
            '-l',
            '-f', key,
        ]

        p = Subprocess(cmd)
        output = p.stdout.strip()
        bits, fingerprint, _ = output.split(' ', 2)
        return fingerprint
6527
@Override
    public ScriptType getOutputScriptType() {
        int version = getWitnessVersion();
        checkState(version == 0);
        int programLength = getWitnessProgram().length;
        if (programLength == WITNESS_PROGRAM_LENGTH_PKH)
            return ScriptType.P2WPKH;
        if (programLength == WITNESS_PROGRAM_LENGTH_SH)
            return ScriptType.P2WSH;
        throw new IllegalStateException("Cannot happen.");
    }
110771
def annotate_scripts(self, tx, tx_in_idx):
        ""
        # input_annotations_f, output_annotations_f = annotation_f_for_scripts(tx, tx_in_idx)

        data_annotations = collections.defaultdict(list)

        def traceback_f(opcode, data, pc, vmc):
            if opcode in (self.OP_CHECKSIG, self.OP_CHECKSIGVERIFY):
                self.annotate_checksig(vmc, data_annotations)
            if opcode in (self.OP_CHECKMULTISIG, self.OP_CHECKMULTISIGVERIFY):
                self.annotate_checkmultisig(vmc, data_annotations)
            return

        try:
            tx.check_solution(tx_in_idx, traceback_f=traceback_f)
        except ScriptError:
            pass

        r = []

        def traceback_f(opcode, data, pc, vmc):
            a0 = []
            if vmc.pc == 0:
                if vmc.is_solution_script:
                    a0.append("--- SIGNATURE SCRIPT START")
                else:
                    a0.append("--- PUBLIC KEY SCRIPT START")
            r.append((a0, vmc.pc, opcode, self.instruction_for_opcode(opcode, data), data_annotations[data]))

        try:
            tx.check_solution(tx_in_idx, traceback_f=traceback_f)
        except ScriptError:
            pass

        # the script may have ended early, so let's just double-check
        try:
            for idx, (opcode, data, pc, new_pc) in enumerate(itertools.chain(
                self._script_tools.get_opcodes(tx.unspents[tx_in_idx].script),
                    self._script_tools.get_opcodes(tx.txs_in[tx_in_idx].script))):
                if idx >= len(r):
                    r.append(([], pc, opcode, self.instruction_for_opcode(opcode, data), []))
        except IndexError:
            pass

        return r
661737
def get_output_key(self, args, kwargs):
        
        # Get a dictionary mapping argument names to argument values where
        # ignored arguments are omitted.
        filtered_args = joblib.func_inspect.filter_args(
            self.func, self.ignore, args, kwargs)
        # Get a sorted tuple of the filtered argument.
        filtered_args = tuple(sorted(filtered_args.values()))
        # Use native hash when hashing arguments.
        return db.generate_key(filtered_args)
975258
def from_output_script(output_script, cashaddr=True):
    '''
    
    '''
    try:
        if (len(output_script) == len(riemann.network.P2WSH_PREFIX) + 32
                and output_script.find(riemann.network.P2WSH_PREFIX) == 0):
            # Script hash is the last 32 bytes
            return _hash_to_sh_address(
                output_script[-32:], witness=True, cashaddr=cashaddr)
    except TypeError:
        pass
    try:
        if (len(output_script) == len(riemann.network.P2WPKH_PREFIX) + 20
                and output_script.find(riemann.network.P2WPKH_PREFIX) == 0):
            # PKH is the last 20 bytes
            return _make_pkh_address(
                output_script[-20:], witness=True, cashaddr=cashaddr)
    except TypeError:
        pass

    if len(output_script) == 25 and output_script.find(b'\x76\xa9\x14') == 0:
        return _make_pkh_address(
            output_script[3:23], witness=False, cashaddr=cashaddr)

    elif len(output_script) == 23 and output_script.find(b'\xa9\x14') == 0:
        return _hash_to_sh_address(
            output_script[2:22], witness=False, cashaddr=cashaddr)

    raise ValueError('Cannot parse address from script.')
1332585
public static Script createOutputScript(Address to) {
        if (to instanceof LegacyAddress) {
            ScriptType scriptType = to.getOutputScriptType();
            if (scriptType == ScriptType.P2PKH)
                return createP2PKHOutputScript(to.getHash());
            else if (scriptType == ScriptType.P2SH)
                return createP2SHOutputScript(to.getHash());
            else
                throw new IllegalStateException("Cannot handle " + scriptType);
        } else if (to instanceof SegwitAddress) {
            ScriptBuilder builder = new ScriptBuilder();
            // OP_0 <pubKeyHash|scriptHash>
            SegwitAddress toSegwit = (SegwitAddress) to;
            builder.smallNum(toSegwit.getWitnessVersion());
            builder.data(toSegwit.getWitnessProgram());
            return builder.build();
        } else {
            throw new IllegalStateException("Cannot handle " + to);
        }
    }
1149741
@Override
    public Script freshOutputScript(KeyPurpose purpose) {
        DeterministicKey followedKey = getKey(purpose);
        ImmutableList.Builder<ECKey> keys = ImmutableList.<ECKey>builder().add(followedKey);
        for (DeterministicKeyChain keyChain : followingKeyChains) {
            DeterministicKey followingKey = keyChain.getKey(purpose);
            checkState(followedKey.getChildNumber().equals(followingKey.getChildNumber()), "Following keychains should be in sync");
            keys.add(followingKey);
        }
        List<ECKey> marriedKeys = keys.build();
        Script redeemScript = ScriptBuilder.createRedeemScript(sigsRequiredToSpend, marriedKeys);
        return ScriptBuilder.createP2SHOutputScript(redeemScript);
    }