private static void ReadWriteArray(this BitcoinStream bitcoinStream, ref byte[] data)
 {
     if (data == null && bitcoinStream.Serializing)
     {
         throw new ArgumentNullException("Impossible to serialize a null array");
     }
     if (bitcoinStream.Serializing)
     {
         var len = data == null ? 0 : (ulong)data.Length;
         if (len > (uint)bitcoinStream.MaxArraySize)
         {
             throw new ArgumentOutOfRangeException("Array size too big");
         }
         VarInt.StaticWrite(bitcoinStream, len);
         if (len == 0)
         {
             return;
         }
     }
     else
     {
         var len = VarInt.StaticRead(bitcoinStream);
         if (len > (uint)bitcoinStream.MaxArraySize)
         {
             throw new ArgumentOutOfRangeException("Array size too big");
         }
         data = new byte[len];
     }
     bitcoinStream.ReadWriteBytes(ref data);
 }