Script { public byte[] getPubKey() throws ScriptException { if (chunks.size() != 2) { throw new ScriptException("Script not of right size, expecting 2 but got " + chunks.size()); } final ScriptChunk chunk0 = chunks.get(0); final byte[] chunk0data = chunk0.data; final ScriptChunk chunk1 = chunks.get(1); final byte[] chunk1data = chunk1.data; if (chunk0data != null && chunk0data.length > 2 && chunk1data != null && chunk1data.length > 2) { return chunk1data; } else if (chunk1.equalsOpCode(OP_CHECKSIG) && chunk0data != null && chunk0data.length > 2) { return chunk0data; } else { throw new ScriptException("Script did not match expected form: " + toString()); } } private  Script();   Script(List<ScriptChunk> chunks);  Script(byte[] programBytes);  Script(byte[] programBytes, long creationTimeSeconds); long getCreationTimeSeconds(); void setCreationTimeSeconds(long creationTimeSeconds); @Override String toString(); byte[] getProgram(); List<ScriptChunk> getChunks(); boolean isSentToRawPubKey(); boolean isSentToAddress(); @Deprecated boolean isSentToP2SH(); boolean isSendFromMultiSig(); boolean isMultiSigRedeem(); byte[] getPubKeyHash(); byte[] getPubKey(); @Deprecated byte[] getSig(); List<byte[]> getSigs(); String getFromAddress(); String getToAddress(); static void writeBytes(OutputStream os, byte[] buf); static byte[] createMultiSigOutputScript(int threshold, List<ECKey> pubkeys); static byte[] createInputScript(byte[] signature, byte[] pubkey); static byte[] createInputScript(byte[] signature); static int encodeToOpN(int value); static int getSigOpCount(byte[] program); static long getP2SHSigOpCount(byte[] scriptSig); int getNumberOfBytesRequiredToSpend(@Nullable ECKey pubKey, @Nullable Script redeemScript); List<byte[]> getP2SHPubKeys(Tx tx, int index); int getNumberOfBytesRequiredToSpend(boolean isCompressed, @Nullable Script redeemScript); boolean isPayToScriptHash(); boolean isSentToMultiSig(); static byte[] removeAllInstancesOf(byte[] inputScript, byte[] chunkToRemove); static byte[] removeAllInstancesOfOp(byte[] inputScript, int opCode); void correctlySpends(Tx txContainingThis, long scriptSigIndex, Script scriptPubKey,
                                boolean enforceP2SH); @Override boolean equals(Object o); @Override int hashCode(); static final long MAX_SCRIPT_ELEMENT_SIZE; static final int SIG_SIZE; }
@Test public void testScriptSig() throws Exception { byte[] sigProgBytes = Utils.hexStringToByteArray(sigProg); Script script = new Script(sigProgBytes); byte[] hash160 = Utils.sha256hash160(script.getPubKey()); String address = this.toAddress(hash160, 111); assertEquals("mkFQohBpy2HDXrCwyMrYL5RtfrmeiuuPY2", address); }