public byte [ ] getProgram ( ) { try { // Don't round-trip as Bitcoin Core doesn't and it would introduce a mismatch. 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 ) ; // Cannot happen. } }
Returns the serialized program as a newly created byte array .