@Override
    public String toString() {
        if (data == null)
            return getOpCodeName(opcode);
        return String.format("%s[%s]", getPushDataName(opcode), ByteUtils.formatHex(data));
    }
@Test
    public void testToStringOnInvalidScriptChunk() {
        // see https://github.com/bitcoinj/bitcoinj/issues/1860
        // In summary: toString() throws when given an invalid ScriptChunk.
        // It should perhaps be impossible to even construct such a ScriptChunk, but
        // until that is the case, toString() should not throw.
        ScriptChunk pushWithoutData = new ScriptChunk(OP_PUSHDATA1, null);

        // the chunk is invalid, but at least we can determine its opcode
        assertEquals("PUSHDATA1", pushWithoutData.toString());
    }