public static VersionMessage read(ByteBuffer payload) throws BufferUnderflowException, ProtocolException {
        int clientVersion = (int) ByteUtils.readUint32(payload);
        check(clientVersion >= ProtocolVersion.MINIMUM.intValue(),
                ProtocolException::new);
        Services localServices = Services.read(payload);
        Instant time = Instant.ofEpochSecond(ByteUtils.readInt64(payload));
        Services receivingServices = Services.read(payload);
        InetAddress receivingInetAddress = PeerAddress.getByAddress(Buffers.readBytes(payload, 16));
        int receivingPort = ByteUtils.readUint16BE(payload);
        InetSocketAddress receivingAddr = new InetSocketAddress(receivingInetAddress, receivingPort);
        Buffers.skipBytes(payload, NETADDR_BYTES); // addr_from
        // uint64 localHostNonce (random data)
        // We don't care about the localhost nonce. It's used to detect connecting back to yourself in cases where
        // there are NATs and proxies in the way. However we don't listen for inbound connections so it's
        // irrelevant.
        Buffers.skipBytes(payload, 8);
        // string subVer (currently "")
        String subVer = Buffers.readLengthPrefixedString(payload);
        // int bestHeight (size of known block chain).
        long bestHeight = ByteUtils.readUint32(payload);
        boolean relayTxesBeforeFilter = clientVersion >= ProtocolVersion.BLOOM_FILTER.intValue() ?
                payload.get() != 0 :
                true;
        return new VersionMessage(clientVersion, localServices, time, receivingServices, receivingAddr, subVer,
                bestHeight, relayTxesBeforeFilter);
    }
@Test
    public void decode_noRelay_bestHeight_subVer() {
        // Test that we can decode version messages which miss data which some old nodes may not include
        String hex = "7111010000000000000000003334a85500000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d00000000000000000f2f626974636f696e6a3a302e31332f0004000000";
        VersionMessage ver = VersionMessage.read(ByteBuffer.wrap(ByteUtils.parseHex(hex)));
        assertFalse(ver.relayTxesBeforeFilter);
        assertEquals(1024, ver.bestHeight);
        assertEquals("/bitcoinj:0.13/", ver.subVer);
    }