Script { public byte[] getProgram() { try { if (program != null) return Arrays.copyOf(program, program.length); ByteArrayOutputStream bos = new ByteArrayOutputStream(); for (ScriptChunk chunk : chunks) { chunk.write(bos); } program = bos.toByteArray(); return program; } catch (IOException e) { throw new RuntimeException(e); } } 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(); byte[] getPubKeyHash(); byte[] getPubKey(); byte[] getCLTVPaymentChannelSenderPubKey(); byte[] getCLTVPaymentChannelRecipientPubKey(); BigInteger getCLTVPaymentChannelExpiry(); @Deprecated Address getFromAddress(NetworkParameters params); Address getToAddress(NetworkParameters params); Address getToAddress(NetworkParameters params, boolean forcePayToPubKey); 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); Script createEmptyInputScript(@Nullable ECKey key, @Nullable Script redeemScript); Script getScriptSigWithSignature(Script scriptSig, byte[] sigBytes, int index); int getSigInsertionIndex(Sha256Hash hash, ECKey signingKey); List<ECKey> getPubKeys(); static int getSigOpCount(byte[] program); static long getP2SHSigOpCount(byte[] scriptSig); int getNumberOfSignaturesRequiredToSpend(); int getNumberOfBytesRequiredToSpend(@Nullable ECKey pubKey, @Nullable Script redeemScript); boolean isPayToScriptHash(); boolean isSentToMultiSig(); boolean isSentToCLTVPaymentChannel(); static byte[] removeAllInstancesOf(byte[] inputScript, byte[] chunkToRemove); static byte[] removeAllInstancesOfOp(byte[] inputScript, int opCode); boolean isOpReturn(); boolean isUnspendable(); @Deprecated static void executeScript(@Nullable Transaction txContainingThis, long index,
                                     Script script, LinkedList<byte[]> stack, boolean enforceNullDummy); static void executeScript(@Nullable Transaction txContainingThis, long index,
                                     Script script, LinkedList<byte[]> stack, Set<VerifyFlag> verifyFlags); @Deprecated void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey); void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey,
                                Set<VerifyFlag> verifyFlags); ScriptType getScriptType(); @Override boolean equals(Object o); @Override int hashCode(); static final EnumSet<VerifyFlag> ALL_VERIFY_FLAGS; static final long MAX_SCRIPT_ELEMENT_SIZE; static final int SIG_SIZE; static final int MAX_P2SH_SIGOPS; }
@Test public void numberBuilderZero() { final ScriptBuilder builder = new ScriptBuilder(); builder.number(0); assertArrayEquals(new byte[] { 0x00 }, builder.build().getProgram()); }
@Test public void numberBuilderPositiveOpCode() { final ScriptBuilder builder = new ScriptBuilder(); builder.number(5); assertArrayEquals(new byte[] { 0x55 }, builder.build().getProgram()); }
@Test public void numberBuilderBigNum() { ScriptBuilder builder = new ScriptBuilder(); builder.number(0x524a); assertArrayEquals(new byte[] { 0x02, 0x4a, 0x52 }, builder.build().getProgram()); builder = new ScriptBuilder(); builder.number(0x110011); assertEquals(4, builder.build().getProgram().length); builder = new ScriptBuilder(); builder.number(0x8000); assertArrayEquals(new byte[] { 0x03, 0x00, (byte) 0x80, 0x00 }, builder.build().getProgram()); }
@Test public void numberBuilderNegative() { final ScriptBuilder builder = new ScriptBuilder(); builder.number(-5); assertArrayEquals(new byte[] { 0x01, ((byte) 133) }, builder.build().getProgram()); }